Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract differ to support #441

Merged
merged 1 commit into from
Mar 27, 2014
Merged

Conversation

phiggins
Copy link
Contributor

This was done to support rspec/rspec-mocks#434 and depends on rspec/rspec-support#36.

I'm not extremely happy with the way I did the fail_with tests that call the differ in support, but I wasn't sure if testing that the proper options were passed vs testing the actual integration with the differ was preferred: https://github.com/phiggins/rspec-expectations/blob/a3c1888b92b82456d166b9c39255f605a8261d2f/spec/rspec/expectations/fail_with_spec.rb

@myronmarston
Copy link
Member

Thanks for working on this, @phiggins. I've got a backlog of other PRs I'm reviewing and helping with so it might be a few days before I get to this.

@phiggins
Copy link
Contributor Author

No rush @myronmarston, I just wanted to get this up before too much time had passed.

@JonRowe
Copy link
Member

JonRowe commented Feb 1, 2014

I'd feel more comfortable with this if the differ was configurable, and set to the support differ by default, that way you could inject a double rather than stubbing the instantiation of the differ.

module RSpec
module Expectations
class << self
# @private
def differ
DiffPresenter.new
RSpec::Support::DiffPresenter.new(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also rather this took definitive options rather than a hash...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "definitive options"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguments I guess, see the rspec/rspec-support#36 for further discussion of this though

@phiggins
Copy link
Contributor Author

phiggins commented Feb 1, 2014

I'd feel more comfortable with this if the differ was configurable, and set to the support differ by default, that way you could inject a double rather than stubbing the instantiation of the differ.

That is a great idea, will do.

module RSpec
module Expectations
class << self
# @private
def differ
DiffPresenter.new
RSpec::Support::DiffPresenter.new(
stringifier: lambda {|object| RSpec::Matchers::Composable.surface_descriptions_in(object) },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that stringifier is the right name for this -- it suggests that the lambda returns a string, and this lambda doesn't: it returns the same kind of object (such as an array or hash) with any matchers appropriately replaced with objects whose inspect returns the description of the matcher.

Maybe object_preparer is a better name? It prepares objects for being diffed.

@myronmarston
Copy link
Member

I'm not extremely happy with the way I did the fail_with tests that call the differ in support, but I wasn't sure if testing that the proper options were passed vs testing the actual integration with the differ was preferred: https://github.com/phiggins/rspec-expectations/blob/a3c1888b92b82456d166b9c39255f605a8261d2f/spec/rspec/expectations/fail_with_spec.rb

I prefer testing the actual integration. The external behavior for the user is the final error message that is produced. The options passed to achieve that are an implementation detail that we may refactor.

@phiggins
Copy link
Contributor Author

phiggins commented Feb 5, 2014

There's still a bit of work to be done on both tickets so I might not get this done immediately. Thanks so much for the feedback guys!

@phiggins
Copy link
Contributor Author

I think I have addressed all of the feedback given. What do you folks think?

@JonRowe
Copy link
Member

JonRowe commented Mar 24, 2014

Needs rebasing for a start... ;)

@@ -1,9 +1,14 @@
require 'rspec/support/differ'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should leverage our new require stuff.

@JonRowe
Copy link
Member

JonRowe commented Mar 24, 2014

Looking good, needs rebasing, squashing, and a minor update. We also need the support side merged first.

@phiggins
Copy link
Contributor Author

This has been rebased.

@JonRowe
Copy link
Member

JonRowe commented Mar 24, 2014

Still needs squashing please :)

@phiggins
Copy link
Contributor Author

I pushed some changes to rspec-support that should fix the build failures, but I can't as a non-repo owner force travis to rebuild. :/

@phiggins
Copy link
Contributor Author

Squashed this one as well.

@phiggins
Copy link
Contributor Author

Travis says the build failed, but these all look fine to me... ?

https://travis-ci.org/rspec/rspec-expectations/jobs/21604745

@JonRowe
Copy link
Member

JonRowe commented Mar 26, 2014

I've merged support so can you drop the references to your branch?

@@ -1,9 +1,14 @@
RSpec::Support.require_rspec_support('differ')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for brackets here.

@JonRowe
Copy link
Member

JonRowe commented Mar 26, 2014

LGTM, as soon as you've restored the support dependency and it goes green I'll merge.

@phiggins
Copy link
Contributor Author

Cool, it's in the middle of my work day right now so it'll be a few hours.

@JonRowe
Copy link
Member

JonRowe commented Mar 26, 2014

No worries, it's almost the start of my work day ;)

@JonRowe
Copy link
Member

JonRowe commented Mar 26, 2014

Just ping a comment when you've done it, as github doesn't notify us of commits

@phiggins
Copy link
Contributor Author

Will do!

@phiggins
Copy link
Contributor Author

The support dependency is back to normal and I removed the extra parenthesis you noted. Travis is running but it looks like that takes a while.

JonRowe added a commit that referenced this pull request Mar 27, 2014
@JonRowe JonRowe merged commit ec2e9a2 into rspec:master Mar 27, 2014
@JonRowe
Copy link
Member

JonRowe commented Mar 27, 2014

Thanks @phiggins!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants