@private Validates the provided matcher to ensure it supports block expectations, in order to avoid user confusion when they use a block thinking the expectation will be on the return value of the block rather than the block itself.
# File lib/rspec/expectations/expectation_target.rb, line 90 def not_to(matcher, message=nil, &block) enforce_block_expectation(matcher) super end
# File lib/rspec/expectations/expectation_target.rb, line 85 def to(matcher, message=nil, &block) enforce_block_expectation(matcher) super end
# File lib/rspec/expectations/expectation_target.rb, line 113 def description_of(matcher) matcher.description rescue NoMethodError matcher.inspect end
# File lib/rspec/expectations/expectation_target.rb, line 98 def enforce_block_expectation(matcher) return if supports_block_expectations?(matcher) raise ExpectationNotMetError, "You must pass an argument rather than a block to use the provided " + "matcher (#{description_of matcher}), or the matcher must implement " + "`supports_block_expectations?`." end
# File lib/rspec/expectations/expectation_target.rb, line 107 def supports_block_expectations?(matcher) matcher.supports_block_expectations? rescue NoMethodError false end