-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Possible enhancement for responds_with matcher? #578
Comments
@vlad-pisanov Thanks for the suggestion. At first glance it sounds sensible to me. I'll take a proper look at it early next week. |
@vlad-pisanov I haven't got much time at the moment, but I managed to find a few minutes to draft this PR. Is that roughly what you had in mind? |
@floehopper nice, that's exactly it! I like the idea of using |
This provides a terser syntax for matching an object which responds in a certain way, e.g. object = mock() object.expects(:method_1).with(responds_with(:upcase => "FOO", :reverse => "oof")) object.method_1("foo") # no error raised, because "foo".upcase == "FOO" and "foo".reverse == "oof" Addresses #578.
This provides a terser syntax for matching an object which responds in a certain way, e.g. object = mock() object.expects(:method_1).with(responds_with(:upcase => "FOO", :reverse => "oof")) object.method_1("foo") # no error raised, because "foo".upcase == "FOO" and "foo".reverse == "oof" Addresses #578.
This provides a terser syntax for matching an object which responds in a certain way, e.g. object = mock() object.expects(:method_1).with(responds_with(:upcase => "FOO", :reverse => "oof")) object.method_1("foo") # no error raised, because "foo".upcase == "FOO" and "foo".reverse == "oof" Addresses #578.
This provides a terser syntax for matching an object which responds in a certain way, e.g. object = mock() object.expects(:method_1).with(responds_with(:upcase => "FOO", :reverse => "oof")) object.method_1("foo") # no error raised, because "foo".upcase == "FOO" and "foo".reverse == "oof" Addresses #578.
Closed by #579. Sorry it's taken so long! |
Currently, the matcher
responds_with
takes 2 params: an attribute and a value, like:How about introducing a variation of this matcher that takes multiple attribute-value pairs? e.g.
The matcher would succeed if all attributes match. This would give us a compact way of matching complex objects, and the syntax would be symmetrical to the
has_entries
matcher that we currently have for Hashes:The text was updated successfully, but these errors were encountered: