Ruby on Rails: How to run a rake task for the env.rb?
in features/support/env.rb in cucumber, i would like to have a rake task run everytime i start my tests... but not before each scenario.. just开发者_如何学编程.. once.
This is what i need to run
Rake::Task["db:test:prepare"].reenable
Rake::Task["db:test:prepare"].invoke
Assuming a standard cucumber install with the rake file cucumber.rake in app/lib/tasks.
Something like this should work
task :data_prep
Rake::Task["db:test:prepare"].reenable
Rake::Task["db:test:prepare"].invoke
end
task :all => [:data_prep,:ok,:wip]
task :default => [:data_prep,:cucumber]
All you do is define another task (:data_prep) and add a call to it for the existing cucumber tasks.
Not the cleanest of methods but I cannot remember if cucumber has a method to run on startup and not on a per scenario basis.
精彩评论