Comparing DateTimes Down To Second Precision
You may have an RSpec test for your Rails codebase that asserts about the datetime a record gets saved with:
This comparison happens with precision down to the nanosecond. Unfortunately, depending on your operating system and backing database, you may see inconsistent results due to variations in precision.
One way to deal with this, if you only care about precision down to the second, is to modify the expecationa little with the be_within
matcher.
The be_within
matcher can also be used as a nested matcher.
Last updated