Sha256: 67457de9427922ccafede0f73cbfed2eefc3a715ed8b5bf4ef2c4b8d6df69630

Contents?: true

Size: 939 Bytes

Versions: 2

Compression:

Stored size: 939 Bytes

Contents

module Mailstro
  module Test
    @@enabled    = false
    @@deliveries = []

    def self.deliveries
      @@deliveries
    end

    def self.clear_deliveries
      @@deliveries = []
    end

    def self.enable
      def Mailstro.deliver(template_name, contact_email, payload = {})
        Mailstro::Test.deliveries << Mailstro::Delivery.new(template_name, contact_email, payload)
        true # insert response here
      end

      def Mailstro.has_delivered?(template_name)
        Mailstro::Test.has_delivered?(template_name)
      end

      @@enabled = true
    end

    def self.disable
      def Mailstro.deliver(template_name, contact_email, payload = {})
        Mailstro::Delivery.deliver(template_name, contact_email, payload)
      end

      @@enabled = false
    end

    def self.has_delivered?(template_name)
      templates = @@deliveries.map(&:template_name)

      templates.include?(template_name)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mailstro-0.0.5 lib/mailstro/test.rb
mailstro-0.0.4 lib/mailstro/test.rb