Module: Cloudtasker::Testing
- Defined in:
- lib/cloudtasker/testing.rb
Overview
Enable/Disable test mode for Cloudtasker
Class Method Summary collapse
-
.enable!(&block) ⇒ Object
Set cloudtasker to real mode temporarily.
-
.enabled? ⇒ Boolean
Return true if Cloudtasker is enabled.
-
.fake!(&block) ⇒ Object
Set cloudtasker to fake mode temporarily.
-
.fake? ⇒ Boolean
Return true if Cloudtasker is in fake mode.
-
.in_memory? ⇒ Boolean
Return true if tasks should be managed in memory.
-
.inline!(&block) ⇒ Object
Set cloudtasker to inline mode temporarily.
-
.inline? ⇒ Boolean
Return true if Cloudtasker is in inline mode.
-
.switch_test_mode(mode) ⇒ Symbol
Set the test mode, either permanently or temporarily (via block).
Class Method Details
.enable!(&block) ⇒ Object
Set cloudtasker to real mode temporarily
37 38 39 |
# File 'lib/cloudtasker/testing.rb', line 37 def enable!(&block) switch_test_mode(:enabled, &block) end |
.enabled? ⇒ Boolean
Return true if Cloudtasker is enabled.
62 63 64 |
# File 'lib/cloudtasker/testing.rb', line 62 def enabled? !@test_mode || @test_mode == :enabled end |
.fake!(&block) ⇒ Object
Set cloudtasker to fake mode temporarily
46 47 48 |
# File 'lib/cloudtasker/testing.rb', line 46 def fake!(&block) switch_test_mode(:fake, &block) end |
.fake? ⇒ Boolean
Return true if Cloudtasker is in fake mode.
71 72 73 |
# File 'lib/cloudtasker/testing.rb', line 71 def fake? @test_mode == :fake end |
.in_memory? ⇒ Boolean
Return true if tasks should be managed in memory.
89 90 91 |
# File 'lib/cloudtasker/testing.rb', line 89 def in_memory? !enabled? end |
.inline!(&block) ⇒ Object
Set cloudtasker to inline mode temporarily
55 56 57 |
# File 'lib/cloudtasker/testing.rb', line 55 def inline!(&block) switch_test_mode(:inline, &block) end |
.inline? ⇒ Boolean
Return true if Cloudtasker is in inline mode.
80 81 82 |
# File 'lib/cloudtasker/testing.rb', line 80 def inline? @test_mode == :inline end |
.switch_test_mode(mode) ⇒ Symbol
Set the test mode, either permanently or temporarily (via block).
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cloudtasker/testing.rb', line 18 def switch_test_mode(mode) if block_given? current_mode = @test_mode begin @test_mode = mode yield ensure @test_mode = current_mode end else @test_mode = mode end end |