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.
Instance Method Summary collapse
-
#initialize(value) ⇒ ExpectationTarget
constructor
private
A new instance of ExpectationTarget.
-
#not_to(matcher = nil, message = nil, &block) ⇒ Boolean
(also: #to_not)
Runs the given expectation, passing if
matcher
returns false. -
#to(matcher = nil, message = nil, &block) ⇒ Boolean
Runs the given expectation, passing if
matcher
returns true.
Constructor Details
#initialize(value) ⇒ ExpectationTarget
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
#not_to(matcher = nil, message = nil, &block) ⇒ Boolean 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 |
#to(matcher = nil, message = nil, &block) ⇒ Boolean
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 |