samedi 31 janvier 2015

Seeding before Rails feature test

I have a number of feature tests which rely on a fair amount of data being in the database. I have put this data in a seed file and am trying to call it in the before block in my tests



feature 'capybara tests' do
self.use_transactional_fixtures = false

before do
DatabaseCleaner.strategy =:truncation
DatabaseCleaner.clean
MyApp::Application.load_tasks
Rake::Task['db:seed:capybara'].invoke
end

scenario 'one' do
end

scenario 'two' do
end
end


The above doesn't work. Scenario two has an empty database. The before block is being called just before running scenario two, but the seed rake task is silently not executing so I'm left with an empty database.


Can someone tell me why this is happening and how to fix it? Thanks


Aucun commentaire:

Enregistrer un commentaire