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 description_of(matcher)

def description_of(matcher)
  matcher.description
rescue NoMethodError
  matcher.inspect
end

def enforce_block_expectation(matcher)

def enforce_block_expectation(matcher)
  return if supports_block_expectations?(matcher)
  RSpec.deprecate("Using a matcher in a block expectation expression " +
                  "(e.g. `expect { }.to matcher`) that does not implement " +
                  "`supports_block_expectations?`",
                  :replacement => "a value expectation expression " +
                  "(e.g. `expect(value).to matcher`) or implement " +
                  "`supports_block_expectations?` on the provided matcher " +
                  "(#{description_of matcher})")
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.supports_block_expectations?
rescue NoMethodError
  false
end

def to(matcher, message=nil, &block)

def to(matcher, message=nil, &block)
  enforce_block_expectation(matcher)
  super
end