Class: FastlyNsq::Testing
- Inherits:
-
Object
- Object
- FastlyNsq::Testing
- Defined in:
- lib/fastly_nsq/testing.rb
Overview
FastlyNsq::Testing.disable! # do it live
FastlyNsq::Testing.enable! # re-enable testing mode
Class Attribute Summary collapse
-
.__test_mode ⇒ Object
Returns the value of attribute __test_mode.
Class Method Summary collapse
- .__set_test_mode(mode) ⇒ Object
- .disable!(&block) ⇒ Object
- .disabled? ⇒ Boolean
- .enabled? ⇒ Boolean
- .fake!(&block) ⇒ Object
- .fake? ⇒ Boolean
- .inline!(&block) ⇒ Object
- .inline? ⇒ Boolean
-
.message(data:, meta: nil) ⇒ Object
Creates a FastlyNsq::TestMessage that is used to create a FastlyNsq::Message where the underlying
nsq_message
is the TestMessage and not an Nsq::Message. - .reset! ⇒ Object
Class Attribute Details
.__test_mode ⇒ Object
Returns the value of attribute __test_mode.
39 40 41 |
# File 'lib/fastly_nsq/testing.rb', line 39 def __test_mode @__test_mode end |
Class Method Details
.__set_test_mode(mode) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fastly_nsq/testing.rb', line 41 def __set_test_mode(mode) if block_given? current_mode = __test_mode begin self.__test_mode = mode yield ensure self.__test_mode = current_mode end else self.__test_mode = mode end end |
.disable!(&block) ⇒ Object
55 56 57 |
# File 'lib/fastly_nsq/testing.rb', line 55 def disable!(&block) __set_test_mode(:disable, &block) end |
.disabled? ⇒ Boolean
71 72 73 |
# File 'lib/fastly_nsq/testing.rb', line 71 def disabled? __test_mode == :disable end |
.enabled? ⇒ Boolean
67 68 69 |
# File 'lib/fastly_nsq/testing.rb', line 67 def enabled? __test_mode != :disable end |
.fake!(&block) ⇒ Object
59 60 61 |
# File 'lib/fastly_nsq/testing.rb', line 59 def fake!(&block) __set_test_mode(:fake, &block) end |
.fake? ⇒ Boolean
75 76 77 |
# File 'lib/fastly_nsq/testing.rb', line 75 def fake? __test_mode == :fake end |
.inline!(&block) ⇒ Object
63 64 65 |
# File 'lib/fastly_nsq/testing.rb', line 63 def inline!(&block) __set_test_mode(:inline, &block) end |
.inline? ⇒ Boolean
79 80 81 |
# File 'lib/fastly_nsq/testing.rb', line 79 def inline? __test_mode == :inline end |
.message(data:, meta: nil) ⇒ Object
Creates a FastlyNsq::TestMessage that is used to create a FastlyNsq::Message where the underlying nsq_message
is the TestMessage and not an Nsq::Message. This aids in testing application code that is doing message processing
100 101 102 103 |
# File 'lib/fastly_nsq/testing.rb', line 100 def (data:, meta: nil) = FastlyNsq::TestMessage.new(JSON.dump("data" => data, "meta" => )) FastlyNsq::Message.new() end |