![](/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.