Skip to content

Commit

Permalink
fixup!
Browse files Browse the repository at this point in the history
rspec-collection_matchers' `have` matcher is very sensitive to chained
methods called on it and considers it a model name. When we happen to
call `supports_value_expectations?` on `have(3).players`, it is
overriding the previously passed model name (`players`).
  • Loading branch information
pirj committed Sep 14, 2019
1 parent 3c0a85e commit 05edeb7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/rspec/expectations/expectation_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ def enforce_value_expectation(matcher)
end

def supports_value_expectations?(matcher)
matcher.supports_value_expectations?
rescue NoMethodError
true
if matcher.respond_to?(:supports_value_expectations?)
matcher.supports_value_expectations?
else
true
end
end
end

Expand Down Expand Up @@ -150,9 +152,11 @@ def enforce_block_expectation(matcher)
end

def supports_block_expectations?(matcher)
matcher.supports_block_expectations?
rescue NoMethodError
false
if matcher.respond_to?(:supports_block_expectations?)
matcher.supports_block_expectations?
else
false
end
end
end
end
Expand Down

0 comments on commit 05edeb7

Please sign in to comment.