spec/alephant/publisher/queue/revalidate_processor_spec.rb in alephant-publisher-queue-2.5.0 vs spec/alephant/publisher/queue/revalidate_processor_spec.rb in alephant-publisher-queue-2.6.0
- old
+ new
@@ -30,11 +30,12 @@
let(:writer_double) { instance_double(Alephant::Publisher::Queue::RevalidateWriter, run!: nil) }
let(:cache_double) { instance_double(Dalli::Client, delete: nil) }
let(:elasticache_double) { instance_double(Dalli::ElastiCache, client: cache_double) }
- let(:message) { instance_double(AWS::SQS::ReceivedMessage, body: JSON.generate(message_body), delete: nil) }
+ let(:message) { instance_double(Aws::SQS::Message, body: JSON.generate(message_body), delete: nil) }
+ let(:message_collection) { [message] }
let(:message_body) { { id: '', batch_id: '', options: {} } }
before do
allow(Alephant::Publisher::Queue::RevalidateWriter)
.to receive(:new)
@@ -62,41 +63,41 @@
.with(opts.writer, anything)
.and_return(writer_double)
expect(writer_double).to receive(:run!)
- subject.consume(message)
+ subject.consume(message_collection)
end
it 'passes the response to the http_response_processor' do
expect(http_response_processor)
.to receive(:process)
.with(message_body, resp_status, resp_body)
.and_call_original
- subject.consume(message)
+ subject.consume(message_collection)
end
it "calls the 'ttl' method on the http_response_processor" do
expect(http_response_processor)
.to receive(:ttl)
.with(message_body)
.and_call_original
- subject.consume(message)
+ subject.consume(message_collection)
end
it 'deletes the message from the queue' do
expect(message).to receive(:delete)
- subject.consume(message)
+ subject.consume(message_collection)
end
it "removes the 'inflight' cache message" do
expect(cache_double).to receive(:delete)
- subject.consume(message)
+ subject.consume(message_collection)
end
end
context 'when the HTTP request is unsuccessful' do
before do
@@ -104,37 +105,37 @@
end
it 'does not call #run! on the writer' do
expect(writer_double).to_not receive(:run!)
- expect { subject.consume(message) }
+ expect { subject.consume(message_collection) }
.to raise_error(Faraday::TimeoutError)
end
it 'does NOT delele the message from the queue' do
expect(message).to_not receive(:delete)
- expect { subject.consume(message) }
+ expect { subject.consume(message_collection) }
.to raise_error(Faraday::TimeoutError)
end
it "does not remove the 'inflight' cache message" do
expect(cache_double).to_not receive(:delete)
- expect { subject.consume(message) }
+ expect { subject.consume(message_collection) }
.to raise_error(Faraday::TimeoutError)
end
end
end
context 'when there is no message passed through' do
- let(:message) { nil }
+ let(:message_collection) { [] }
it 'does nothing' do
expect(writer_double).to_not receive(:run!)
expect(cache_double).to_not receive(:delete)
- subject.consume(message)
+ subject.consume(message_collection)
end
end
end
end