【问题标题】:Inflections seem to not get loaded in test environment of a rails app在 Rails 应用程序的测试环境中似乎没有加载拐点
【发布时间】:2009-09-07 09:54:58
【问题描述】:

我有一个名为 Agelia 的模型(它是分类广告的希腊语),并在 RAILS_ROOT/config/initializers/inflections.rb 中设置了一个变形,如下所示: p>

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'aggelia', 'aggelies'
end

它在开发环境中运行良好,但是当我尝试运行测试(现在只断言真相)时,每个测试错误:

test_the_truth(UserTest):
ActiveRecord::StatementInvalid: Mysql::Error: Table 'market_redux_test.aggelias' doesn't exist: DELETE FROM `aggelias`

似乎 rails 在运行测试时不会加载变形(或至少没有及时加载)。

我在 rails 2.3.3

上使用 ruby 1.8.7

任何想法为什么会发生这种情况?

【问题讨论】:

    标签: ruby-on-rails unit-testing inflection


    【解决方案1】:

    发现错误。

    实际上,测试环境可以很好地加载变形,问题是一个被遗忘的 aggelias.yml,它是由 script/generate model 创建的(可能在我编写变形规则)并触发对 aggelias 表的搜索。

    relevant lighthouse ticket

    【讨论】:

      猜你喜欢
      • 2013-09-07
      • 1970-01-01
      • 1970-01-01
      • 2020-01-22
      • 1970-01-01
      • 2014-11-11
      • 2017-08-07
      • 2014-12-25
      • 1970-01-01
      相关资源
      最近更新 更多