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 129
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 156
def description
  "change #{@change_details.value_representation} " \
  "#{@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 150
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 137
def failure_message
  "expected #{@change_details.value_representation} 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 144
def matches?(event_proc)
  @event_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 162
def supports_block_expectations?
  true
end
supports_value_expectations?() click to toggle source

@private

# File lib/rspec/matchers/built_in/change.rb, line 167
def supports_value_expectations?
  false
end

Private Instance Methods

failure_reason() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 173
def failure_reason
  return "was not given a block" unless Proc === @event_proc
  "was changed by #{description_of @change_details.actual_delta}"
end