Sha256: 21ee3459069e80c3ddf6a1e95a764e35420e063ac6d0801b451b7507070cd2db
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require 'active_job' require 'spec_helper' ActiveJob::Base.queue_adapter = :test ActiveJob::Base.logger = ::Logger.new(nil) RSpec.describe 'ActiveJob routines' do context 'default configuration' do before do Lev.configure { |c| c.active_job_class = ActiveJob::Base } # default end class LaterRoutine lev_routine active_job_queue: :something_else protected def exec; end end it 'can perform routines later' do expect { LaterRoutine.perform_later }.to change { ActiveJob::Base.queue_adapter.enqueued_jobs.count }.by(1) end it 'can have the default queue overridden' do LaterRoutine.perform_later queue_name = ActiveJob::Base.queue_adapter.enqueued_jobs.first[:queue] expect(queue_name).to eq('something_else') end end context 'specialized configuration' do before do Lev.configure { |c| c.active_job_class = SomeOtherJobBase } end class SomeOtherJobBase def self.queue_as(*args); end def self.perform_later; end end class NewLaterRoutine lev_routine protected def exec; end end it 'allows configuration of the class' do allow(SomeOtherJobBase).to receive(:perform_later) expect(Lev.configuration.active_job_class).to eq(SomeOtherJobBase) NewLaterRoutine.perform_later expect(SomeOtherJobBase).to have_received(:perform_later) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lev-4.3.0 | spec/active_job_routines_spec.rb |