class RSpec::Matchers::BuiltIn::SpecificValuesChange

@api private Base class for specifying a change from and/or to specific values.

Constants

MATCH_ANYTHING

@private

Public Class Methods

new(change_details, from, to) click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 160
def initialize(change_details, from, to)
  @change_details  = change_details
  @expected_before = from
  @expected_after  = to
end

Public Instance Methods

description() click to toggle source

@private

# File lib/rspec/matchers/built_in/change.rb, line 175
def description
  "change #{@change_details.message} #{change_description}"
end
failure_message() click to toggle source

@private

# File lib/rspec/matchers/built_in/change.rb, line 180
def failure_message
  return not_given_a_block_failure unless Proc === @event_proc
  return before_value_failure      unless matches_before?
  return did_not_change_failure    unless @change_details.changed?
  after_value_failure
end
matches?(event_proc) click to toggle source

@private

# File lib/rspec/matchers/built_in/change.rb, line 167
def matches?(event_proc)
  @event_proc = event_proc
  return false unless Proc === event_proc
  @change_details.perform_change(event_proc)
  @change_details.changed? && matches_before? && matches_after?
end
supports_block_expectations?() click to toggle source

@private

# File lib/rspec/matchers/built_in/change.rb, line 188
def supports_block_expectations?
  true
end

Private Instance Methods

after_value_failure() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 206
def after_value_failure
  "expected #{@change_details.message} to have changed to #{description_of @expected_after}, but is now #{description_of @change_details.actual_after}"
end
before_value_failure() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 202
def before_value_failure
  "expected #{@change_details.message} to have initially been #{description_of @expected_before}, but was #{description_of @change_details.actual_before}"
end
did_change_failure() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 214
def did_change_failure
  "expected #{@change_details.message} not to have changed, but did change from #{description_of @change_details.actual_before} to #{description_of @change_details.actual_after}"
end
did_not_change_failure() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 210
def did_not_change_failure
  "expected #{@change_details.message} to have changed #{change_description}, but did not change"
end
matches_after?() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 198
def matches_after?
  values_match?(@expected_after, @change_details.actual_after)
end
matches_before?() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 194
def matches_before?
  values_match?(@expected_before, @change_details.actual_before)
end
not_given_a_block_failure() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 218
def not_given_a_block_failure
  "expected #{@change_details.message} to have changed #{change_description}, but was not given a block"
end