Class: BuiltIn::Change

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/change_to_now.rb

Instance Method Summary collapse

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.

Examples:

expect({ @x = 1 }.to change { @x }.not_to_now eq 1


29
30
31
# File 'lib/rspec/change_to_now.rb', line 29

def not_to_now(matcher)
  RSpec::Matchers::BuiltIn::ChangeToValue.new(@change_details, negate(matcher)).from(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))

Examples:

expect({ @x = 1 }.to change { @x }.to_now eq 1


20
21
22
# File 'lib/rspec/change_to_now.rb', line 20

def to_now(matcher)
  RSpec::Matchers::BuiltIn::ChangeToValue.new(@change_details, matcher).from(negate(matcher))
end