Revisions
-
rahsheen created this gist
Nov 30, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ require 'rails_helper' RSpec.describe MyWorker, type: :job do include ActiveJob::TestHelper let(:sqs_msg) { double AWS::SQS::ReceivedMessage, id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e', body: 'test', delete: nil } describe '#perform' do subject(:job) { described_class.new } it 'sends the message' do # Setup successful response response = Net::HTTPSuccess.new(1.0, '200', 'OK') # Setup Net::HTTP to receive the response expect_any_instance_of(Net::HTTP).to receive(:request) { response } # Setup response to receive follow messages below. # This prevents the elusive "undefined method `close' for nil:NilClass" error. expect(response).to receive(:body) { '{"data": "that you want to return"}' } job.perform(sqs_msg) end end end