Sha256: 41d6250ac086121ffe45094d348f4a278f78c41c41ade38119802d374f5df73f

Contents?: true

Size: 1.45 KB

Versions: 47

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

begin
  require 'rollbar/delay/sidekiq'
  require 'sidekiq/testing'
rescue LoadError
  module Rollbar
    module Delay
      class Sidekiq
      end
    end
  end
end

describe Rollbar::Delay::Sidekiq, :if => RUBY_VERSION != '1.8.7' do
  let(:payload) { anything }

  describe "#perform" do
    it "performs payload" do
      Rollbar.should_receive(:process_from_async_handler).with(payload)
      subject.perform payload
    end
  end

  describe "#call" do
    shared_examples "a Rollbar processor" do

      it "processes payload" do
        Rollbar.should_receive(:process_from_async_handler).with(payload)

        subject.call payload
        described_class.drain
      end
    end

    context "with default options" do
      it "enqueues to default queue" do
        options = Rollbar::Delay::Sidekiq::OPTIONS.merge('args' => payload)
        ::Sidekiq::Client.should_receive(:push).with options

        subject.call payload
      end

      it_behaves_like "a Rollbar processor"
    end

    context "with custom options" do
      let(:custom_config) { { 'queue' => 'custom_queue' } }
      subject { Rollbar::Delay::Sidekiq.new custom_config }

      it "enqueues to custom queue" do
        options = Rollbar::Delay::Sidekiq::OPTIONS.merge(custom_config.merge('args' => payload))
        ::Sidekiq::Client.should_receive(:push).with options

        subject.call payload
      end

      it_behaves_like "a Rollbar processor"
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
rollbar-2.18.2 spec/delay/sidekiq_spec.rb
rollbar-2.18.0 spec/delay/sidekiq_spec.rb
rollbar-2.17.0 spec/delay/sidekiq_spec.rb
rollbar-2.16.4 spec/delay/sidekiq_spec.rb
rollbar-2.16.3 spec/delay/sidekiq_spec.rb
rollbar-2.16.2 spec/delay/sidekiq_spec.rb
rollbar-2.16.0 spec/delay/sidekiq_spec.rb
rollbar-2.15.6 spec/delay/sidekiq_spec.rb
rollbar-2.15.5 spec/delay/sidekiq_spec.rb
rollbar-2.15.4 spec/delay/sidekiq_spec.rb
rollbar-2.15.3 spec/delay/sidekiq_spec.rb
rollbar-2.15.2 spec/delay/sidekiq_spec.rb
rollbar-2.15.1 spec/delay/sidekiq_spec.rb
rollbar-2.15.0 spec/delay/sidekiq_spec.rb
rollbar-2.14.1 spec/delay/sidekiq_spec.rb
rollbar-2.14.0 spec/delay/sidekiq_spec.rb
rollbar-2.13.3 spec/delay/sidekiq_spec.rb
rollbar-2.13.2 spec/delay/sidekiq_spec.rb
rollbar-2.13.1 spec/delay/sidekiq_spec.rb
rollbar-2.13.0 spec/delay/sidekiq_spec.rb