Sha256: fbeb8f8317689abcca8082488966542076364df94a2f29007270124bfcec0c77
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
require 'spec_helper' class MailerSubscriber < ActionMailer::Base include Reactor::Subscribable def fire_mailer(event) mail subject: 'Here is a mailer', to: 'reactor@hired.com', from: 'test+reactor@hired.com', body: 'an example email body' end end class MyMailerWorker < Reactor::Workers::MailerWorker self.source = MailerSubscriber self.action = :fire_mailer self.async = false self.delay = 0 end class MyBlockMailerWorker < Reactor::Workers::MailerWorker self.source = MailerSubscriber self.async = false self.delay = 0 self.action = lambda { |event| fire_mailer(event) } end describe Reactor::Workers::MailerWorker do let(:klass) { MyMailerWorker } let(:event_data) { Hash[some_example: :event_data] } subject { klass.new.perform(event_data) } before do allow_any_instance_of(klass).to receive(:should_perform?).and_return(true) end it 'sends an email from symbol method name' do expect { subject }.to change { ActionMailer::Base.deliveries.count }.by(1) end context 'for a block subscription' do let(:klass) { MyBlockMailerWorker } it 'sends an email from the block' do expect { subject }.to change { ActionMailer::Base.deliveries.count }.by(1) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
reactor-0.15.1 | spec/workers/mailer_worker_spec.rb |
reactor-0.15.0 | spec/workers/mailer_worker_spec.rb |
reactor-0.14.0 | spec/workers/mailer_worker_spec.rb |