@api private Used to specify a change from a specific value (and, optionally, to a specific value).
# File lib/rspec/matchers/built_in/change.rb, line 237 def initialize(change_details, expected_before) @description_suffix = nil super(change_details, expected_before, MATCH_ANYTHING) end
@private
# File lib/rspec/matchers/built_in/change.rb, line 251 def does_not_match?(event_proc) if @description_suffix raise NotImplementedError, "`expect { }.not_to change { }.to()` " "is not supported" end @event_proc = event_proc return false unless Proc === event_proc @change_details.perform_change(event_proc) !@change_details.changed? && matches_before? end
@private
# File lib/rspec/matchers/built_in/change.rb, line 264 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
@api public Specifies the new value you expect.
# File lib/rspec/matchers/built_in/change.rb, line 244 def to(value) @expected_after = value @description_suffix = " to #{description_of value}" self end
# File lib/rspec/matchers/built_in/change.rb, line 272 def change_description "from #{description_of @expected_before}#{@description_suffix}" end