![](/img/trans.png)
[英]Rails testing with Watir. How do I load my test db with the fixtures from /test/fixtures
[英]How to load the fixtures from an Engine?
我已將我的模型提取到可安裝的引擎中,現在我希望主機應用程序(包括可安裝引擎的應用程序)使用該引擎的燈具。
class ActiveSupport::TestCase
# Add fixtures from the mounted engine "blorgh"
fixture_path = Blorgh::Engine.root.join("test", "fixtures")
fixtures :all
end
調試了解到fixture_path的設置是否正確,如/home/x/.rvm/gems/ruby-1.9.3-p286@x/bundler/gems/blorgh-07520673953b/test/fixtures/
。 這是正確的固定裝置路徑。
但是,不知何故,燈具似乎沒有加載。 數據庫仍為空。 幫助者不可用。 例如夾具contacts.yml
通常會導致輔助contacts(:harry)
。 未設置此助手,因為未加載燈具。
引擎沒有命名空間,但為了完整起見,還沒有定義blorgh_contacts(:harry)
。
我怎樣才能使用發動機的夾具?
這適合我
self.fixture_path = Rails.root.parent + "./fixtures/ads"
這對我有用,我覺得更簡潔。
self.fixture_path = Blorgh::Engine.root.join("test", "fixtures")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.