class RSpec::Matchers::BuiltIn::SpecificValuesChange
Base class for specifying a change from and/or to specific values.
@api private
def after_value_failure
def after_value_failure "expected #{@change_details.value_representation} " \ "to have changed to #{description_of @expected_after}, " \ "but is now #{description_of @change_details.actual_after}" end
def before_value_failure
def before_value_failure "expected #{@change_details.value_representation} " \ "to have initially been #{description_of @expected_before}, " \ "but was #{@actual_before_description}" end
def description
- Private: -
def description "change #{@change_details.value_representation} #{change_description}" end
def did_change_failure
def did_change_failure "expected #{@change_details.value_representation} not to have changed, but " \ "did change from #{@actual_before_description} " \ "to #{description_of @change_details.actual_after}" end
def did_not_change_failure
def did_not_change_failure "expected #{@change_details.value_representation} " \ "to have changed #{change_description}, but did not change" end
def failure_message
- Private: -
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
def initialize(change_details, from, to)
def initialize(change_details, from, to) @change_details = change_details @expected_before = from @expected_after = to end
def matches?(event_proc)
- Private: -
def matches?(event_proc) perform_change(event_proc) && @change_details.changed? && @matches_before && matches_after? end
def matches_after?
def matches_after? values_match?(@expected_after, @change_details.actual_after) end
def not_given_a_block_failure
def not_given_a_block_failure "expected #{@change_details.value_representation} to have changed " \ "#{change_description}, but was not given a block" end
def perform_change(event_proc)
def perform_change(event_proc) @event_proc = event_proc @change_details.perform_change(event_proc) do |actual_before| # pre-compute values derived from the `before` value before the # mutation is applied, in case the specified mutation is mutation # of a single object (rather than a changing what object a method # returns). We need to cache these values before the `before` value # they are based on potentially gets mutated. @matches_before = values_match?(@expected_before, actual_before) @actual_before_description = description_of(actual_before) end end
def supports_block_expectations?
- Private: -
def supports_block_expectations? true end
def supports_value_expectations?
- Private: -
def supports_value_expectations? false end