Sha256: 888c65bdd0c99d8f824d954104158104ad3538be4e443929988581e5108b4a84

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module AbstractNotifier
  module Testing
    module Driver
      class << self
        def deliveries
          Thread.current[:notifier_deliveries] ||= []
        end

        def enqueued_deliveries
          Thread.current[:notifier_enqueued_deliveries] ||= []
        end

        def clear
          deliveries.clear
          enqueued_deliveries.clear
        end

        def send_notification(data)
          deliveries << data
        end

        def enqueue_notification(data)
          enqueued_deliveries << data
        end
      end
    end

    module Notification
      def notify_now
        return super unless AbstractNotifier.test?

        Driver.send_notification payload
      end

      def notify_later
        return super unless AbstractNotifier.test?

        Driver.enqueue_notification payload
      end
    end
  end
end

AbstractNotifier::Notification.prepend AbstractNotifier::Testing::Notification

require "abstract_notifier/testing/rspec" if defined?(RSpec::Core)
require "abstract_notifier/testing/minitest" if defined?(Minitest::Assertions)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
abstract_notifier-0.3.2 lib/abstract_notifier/testing.rb