Skip to content

Commit

Permalink
mock Time#new same as Time#now since they're synonyms
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Jeffery committed Jul 27, 2012
1 parent 8e2ab89 commit 13e01d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/timecop/time_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def now_with_mock_time

# Alias now to now_with_mock_time
alias_method :now, :now_with_mock_time
alias_method :new, :now
end
end

Expand Down Expand Up @@ -69,4 +70,4 @@ def now_with_mock_time
alias_method :now, :now_with_mock_time
end
end
end
end
7 changes: 7 additions & 0 deletions test/timecop_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,11 @@ def test_return_eliminates_baseline
Timecop.return_to_baseline
assert times_effectively_equal(time_before_travel, Time.now)
end

def test_mock_time_new_same_as_now
date = Time.local(2011, 01, 02)
Timecop.freeze date
assert_equal date, Time.now
assert_equal date, Time.new
end
end

0 comments on commit 13e01d8

Please sign in to comment.