Sha256: 7f109b94dc60932acff05e65ca1118551cd560f1b088c94e7b2e1ef1050ec0c7
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true module ActiveDelivery module TestDelivery class << self 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 def enabled? Thread.current.thread_variable_get(:active_delivery_testing) == true end def track(delivery, options) store << [delivery, options] end def track_line(line) lines << line end def store Thread.current.thread_variable_get(:active_delivery_testing_store) || Thread.current.thread_variable_set(:active_delivery_testing_store, []) end def lines Thread.current.thread_variable_get(:active_delivery_testing_lines) || Thread.current.thread_variable_set(:active_delivery_testing_lines, []) end def clear store.clear lines.clear end end def perform_notify(delivery, **options) return super unless test? TestDelivery.track(delivery, options) nil end def notify_line(line, ...) res = super TestDelivery.track_line(line) if res end def test? TestDelivery.enabled? end end end ActiveDelivery::Base.prepend ActiveDelivery::TestDelivery require "active_delivery/testing/rspec" if defined?(RSpec::Core)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
active_delivery-1.1.0 | lib/active_delivery/testing.rb |
active_delivery-1.0.0 | lib/active_delivery/testing.rb |
active_delivery-1.0.0.rc2 | lib/active_delivery/testing.rb |