Class: RSpec::Expectations::ExpectationTarget
- Inherits:
-
Object
- Object
- RSpec::Expectations::ExpectationTarget
- Defined in:
- lib/rspec/expectations/expectation_target.rb
Overview
Note:
ExpectationTarget
is not intended to be instantiated
directly by users. Use expect
instead.
Wraps the target of an expectation.
Constant Summary
Instance Method Summary (collapse)
-
- (ExpectationTarget) initialize(value)
constructor
private
A new instance of ExpectationTarget.
-
- (Boolean) not_to(matcher = nil, message = nil, &block)
(also: #to_not)
Runs the given expectation, passing if
matcher
returns false. -
- (Boolean) to(matcher = nil, message = nil, &block)
Runs the given expectation, passing if
matcher
returns true.
Constructor Details
- (ExpectationTarget) initialize(value)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ExpectationTarget
25 26 27 |
# File 'lib/rspec/expectations/expectation_target.rb', line 25 def initialize(value) @target = value end |
Instance Method Details
- (Boolean) not_to(matcher = nil, message = nil, &block) Also known as: to_not
Runs the given expectation, passing if matcher
returns false.
65 66 67 68 |
# File 'lib/rspec/expectations/expectation_target.rb', line 65 def not_to(matcher=nil, =nil, &block) prevent_operator_matchers(:not_to) unless matcher RSpec::Expectations::NegativeExpectationHandler.handle_matcher(@target, matcher, , &block) end |
- (Boolean) to(matcher = nil, message = nil, &block)
Runs the given expectation, passing if matcher
returns true.
52 53 54 55 |
# File 'lib/rspec/expectations/expectation_target.rb', line 52 def to(matcher=nil, =nil, &block) prevent_operator_matchers(:to) unless matcher RSpec::Expectations::PositiveExpectationHandler.handle_matcher(@target, matcher, , &block) end |