Skip to content

Improved detection of matchers in argument lists.

gitlab-qa-bot requested to merge github/fork/codebeige/master into master

Created by: codebeige

It is quite likely to have an object responding to #matches? and #description that is not a matcher. All Mongoid models for instance respond to #matches? — as soon as you add a field called #description you are caught.

The following leads to an error: view.should_receive(:my_helper_path).with(record)

So I changed the implementation to check for #failure_message_for_should instead of #description. This seems to be closer to the definition of a matcher anyway.

See corresponding docs:

rspec-expecations provides a number of useful Matchers we use to compose expectations. A Matcher is any object that responds to the following:

matches?(actual) failure_message_for_should

These methods are also part of the matcher protocol, but are optional:

does_not_match?(actual) failure_message_for_should_not description #optional

Merge request reports