Sha256: 170b46392cebb1ac4e183c00c1f527d58f52250d46069b2ef1c6a40d1c9044d0

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 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)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
abstract_notifier-0.3.0 lib/abstract_notifier/testing.rb
abstract_notifier-0.2.0 lib/abstract_notifier/testing.rb
abstract_notifier-0.1.1 lib/abstract_notifier/testing.rb
abstract_notifier-0.1.0 lib/abstract_notifier/testing.rb