【发布时间】:2015-06-02 18:44:49
【问题描述】:
在控制器方法中,当向该用户发送激活电子邮件时,我将用户变量 activation_sent_at 设置为等于 Time.zone.now。在开发服务器上,这似乎有效(尽管我的应用程序中的时间表达式比我的计算机本地时间晚了 2 小时)。
我想包含一个集成测试来测试activation_sent_at 是否确实设置正确。所以我加入了这一行:
assert_equal @user.activation_sent_at, Time.zone.now
但是,这会产生错误:
No visible difference in the ActiveSupport::TimeWithZone#inspect output.
You should look at the implementation of #== on ActiveSupport::TimeWithZone or its members.
我认为建议在我的测试中为Time.zone.now 使用另一个表达式。我查看了不同的来源,包括http://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html,但不确定在这里做什么。有什么建议可能导致此错误?
其他信息:添加puts Time.zone.now 和puts @stakeholder.activation_sent_at 确认两者相等。不确定是什么导致了失败/错误。
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 integration-testing