class RSpec::Expectations::ValueExpectationTarget
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_value_expectation(matcher)
def enforce_value_expectation(matcher) return if supports_value_expectations?(matcher) RSpec.deprecate( "expect(value).to #{RSpec::Support::ObjectFormatter.format(matcher)}", :message => "The implicit block expectation syntax is deprecated, you should pass " \ "a block rather than an argument to `expect` to use the provided " \ "block expectation matcher or the matcher must implement " \ "`supports_value_expectations?`. e.g `expect { value }.to " \ "#{RSpec::Support::ObjectFormatter.format(matcher)}` not " \ "`expect(value).to #{RSpec::Support::ObjectFormatter.format(matcher)}`" ) end
def not_to(matcher=nil, message=nil, &block)
def not_to(matcher=nil, message=nil, &block) enforce_value_expectation(matcher) super end
def supports_value_expectations?(matcher)
def supports_value_expectations?(matcher) !matcher.respond_to?(:supports_value_expectations?) || matcher.supports_value_expectations? end
def to(matcher=nil, message=nil, &block)
def to(matcher=nil, message=nil, &block) enforce_value_expectation(matcher) super end