【发布时间】:2013-04-27 04:43:51
【问题描述】:
我正在使用 ActiveSupport::TimeZone 根据邮政编码设置时区。
def set_time_zone
self.time_zone = ActiveSupport::TimeZone.find_by_zipcode(self.zip)
end
这在应用程序本身中运行良好。我在 before_save 上调用 set_time_zone。
在使用 Rspec 运行测试时,当它尝试运行 set_time_zone 方法时,它会出错并显示“undefined method 'find_by_zipcode'in ActiveSupport::TimeZone”
我也在我的规范助手中包含了“require 'active_support/time_with_zone'”。
目前我的工作是在测试环境中排除之前的保存。
任何想法都会很棒。
【问题讨论】:
标签: ruby rspec timezone activesupport zipcode