class RSpec::Matchers::BuiltIn::ChangeFromValue

@api private Used to specify a change from a specific value (and, optionally, to a specific value).

Public Class Methods

new(change_details, expected_before) click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 256
def initialize(change_details, expected_before)
  @description_suffix = nil
  super(change_details, expected_before, MATCH_ANYTHING)
end

Public Instance Methods

does_not_match?(event_proc) click to toggle source

@private

# File lib/rspec/matchers/built_in/change.rb, line 270
def does_not_match?(event_proc)
  if @description_suffix
    raise NotImplementedError, "`expect { }.not_to change { }.to()` " \
      "is not supported"
  end

  perform_change(event_proc) && !@change_details.changed? && @matches_before
end
failure_message_when_negated() click to toggle source

@private

# File lib/rspec/matchers/built_in/change.rb, line 280
def failure_message_when_negated
  return not_given_a_block_failure unless Proc === @event_proc
  return before_value_failure unless @matches_before
  did_change_failure
end
to(value) click to toggle source

@api public Specifies the new value you expect.

# File lib/rspec/matchers/built_in/change.rb, line 263
def to(value)
  @expected_after     = value
  @description_suffix = " to #{description_of value}"
  self
end

Private Instance Methods

change_description() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 288
def change_description
  "from #{description_of @expected_before}#{@description_suffix}"
end