Module: Cloudenvoy::Testing
- Defined in:
- lib/cloudenvoy/testing.rb
Overview
Enable/Disable test mode for Cloudenvoy
Class Method Summary collapse
-
.clear(topic) ⇒ Array
Clear all messages in a specific topic.
-
.clear_all ⇒ Object
Clear all messages across all topics.
-
.enable!(&block) ⇒ Object
Set cloudenvoy to real mode temporarily.
-
.enabled? ⇒ Boolean
Return true if Cloudenvoy is enabled.
-
.fake!(&block) ⇒ Object
Set cloudenvoy to fake mode temporarily.
-
.fake? ⇒ Boolean
Return true if Cloudenvoy is in fake mode.
-
.in_memory? ⇒ Boolean
Return true if tasks should be managed in memory.
-
.queue(topic) ⇒ Array
Return the message queue for a specific topic.
-
.switch_test_mode(mode) ⇒ Symbol
Set the test mode, either permanently or temporarily (via block).
Class Method Details
.clear(topic) ⇒ Array
Clear all messages in a specific topic.
91 92 93 |
# File 'lib/cloudenvoy/testing.rb', line 91 def clear(topic) Cloudenvoy::Backend::MemoryPubSub.clear(topic) end |
.clear_all ⇒ Object
Clear all messages across all topics.
80 81 82 |
# File 'lib/cloudenvoy/testing.rb', line 80 def clear_all Cloudenvoy::Backend::MemoryPubSub.clear_all end |
.enable!(&block) ⇒ Object
Set cloudenvoy to real mode temporarily
37 38 39 |
# File 'lib/cloudenvoy/testing.rb', line 37 def enable!(&block) switch_test_mode(:enabled, &block) end |
.enabled? ⇒ Boolean
Return true if Cloudenvoy is enabled.
53 54 55 |
# File 'lib/cloudenvoy/testing.rb', line 53 def enabled? !@test_mode || @test_mode == :enabled end |
.fake!(&block) ⇒ Object
Set cloudenvoy to fake mode temporarily
46 47 48 |
# File 'lib/cloudenvoy/testing.rb', line 46 def fake!(&block) switch_test_mode(:fake, &block) end |
.fake? ⇒ Boolean
Return true if Cloudenvoy is in fake mode.
62 63 64 |
# File 'lib/cloudenvoy/testing.rb', line 62 def fake? @test_mode == :fake end |
.in_memory? ⇒ Boolean
Return true if tasks should be managed in memory.
71 72 73 |
# File 'lib/cloudenvoy/testing.rb', line 71 def in_memory? !enabled? end |
.queue(topic) ⇒ Array
Return the message queue for a specific topic.
102 103 104 |
# File 'lib/cloudenvoy/testing.rb', line 102 def queue(topic) Cloudenvoy::Backend::MemoryPubSub.queue(topic) 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/cloudenvoy/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 |