I see that it is possible to pass arguments to a rake task:
task :task_name, :arg_name do |t, args|
What I'd like to do is pass arguments into a cucumber rake task:
Cucumber::Rake::Task.new({:tags => 'db:test:prepare'}) do |t, args|
t.cucumber_opts = ['--tags', #args?]
end
Is this sort of thing possible? This way I could do:
rake cucumber:tags['tag1', 'tag2', ...]
And have it run only those tags. Most sources say to use an environment variable, which I have done, but I'd prefer to just provide the arguments the "right" way.
Go to Websites & Domains and click Ruby. After gems installation you can try to run a Rake task by clicking Run rake task. In the opened dialog, you can provide some parameters and click OK - this will be equivalent to running the rake utility with the specified parameters in the command line.
Rake is a popular task runner for Ruby and Rails applications. For example, Rails provides the predefined Rake tasks for creating databases, running migrations, and performing tests. You can also create custom tasks to automate specific actions - run code analysis tools, backup databases, and so on.
A Task is the basic unit of work in a Rakefile. Tasks have associated actions (possibly more than one) and a list of prerequisites.
You can get it to work by doing something like this:
task :task_name, :arg1 do |t, args|
Cucumber::Rake::Task.new(:run) do |t|
t.cucumber_opts = "--format pretty --tags @#{args[:arg1]}"
end
Rake::Task[:run].invoke()
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With