Sha256: 06da5347ea3a107674f10130a205ba594ba390ff894d5a10cfa4ca0a334a6136

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 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, data = {})
        Mailstro::Test.deliveries << Mailstro::Delivery.new(template_name, contact_email, data)
        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, data = {})
        Mailstro::Delivery.deliver(template_name, contact_email, data)
      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

1 entries across 1 versions & 1 rubygems

Version Path
mailstro-0.0.6 lib/mailstro/test.rb