Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber scenarios don't run when is task invoked in a lib/tasks task

I have the following task in lib/tasks:

    task :cuke_test_db_constraints do
      puts 'cuke_test_db_constraints'
      ENV['TEST_DB_CONSTRAINTS'] = '1'
      Rake::Task['cucumber'].reenable
      Rake::Task['cucumber'].invoke
    end

    task :default => :cuke_test_db_constraints

As you see, I want to run cucumber again after setting an env variable. However, while cuke_test_db_constraints task runs, cucumber doesn't run scenarios. The cucumber task itself runs, I checked it with adding debug output under :cucumber task in lib/tasks/cucumber.rake.

Any ideas? Thanks.

like image 689
ledestin Avatar asked Nov 21 '12 15:11

ledestin


1 Answers

You should declare that the cucumber task depends on cuke_test_db_constraints instead of imperatively invoking the task.

task :cuke_test_db_constraints do
  puts 'cuke_test_db_constraints'
  ENV['TEST_DB_CONSTRAINTS'] = '1'
end

task :default => :cucumber
task :cucumber => :cuke_test_db_constraints
like image 110
Arnaud Meuret Avatar answered Oct 14 '22 13:10

Arnaud Meuret