class RSpec::Matchers::BuiltIn::ChangeRelatively
Used to specify a relative change. @api private
Public Class Methods
new(change_details, expected_delta, relativity, &comparer)
click to toggle source
# 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
Public Instance Methods
description()
click to toggle source
@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
does_not_match?(_event_proc)
click to toggle source
@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
failure_message()
click to toggle source
@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
matches?(event_proc)
click to toggle source
@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
supports_block_expectations?()
click to toggle source
@private
# File lib/rspec/matchers/built_in/change.rb, line 144 def supports_block_expectations? true end
Private Instance Methods
failure_reason()
click to toggle source
# 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