-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Fix an error when passed non-array to match_array #135
Conversation
items = *items | ||
BuiltIn::MatchArray.new(items) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be?
items = *items | |
BuiltIn::MatchArray.new(items) | |
BuiltIn::MatchArray.new(items.is_a?(Array) ? items : [items] ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original implementation is splatting the given argument, so I believe it would be more strict to do the same conversion.
https://github.com/rspec/rspec-expectations/blob/040d1b0bba83031c9ae432fd3a4462fdd1cc74e7/lib/rspec/matchers.rb#L715-L717
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call!
Hi @wata727, sorry it has taken me so long to get to this PR. I took a closer look at the current behavior of |
This fix has been included in v0.11.0. Thanks again! |
Fixes #132
This issue is caused by a difference in handling arguments to the monkey patched
match_array
. In the original matcher implementation, the arguments are splatted:https://github.com/rspec/rspec-expectations/blob/040d1b0bba83031c9ae432fd3a4462fdd1cc74e7/lib/rspec/matchers.rb#L715-L717
https://github.com/rspec/rspec-expectations/blob/040d1b0bba83031c9ae432fd3a4462fdd1cc74e7/lib/rspec/matchers.rb#L510-L512