Created
June 10, 2013 13:49
Revisions
-
natritmeyer created this gist
Jun 10, 2013 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ # Example Rakefile that demonstrates how to add task dependencies # to custom rake tasks that don't allow for the normal rake task # behaviour around setting task dependencies. require 'cucumber/rake/task' # here's the task that I want to run before any of my cucumber tasks (see below) namespace :stub do desc "Start stub required by features" task :start do puts "Starting stub" # `command to start stub` end end namespace :cuke do Cucumber::Rake::Task.new(:all, "Run all the features") do |t| t.libs << 'lib' end Cucumber::Rake::Task.new(:wip, "Run only wip features") do |t| t.libs << 'lib' end #here's the magic: # 1) select all tasks that begin with the "cuke:" namespace tasks_in_cuke_namespace = Rake.application.tasks.select {|task| task.name.start_with? "cuke:"} # 2) call #enhance on each of those tasks, passing an array of task dependencies tasks_in_cuke_namespace.each do |task| task.enhance ["stub:start"] end end