Sha256: 1945db8b72d04964a720f91d572711ece25c88a0bc1d509eb915fdf36979a96d

Contents?: true

Size: 751 Bytes

Versions: 2

Compression:

Stored size: 751 Bytes

Contents

RSpec.shared_context "worker class", worker_class: true do
  let(:worker_options) { { key: -> (args) { "key" } } }
  let(:worker_class) do
    local_options = worker_options
    Class.new do
      include Sidekiq::Worker

      sidekiq_options merger: local_options

      def self.name
        "SomeWorker"
      end

      def self.to_s
        "SomeWorker"
      end

      def perform(*args)
      end
    end
  end
  before :example do
    allow(Object).to receive(:const_get).with(anything).and_call_original
    allow(Object).to receive(:const_get).with("SomeWorker").and_return worker_class
  end
  around :example do |example|
    worker_class.jobs.clear
    begin
      example.run
    ensure
      worker_class.jobs.clear
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-merger-0.0.11 spec/support/worker_class.rb
sidekiq-merger-0.0.10 spec/support/worker_class.rb