Class: Matchers::BuiltIn::Change
- Inherits:
-
Object
- Object
- Matchers::BuiltIn::Change
- Includes:
- RSpec::ChangeToNow::Matchers::DSL
- Defined in:
- lib/rspec/change_to_now.rb
Instance Method Summary collapse
-
#not_to_now(matcher) ⇒ Object
(also: #not_to, #not_now_to, #to_not, #to_not_now)
Passes if
matcher
passes on the result of the change block before the expectation block and fails after. -
#to_now(matcher) ⇒ Object
(also: #now_to)
Passes if
matcher
fails on the result of the change block before the expectation block and passes after. - #to_with_to_now(expected) ⇒ Object (also: #to)
- #with_final_result(expected) ⇒ Object
Methods included from RSpec::ChangeToNow::Matchers::DSL
#as_matcher, #matcher_only, #negate
Methods included from RSpec::ChangeToNow::Matchers::DSL::Detect
Instance Method Details
#not_to_now(matcher) ⇒ Object Also known as: not_to, not_now_to, to_not, to_not_now
Passes if matcher
passes on the result of the change block before the expectation block and fails after.
32 33 34 35 |
# File 'lib/rspec/change_to_now.rb', line 32 def not_to_now(matcher) RSpec::Matchers::BuiltIn::ChangeToValue.new(@change_details, negate(as_matcher(matcher))). from(as_matcher(matcher)) end |
#to_now(matcher) ⇒ Object Also known as: now_to
Passes if matcher
fails on the result of the change block before the expectation block and passes after.
In implementation, this is identical to
change {}.to eq { }`
is the same as
change {}.to_now eq(1)
change {}.from(negate(eq(1))).to(eq(1))
22 23 24 25 |
# File 'lib/rspec/change_to_now.rb', line 22 def to_now(matcher) RSpec::Matchers::BuiltIn::ChangeToValue.new(@change_details, as_matcher(matcher)). from(negate(as_matcher(matcher))) end |
#to_with_to_now(expected) ⇒ Object Also known as: to
56 57 58 59 60 61 62 |
# File 'lib/rspec/change_to_now.rb', line 56 def to_with_to_now(expected) if RSpec::ChangeToNow.override_to && RSpec::Matchers.is_a_matcher?(expected) to_now(expected) else to_without_to_now(expected) end end |
#with_final_result(expected) ⇒ Object
68 69 70 |
# File 'lib/rspec/change_to_now.rb', line 68 def with_final_result(expected) to_without_to_now(expected) end |