-
-
Notifications
You must be signed in to change notification settings - Fork 280
Testing
tehpeh edited this page Nov 18, 2014
·
10 revisions
require 'spec_helper'
describe MyWorker do
let(:sqs_msg) { double AWS::SQS::ReceivedMessage,
id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e',
body: 'test',
delete: nil }
let(:body) { 'test' }
describe '#perform' do
subject { MyWorker.new }
it 'prints the body message' do
expect { subject.perform(sqs_msg, body) }.to output('test').to_stdout
end
it 'deletes the message' do
expect(sqs_msg).to receive(:delete)
subject.perform(sqs_msg, body)
end
it 'pushes a new message' do
sqs_queue = double 'other queue'
allow(Shoryuken::Client).to receive(:queues).
with('other_queue').and_return(sqs_queue)
expect(sqs_queue).to receive(:send_message).
with('new test')
subject.perform(sqs_msg, body)
end
end
end