Used to specify a relative change. @api private
# File lib/rspec/matchers/built_in/change.rb, line 109 def initialize(change_details, expected_delta, relativity, &comparer) @change_details = change_details @expected_delta = expected_delta @relativity = relativity @comparer = comparer end
@private
# File lib/rspec/matchers/built_in/change.rb, line 138 def description "change #{@change_details.message} " "#{@relativity.to_s.tr('_', ' ')} #{description_of @expected_delta}" end
@private
# File lib/rspec/matchers/built_in/change.rb, line 132 def does_not_match?(_event_proc) raise NotImplementedError, "`expect { }.not_to change " "{ }.#{@relativity}()` is not supported" end
@private
# File lib/rspec/matchers/built_in/change.rb, line 117 def failure_message "expected #{@change_details.message} to have changed " "#{@relativity.to_s.tr('_', ' ')} " "#{description_of @expected_delta}, but #{failure_reason}" end
@private
# File lib/rspec/matchers/built_in/change.rb, line 124 def matches?(event_proc) @event_proc = event_proc return false unless Proc === event_proc @change_details.perform_change(event_proc) @comparer.call(@change_details.actual_delta) end
@private
# File lib/rspec/matchers/built_in/change.rb, line 144 def supports_block_expectations? true end
# File lib/rspec/matchers/built_in/change.rb, line 150 def failure_reason return "was not given a block" unless Proc === @event_proc "was changed by #{description_of @change_details.actual_delta}" end