Sha256: 46aa0b5c9705c31fc6a427a51f90a724db7d993cf4d900d0ba729cf068056cee
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 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, *__rest__, &__block__) res = super TestDelivery.track_line(line) if res end; respond_to?(:ruby2_keywords, true) && (ruby2_keywords :notify_line) def test? TestDelivery.enabled? end end end ActiveDelivery::Base.prepend ActiveDelivery::TestDelivery require "active_delivery/testing/rspec" if defined?(RSpec::Core)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_delivery-1.1.0 | lib/.rbnext/3.0/active_delivery/testing.rb |
active_delivery-1.0.0 | lib/.rbnext/3.0/active_delivery/testing.rb |