Class: Sidekiq::Testing
- Inherits:
-
Object
show all
- Defined in:
- lib/sidekiq/testing.rb
Defined Under Namespace
Classes: TestModeAlreadySetError
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.__global_test_mode ⇒ Object
Returns the value of attribute __global_test_mode.
10
11
12
|
# File 'lib/sidekiq/testing.rb', line 10
def __global_test_mode
@__global_test_mode
end
|
Class Method Details
.__local_test_mode ⇒ Object
36
37
38
|
# File 'lib/sidekiq/testing.rb', line 36
def __local_test_mode
Thread.current[:__sidekiq_test_mode]
end
|
.__local_test_mode=(value) ⇒ Object
40
41
42
|
# File 'lib/sidekiq/testing.rb', line 40
def __local_test_mode=(value)
Thread.current[:__sidekiq_test_mode] = value
end
|
.__set_test_mode(mode) ⇒ Object
Calling without a block sets the global test mode, affecting all threads. Calling with a block only affects the current Thread.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/sidekiq/testing.rb', line 14
def __set_test_mode(mode)
if block_given?
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
|
.__test_mode ⇒ Object
32
33
34
|
# File 'lib/sidekiq/testing.rb', line 32
def __test_mode
__local_test_mode || __global_test_mode
end
|
.disable!(&block) ⇒ Object
44
45
46
|
# File 'lib/sidekiq/testing.rb', line 44
def disable!(&block)
__set_test_mode(:disable, &block)
end
|
.disabled? ⇒ Boolean
60
61
62
|
# File 'lib/sidekiq/testing.rb', line 60
def disabled?
__test_mode == :disable
end
|
.enabled? ⇒ Boolean
56
57
58
|
# File 'lib/sidekiq/testing.rb', line 56
def enabled?
__test_mode != :disable
end
|
.fake!(&block) ⇒ Object
48
49
50
|
# File 'lib/sidekiq/testing.rb', line 48
def fake!(&block)
__set_test_mode(:fake, &block)
end
|
.fake? ⇒ Boolean
64
65
66
|
# File 'lib/sidekiq/testing.rb', line 64
def fake?
__test_mode == :fake
end
|
.inline!(&block) ⇒ Object
52
53
54
|
# File 'lib/sidekiq/testing.rb', line 52
def inline!(&block)
__set_test_mode(:inline, &block)
end
|
.inline? ⇒ Boolean
68
69
70
|
# File 'lib/sidekiq/testing.rb', line 68
def inline?
__test_mode == :inline
end
|
.server_middleware {|@server_chain| ... } ⇒ Object