travisjeffery/timecop — pull request #96 by neerfri (2013-07-07 14:26:29+00:00)
Title: Fix Time.now precision with ActiveSupport 4

ActiveSupport 4 adds the following code to `Time` class:

```
# Layers additional behavior on Time.at so that ActiveSupport::TimeWithZone and DateTime
# instances can be used when called with a single argument
def at_with_coercion(*args)
if args.size == 1 && args.first.acts_like?(:time)
at_without_coercion(args.first.to_i)
else
at_without_coercion(*args)
end
end
alias_method :at_without_coercion, :at
alias_method :at, :at_with_coercion
```

This makes `Time.now` lose millisecond percision (notice the call to `#to_i`).
With this issue it's problematic to use Timecop with Capybara since it is checking to detect time freezing using a small sleep. this makes the small sleep (while in travel) look like a time freeze.

Should probably also be fixed in ActiveSupport. I'm working on a pull request for that as well. but figured you might want to pull this in in order to make Timecop work now with Rails 4 + Capybara