I am trying to test a rake task with rspec, and for that purpose I need to invoke it twice but it is only being invoked once.
it 'first test' do
Rake::Task['my_rake_task'].invoke
# rake task was processed
end
it 'second test' do
Rake::Task['my_rake_task'].invoke
# rake task was NOT processed
end
if a rake task has already been invoked once it won't run again unless you call:
@rake[@task_name].reenable
or invoke it with
@rake[@task_name].execute
To adding to Guy Segev answer I prefer adding this to your spec file
after(:each) do
Rake::Task["task:name"].reenable
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