class RSpec::Matchers::BuiltIn::ChangeDetails

@private Encapsulates the details of the before/after values.

Attributes

actual_after[R]
actual_before[R]
message[R]

Public Class Methods

new(receiver=nil, message=nil, &block) click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 300
def initialize(receiver=nil, message=nil, &block)
  @message    = message ? "##{message}" : "result"
  @value_proc = block || lambda { receiver.__send__(message) }
end

Public Instance Methods

actual_delta() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 315
def actual_delta
  @actual_after - @actual_before
end
changed?() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 311
def changed?
  @actual_before != @actual_after
end
perform_change(event_proc) click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 305
def perform_change(event_proc)
  @actual_before = evaluate_value_proc
  event_proc.call
  @actual_after = evaluate_value_proc
end

Private Instance Methods

evaluate_value_proc() click to toggle source
# File lib/rspec/matchers/built_in/change.rb, line 321
def evaluate_value_proc
  case val = @value_proc.call
  when IO # enumerable, but we don't want to dup it.
    val
  when Enumerable, String
    val.dup
  else
    val
  end
end