How to deal with RSpec time precision error
09 Jul 12:35

In some cases, Ruby uses higher precision to represent time than the DB. When we compare a timestamp before and after saving to the DB it might not be equal.

The easiest solution is to use be_within().of matcher.

time =

model = SomeModel.create(started_at: time)

expect(model.started_at).to be_within(0.001.seconds).of(time)


Empty! You must sign in to add comments.