Ruby on rails 用Watir测试Rails。如何使用/test/fixtures中的fixtures加载测试数据库
我正在尝试使用Watir测试装置测试我的Rails应用程序。watir测试工作正常,但我似乎无法使用/test/fixtures中的fixtures加载测试数据库Ruby on rails 用Watir测试Rails。如何使用/test/fixtures中的fixtures加载测试数据库,ruby-on-rails,watir,fixtures,Ruby On Rails,Watir,Fixtures,我正在尝试使用Watir测试装置测试我的Rails应用程序。watir测试工作正常,但我似乎无法使用/test/fixtures中的fixtures加载测试数据库 我尝试将rake任务与RAILS_ENV=test一起使用,但只设法从/db/fixtures/加载fixtures,并找到了使用rake任务的方法 namespace :watir do desc "Initiate the db for watir tests" task :db_reset do if (ENV
我尝试将rake任务与RAILS_ENV=test一起使用,但只设法从/db/fixtures/加载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_重置
现在我可以在测试夹具上运行watir测试了如果您找到了这样做的方法,您还需要帮助吗?如果不是,你可能想把你的发现写进“答案”中,或者干脆删除这个问题,而不是把它留在这里,看起来没有答案,然后接受你的答案。其中x,y,z是测试/装置中装置的名称/*