Module: ActiveDelivery::TestDelivery
- Included in:
- Base
- Defined in:
- lib/active_delivery/testing.rb
Class Method Summary collapse
- .clear ⇒ Object
- .enable ⇒ Object
- .enabled? ⇒ Boolean
- .store ⇒ Object
- .track(delivery, event, args, options) ⇒ Object
Instance Method Summary collapse
Class Method Details
.clear ⇒ Object
29 30 31 |
# File 'lib/active_delivery/testing.rb', line 29 def clear store.clear end |
.enable ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/active_delivery/testing.rb', line 6 def enable raise ArgumentError, "block is required" unless block_given? begin clear Thread.current.thread_variable_set(:active_delivery_testing, true) yield ensure Thread.current.thread_variable_set(:active_delivery_testing, false) end end |
.enabled? ⇒ Boolean
17 18 19 |
# File 'lib/active_delivery/testing.rb', line 17 def enabled? Thread.current.thread_variable_get(:active_delivery_testing) == true end |
.store ⇒ Object
25 26 27 |
# File 'lib/active_delivery/testing.rb', line 25 def store @store ||= [] end |
.track(delivery, event, args, options) ⇒ Object
21 22 23 |
# File 'lib/active_delivery/testing.rb', line 21 def track(delivery, event, args, ) store << [delivery, event, args, ] end |
Instance Method Details
#notify(event, *args, **options) ⇒ Object
34 35 36 37 38 |
# File 'lib/active_delivery/testing.rb', line 34 def notify(event, *args, **) return super unless test? TestDelivery.track(self, event, args, ) nil end |
#test? ⇒ Boolean
40 41 42 |
# File 'lib/active_delivery/testing.rb', line 40 def test? TestDelivery.enabled? end |