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

1 回答 1

1

您应该声明cucumber任务依赖于cuke_test_db_constraints而不是强制调用任务。

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
于 2013-03-06T14:27:18.513 回答