Class: RSpec::Expectations::BlockExpectationTarget 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, message = nil, &block) (also: #to_not) Internal use only
- #to(matcher, message = nil, &block) Internal use only
-
#to_not(matcher, message = nil, &block)
Alias for #not_to.
- #enforce_block_expectation(matcher) private Internal use only
- #supports_block_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_block_expectation(matcher) (private)
# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 150
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
#not_to(matcher, message = nil, &block) Also known as: #to_not
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 142
def not_to(matcher, =nil, &block) enforce_block_expectation(matcher) super end
#supports_block_expectations?(matcher) ⇒ Boolean
(private)
# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 158
def supports_block_expectations?(matcher) matcher.respond_to?(:supports_block_expectations?) && matcher.supports_block_expectations? end
#to(matcher, message = nil, &block)
[ GitHub ]# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 137
def to(matcher, =nil, &block) enforce_block_expectation(matcher) super end
#to_not(matcher, message = nil, &block)
Alias for #not_to.
# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 146
alias to_not not_to