9

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.

4
  • Oh, I forgot to add that if I run rake cuke_test_db_constraints, then it works, but if I just use rake, it doesn't.
    – ledestin
    Commented Nov 21, 2012 at 15:26
  • 1
    I've found a workaround: user cucumber:ok task name, then it works.
    – ledestin
    Commented Nov 24, 2012 at 11:46
  • 10
    You should write that below if you've answered yourself. Commented Feb 4, 2013 at 2:34
  • I think you could also add => :environment after the task name. Might not be picking up everything correctly without that guy.
    – user1976
    Commented Sep 23, 2013 at 21:47

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.