class RSpec::Matchers::BuiltIn::ChangeRelatively

Used to specify a relative change. @api private

Public Class Methods

# File rspec-expectations/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

@private

# File rspec-expectations/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

@private

# File rspec-expectations/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

@private

# File rspec-expectations/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

@private

# File rspec-expectations/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

@private

# File rspec-expectations/lib/rspec/matchers/built_in/change.rb, line 162
def supports_block_expectations?
  true
end

@private

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