Rspec checks

I have a simple rake task with putsin 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.

+4
source share
1 answer

It turns out that when the rake task was invoked, it will not start again. You must either complete the reenabletask after the call, or useexecute

+4
source

Source: https://habr.com/ru/post/1609797/


All Articles