开发者

Rails testing with Watir. How do I load my test db with the fixtures from /test/fixtures

开发者 https://www.devze.com 2023-03-19 03:53 出处:网络
I\'m trying to test my Rails App with test fixtures using Watir. The watir tests work but I can\'t seem to load my test db with the fixtures from /test/fixtures.

I'm trying to test my Rails App with test fixtures using Watir. The watir tests work but I can't seem to load my test db with the fixtures from /test/fixtures.

I tried using rake tasks with RAILS_ENV=test but only m开发者_JS百科anaged to load the fixtures from /db/fixtures/


Found a way to do this using rake tasks.

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

To run it I do rake watir:db_reset

Now I can run the watir tests on the test fixtures

0

精彩评论

暂无评论...
验证码 换一张
取 消