Skip to content

Commit

Permalink
Bugfix: time_travel_to now works fine with DateTime
Browse files Browse the repository at this point in the history
Fixes: bebanjo#5
  • Loading branch information
porras committed Jun 3, 2011
1 parent 2a767c8 commit 3164e41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/delorean.rb
Expand Up @@ -38,7 +38,7 @@ def reset

def mock_current_time(time, options={})
time = Chronic.parse(time, options) if time.is_a?(String)
time = Time.local(time.year, time.month, time.day) if time.is_a?(Date)
time = Time.local(time.year, time.month, time.day) if time.is_a?(Date) && !time.is_a?(DateTime)

time_travel_offsets.push Time.now - time
end
Expand Down
7 changes: 7 additions & 0 deletions spec/delorean_spec.rb
Expand Up @@ -41,6 +41,13 @@
'Back in good old 1955.'
end.should eql 'Back in good old 1955.'
end

it "should work with DateTime" do
datetime = DateTime.strptime("2011-05-25 18:00", "%Y-%m-%d %H:%M")
Delorean.time_travel_to(datetime) do
Time.now.should be_close(datetime, 1)
end
end
end

describe "back_to_the_present" do
Expand Down

0 comments on commit 3164e41

Please sign in to comment.