[英]Rails testing with Watir. How do I load my test db with the fixtures from /test/fixtures
我正在尝试使用 Watir 使用测试装置测试我的 Rails 应用程序。 watir 测试有效,但我似乎无法使用 /test/fixtures 中的夹具加载我的测试数据库。
我尝试使用带有 RAILS_ENV=test 的 rake 任务,但只能从 /db/fixtures/ 加载固定装置
找到了一种使用 rake 任务执行此操作的方法。
namespace :watir do
desc "Initiate the db for watir tests"
task :db_reset do
if (ENV['RAILS_ENV'] == "test")
Rake::Task["db:test:prepare"].invoke
Rake::Task["db:test:load"].invoke
Rake::Task["db:seed"].invoke
Rake::Task["db:fixtures:load"].invoke("FIXTURES=x,y,z,....") #x,y,z are the name of the fixtures in test/fixtures/*
else
puts "Must be executed with test flag ('RAILS_ENV=test')"
end
end
end
要运行它,我会rake watir:db_reset
现在我可以在测试夹具上运行 watir 测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.