Used to specify a relative change. @api private
# File lib/rspec/matchers/built_in/change.rb, line 110 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 136 def description "change #{@change_details.message} #{@relativity.to_s.gsub("_", " ")} #{description_of @expected_delta}" end
@private
# File lib/rspec/matchers/built_in/change.rb, line 131 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 118 def failure_message "expected #{@change_details.message} to have changed #{@relativity.to_s.gsub("_", " ")} #{description_of @expected_delta}, but #{failure_reason}" end
@private
# File lib/rspec/matchers/built_in/change.rb, line 123 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 141 def supports_block_expectations? true end
# File lib/rspec/matchers/built_in/change.rb, line 147 def failure_reason return "was not given a block" unless Proc === @event_proc "was changed by #{description_of @change_details.actual_delta}" end