2017-02-21 45 views
0

我有一個名稱空間模型,即Billing::Plan。所以我把它的燈具放在test/fixtures/test/billing/plan.yml之下。 (其實,這是軌道發生器把它放在那裏,所以我認爲這是一個約定優於配置愉快:-))Rails minitest命名空間裝置

現在,當我運行一個測試它的工作原理,但是當我嘗試運行我所有的測試套件rake testguard夾具加載失敗,此錯誤

ActiveRecord::StatementInvalid: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "plans" does not exist 

的重要組成部分,是

ERROR: relation "plans" does not exist 

這似乎是fixtures :all命令我n我的test_helper.rb文件無法理解關係名稱是billing_plans而不是plans

這是爲什麼?

回答

0

我想通過看什麼fixtures :alldoes

它需要調用set_fixture_class才能正確地將表名分配給命名空間的燈具。

所以,我解決我的問題將...

# test/test_helper.rb 

module ActiveSupport 
    class TestCase 
    fixtures :all 
    set_fixture_class 'billing/plan' => Billing::Plan # <= ...this line! 
end 
end