Sha256: 2b78ceb5e814479b9f57d5b6de6db622e9f3e413a4d3d28a3d2cd00f55faee85

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Shoryuken::Middleware::Server::Timing do
  let(:sqs_msg) { double AWS::SQS::ReceivedMessage, id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e', body: 'test' }
  let(:queue)   { 'default' }

  xit 'logs timing' do
    expect(Shoryuken.logger).to receive(:info).with(/started at/)
    expect(Shoryuken.logger).to receive(:info).with(/completed in/)

    subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) {}
  end

  context 'when exceeded the `visibility_timeout`' do
    it 'logs exceeded' do
      allow(Shoryuken::Client).to receive(:visibility_timeout).and_return(60)
      allow(subject).to receive(:elapsed).and_return(120000)

      expect(Shoryuken.logger).to receive(:info).with(/started at/)
      expect(Shoryuken.logger).to receive(:info).with(/completed in/)
      expect(Shoryuken.logger).to receive(:warn).with('exceeded the queue visibility timeout by 60000 ms')

      subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) {}
    end
  end

  context 'when exception' do
    it 'logs failed in' do
      expect(Shoryuken.logger).to receive(:info).with(/started at/)
      expect(Shoryuken.logger).to receive(:info).with(/failed in/)

      expect {
        subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise }
      }.to raise_error
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shoryuken-0.0.5 spec/shoryuken/middleware/server/timing_spec.rb
shoryuken-0.0.4 spec/shoryuken/middleware/server/timing_spec.rb
shoryuken-0.0.3 spec/shoryuken/middleware/server/timing_spec.rb