I have a simple rake task with puts
in it
namespace :atask
task something: :environment do
puts 'Foo'
end
end
My specification is as follows
describe 'atask:something' do
before { MyApp.Application.load_tasks }
context 'one' do
it do
Rake::Task['atask:something'].invoke
end
end
context 'two' do
it do
Rake::Task['atask:something'].invoke
end
end
context 'three' do
it do
Rake::Task['atask:something'].invoke
end
end
end
As you can see, it has 3 contexts and 3 blocks. Therefore, I should see "Foo" in the console three times, once for each task call. However, I only see “Foo” once in the console, although it is called three times.
source
share