Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add task dependencies to Rake::TestTask

How can I declare task dependencies to a TestTask ?

In this example, 'clean_database' task should be run before integration task

Rake::TestTask.new(:integration) do |t|
 t.libs << "test"
 t.test_files = FileList['test/**/integration/**/test*.rb']
 t.verbose = true
end

task :clean_database => [:init] do
 #...
end
like image 262
Benoît Guérout Avatar asked Dec 16 '11 17:12

Benoît Guérout


2 Answers

Rake enables redefining existing tasks, so this should be possible (add it to your existing code):

task :integration => :clean_database
like image 108
Marek Příhoda Avatar answered Oct 04 '22 05:10

Marek Příhoda


You can pass in the dependency to the TestTask initializer:

Rake::TestTask.new(:integration => :clean_database) do |t|
 t.libs << "test"
 t.test_files = FileList['test/**/integration/**/test*.rb']
 t.verbose = true
end
like image 29
effkay Avatar answered Oct 04 '22 05:10

effkay