Library providing tools for writing and running RSpec tests.
Encapsulates the value of a method call or block, and captures a snapshot of the value at the time the spy is initialized.
Observing a Method
user = Person.new(name: 'Alan Bradley')
value = ValueSpy.new(user, :name)
value.initial_value #=> 'Alan Bradley'
value.current_value #=> 'Alan Bradley'
user.name = 'Ed Dillinger'
value.initial_value #=> 'Alan Bradley'
value.current_value #=> 'Ed Dillinger'
Observing a Block
value = ValueSpy.new { Person.where(virtual: false).count }
value.initial_value #=> 4
value.current_value #=> 4
Person.where(name: 'Kevin Flynn').enter_grid!
value.initial_value #=> 4
value.current_value #=> 3
#initialize(receiver, method_name) => Object
#initialize(&block) => Object
#initialize(receiver, method_name) => Object
#initialize(&block) => Object
#initial_hash => Integer (readonly)
#initial_inspect => String (readonly)
#initial_value => Object (readonly)
#changed? => Boolean
#current_value => Object
#description => String
Back to Documentation | Reference | RSpec | RSpec::SleepingKingStudios | RSpec::SleepingKingStudios::Support