Sha256: b98b0a67b469553463ffde5c807eef7c3c18a7c4f84fbdfbf0f5d3b972acbd97

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 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.merge(via: owner)
      end

      def notify_later
        return super unless AbstractNotifier.test?

        Driver.enqueue_notification payload.merge(via: owner)
      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
active_delivery-1.0.0.rc2 lib/abstract_notifier/testing.rb