Sha256: 84bb9a803d0e444be659ac1c1b1a2bfcf0ce207b3628ea286f65801f9181fde1
Contents?: true
Size: 1003 Bytes
Versions: 3
Compression:
Stored size: 1003 Bytes
Contents
# frozen_string_literal: true module ActiveDelivery module TestDelivery class << self def enable raise ArgumentError, "block is reauired" unless block_given? begin clear Thread.current[:active_delivery_testing] = true yield ensure Thread.current[:active_delivery_testing] = false end end def enabled? Thread.current[:active_delivery_testing] == true end def track(delivery, event, args, options) store << [delivery, event, args, options] end def store @store ||= [] end def clear store.clear end end def notify(event, *args, **options) return super unless test? TestDelivery.track(self, event, args, options) nil end def test? TestDelivery.enabled? end end end ActiveDelivery::Base.prepend ActiveDelivery::TestDelivery require "active_delivery/testing/rspec" if defined?(RSpec)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
active_delivery-0.3.0 | lib/active_delivery/testing.rb |
active_delivery-0.2.1 | lib/active_delivery/testing.rb |
active_delivery-0.2.0 | lib/active_delivery/testing.rb |