class RSpec::Expectations::BlockExpectationTarget
value of the block rather than the block itself.
use a block thinking the expectation will be on the return
expectations, in order to avoid user confusion when they
Validates the provided matcher to ensure it supports block
@private
def enforce_block_expectation(matcher)
def enforce_block_expectation(matcher) return if supports_block_expectations?(matcher) raise ExpectationNotMetError, "You must pass an argument rather than a block to `expect` to use the provided " \ "matcher (#{RSpec::Support::ObjectFormatter.format(matcher)}), or the matcher must implement " \ "`supports_block_expectations?`." end
def not_to(matcher, message=nil, &block)
def not_to(matcher, message=nil, &block) enforce_block_expectation(matcher) super end
def supports_block_expectations?(matcher)
def supports_block_expectations?(matcher) matcher.respond_to?(:supports_block_expectations?) && matcher.supports_block_expectations? end
def to(matcher, message=nil, &block)
def to(matcher, message=nil, &block) enforce_block_expectation(matcher) super end