Comparison between two ActiveSupport::TimeWithZone objects fails

时光怂恿深爱的人放手 提交于 2019-12-06 14:22:31

Answer #1 rake db:test:prepare

First, attempt dropping the test database and recreating it, and then running rake db:test:prepare. This has resolved this issue for me in the past I know this is a bit of a lame answer, but it is worth a shot.

Answer #2 Spring + Rspec + Shoulda matchers

If having this issue after installing Spring, please checkout this Github Thread, which can cause tests to fail: https://github.com/rails/spring/issues/209

This issue only started occurring for me after adding Spring to my project. Adding gem 'shoulda', require: false and manually adding require 'shoulda/matchers' to my spec_helper.rb resolved the issues

Answer #3 Timecop

If still having issues, checkout the Timecop gem and freeze time around date comparisons. https://github.com/travisjeffery/timecop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!