Class: Timecop::Rspec::TimeMachine
- Inherits:
-
Object
- Object
- Timecop::Rspec::TimeMachine
- Defined in:
- lib/timecop/rspec/time_machine.rb
Overview
Executes an example using Timecop for a single, isolated time operation.
Class Method Summary collapse
-
.instance ⇒ Timecop::Rspec::TimeMachine
Singleton instance accessor.
Instance Method Summary collapse
-
#run(example) ⇒ Object
Run an RSpec example, applying local timecop metadata if present.
Class Method Details
.instance ⇒ Timecop::Rspec::TimeMachine
Singleton instance accessor.
11 12 13 |
# File 'lib/timecop/rspec/time_machine.rb', line 11 def self.instance @instance ||= new end |
Instance Method Details
#run(example) ⇒ Object
Run an RSpec example, applying local timecop metadata if present.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/timecop/rspec/time_machine.rb', line 20 def run(example) example = ExampleDecorator.new(example) return example.run unless example.timecop? method = example.timecop_method time = example.timecop_time Timecop.public_send(method, time) do example.run end end |