class Sidekiq::Testing
Attributes
Public Class Methods
Source
# File lib/sidekiq/testing.rb, line 36 def __local_test_mode Thread.current[:__sidekiq_test_mode] end
Source
# File lib/sidekiq/testing.rb, line 40 def __local_test_mode=(value) Thread.current[:__sidekiq_test_mode] = value end
Source
# File lib/sidekiq/testing.rb, line 14 def __set_test_mode(mode) if block_given? # Reentrant testing modes will lead to a rat's nest of code which is # hard to reason about. You can set the testing mode once globally and # you can override that global setting once per-thread. raise TestModeAlreadySetError, "Nesting test modes is not supported" if __local_test_mode self.__local_test_mode = mode begin yield ensure self.__local_test_mode = nil end else self.__global_test_mode = mode end end
Calling without a block sets the global test mode, affecting all threads. Calling with a block only affects the current Thread.
Source
# File lib/sidekiq/testing.rb, line 32 def __test_mode __local_test_mode || __global_test_mode end
Source
# File lib/sidekiq/testing.rb, line 44 def disable!(&block) __set_test_mode(:disable, &block) end
Source
# File lib/sidekiq/testing.rb, line 60 def disabled? __test_mode == :disable end
Source
# File lib/sidekiq/testing.rb, line 48 def fake!(&block) __set_test_mode(:fake, &block) end
Source
# File lib/sidekiq/testing.rb, line 52 def inline!(&block) __set_test_mode(:inline, &block) end
Source
# File lib/sidekiq/testing.rb, line 72 def server_middleware @server_chain ||= Middleware::Chain.new(Sidekiq.default_configuration) yield @server_chain if block_given? @server_chain end