spec/spec_helper.rb
def with_empty_middleware
  # Save the middleware context
  server_middleware = Sidekiq.server_middleware.entries.map(&:klass)
  client_middleware = Sidekiq.client_middleware.entries.map(&:klass)
  Sidekiq.server_middleware.clear
  Sidekiq.client_middleware.clear

  yield

  # Clear anything added and restore all previously registered middleware
  Sidekiq.server_middleware.clear
  Sidekiq.client_middleware.clear
  server_middleware.each { |m| Sidekiq.server_middleware.add(m) }
  client_middleware.each { |m| Sidekiq.client_middleware.add(m) }
end
# Reset all middleware for nested context and then restore.
#
# @note Middleware args are not preserved
Reset all middleware for nested context and then restore.
Reset all middleware for nested context and then restore .
def with_empty_middleware
  server_middleware = Sidekiq.server_middleware.entries.map(&:klass)
  client_middleware = Sidekiq.client_middleware.entries.map(&:klass)
  Sidekiq.server_middleware.clear
  Sidekiq.client_middleware.clear
  yield
  Sidekiq.server_middleware.clear
  Sidekiq.client_middleware.clear
  server_middleware.each { |m| Sidekiq.server_middleware.add(m) }
  client_middleware.each { |m| Sidekiq.client_middleware.add(m) }
end
def with_empty_middleware server_middleware = Sidekiq . server_middleware . entries . map ( & :klass ) client_middleware = Sidekiq . client_middleware . entries . map ( & :klass ) Sidekiq . server_middleware . clear Sidekiq . client_middleware . clear yield Sidekiq . server_middleware . clear Sidekiq . client_middleware . clear server_middleware . each { | m | Sidekiq . server_middleware . add ( m ) } client_middleware . each { | m | Sidekiq . client_middleware . add ( m ) } end
Reset all middleware for nested context and then restore.
Reset all middleware for nested context and then restore .
# Save the middleware context # Clear anything added and restore all previously registered middleware
note
Middleware args are not preserved
Middleware args are not preserved