Why after_commit not running even with use_transactional_fixtures = false

后端 未结 5 2367
悲哀的现实
悲哀的现实 2021-02-19 03:03

Transactional fixtures in rspec prevent after_commit from being called, but even when I disable them with

RSpec.configure do |config|
  config.use_transactional_         


        
5条回答
  •  长发绾君心
    2021-02-19 03:55

    One way around this is to trigger the commit callbacks manually. Example:

    describe SomeModel do
      subject { ... }
    
      context 'after_commit' do
        after { subject.run_callbacks(:commit) }
    
        it 'does something' do
          subject.should_receive(:some_message)
        end
      end
    end
    

    A little late, but hope this helps others.

提交回复
热议问题