Sha256: 3f95834126021adf522219e0ae7b61000e851436fe4809b0b491779a285d8e02

Contents?: true

Size: 926 Bytes

Versions: 2

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

begin
  require 'sidekiq/testing'

  RSpec.configure do |config|
    config.before(:each, :queue => lambda { |v| !!v }) do |example|
      # Clears out the jobs for tests using the fake testing
      Sidekiq::Worker.clear_all
      Sidekiq::Queues.clear_all
      Sidekiq.redis { |r| r.__send__(:instance_variable_get, :@redis).flushdb }
      Sidekiq.redis do |client|
        client.keys.each do |key|
          client.del(key)
        end
      end

      if example.metadata[:queue] == :stub
        Sidekiq::Testing.fake!
      elsif example.metadata[:queue] == :immediately_execute
        Sidekiq::Testing.inline!
      elsif example.metadata[:type] == :feature
        Sidekiq::Testing.inline!
      else
        Sidekiq::Testing.fake!
      end
    end

    config.after(:each, :queue => lambda { |v| !!v }) do |_example|
      Sidekiq::Testing.fake!
    end
  end
rescue LoadError
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspeckled-0.0.54 lib/rspeckled/plugins/sidekiq.rb
rspeckled-0.0.53 lib/rspeckled/plugins/sidekiq.rb