Class: RSpec::Expectations::ValueExpectationTarget Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
ExpectationTarget
|
|
Instance Chain:
|
|
Inherits: |
RSpec::Expectations::ExpectationTarget
|
Defined in: | rspec-expectations/lib/rspec/expectations/expectation_target.rb |
Overview
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.
Constant Summary
ExpectationTarget
- Inherited
Class Method Summary
ExpectationTarget
- Inherited
Instance Attribute Summary
ExpectationTarget
- Inherited
Instance Method Summary
- #not_to(matcher = nil, message = nil, &block) Internal use only
- #to(matcher = nil, message = nil, &block) Internal use only
- #enforce_value_expectation(matcher) private Internal use only
- #supports_value_expectations?(matcher) ⇒ Boolean private Internal use only
ExpectationTarget::InstanceMethods
- Included
#not_to | Runs the given expectation, passing if |
#to | Runs the given expectation, passing if |
#to_not | Alias for ExpectationTarget::InstanceMethods#not_to. |
#prevent_operator_matchers |
Instance Method Details
#enforce_value_expectation(matcher) (private)
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 111
def enforce_value_expectation(matcher) return if supports_value_expectations?(matcher) RSpec.deprecate( "expect(value).to #{RSpec::Support::ObjectFormatter.format(matcher)}", : => "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
#not_to(matcher = nil, message = nil, &block)
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 104
def not_to(matcher=nil, =nil, &block) enforce_value_expectation(matcher) super end
#supports_value_expectations?(matcher) ⇒ Boolean
(private)
# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 126
def supports_value_expectations?(matcher) !matcher.respond_to?(:supports_value_expectations?) || matcher.supports_value_expectations? end
#to(matcher = nil, message = nil, &block)
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 99
def to(matcher=nil, =nil, &block) enforce_value_expectation(matcher) super end