Sha256: 8031a1711365169c9676d4234b0779d581cf9e67b349e249ba461ae623796ba2

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

if Mack.env == "test"
  
  # Used for testing this method will return any emails that have been 'sent' using Mack::Notifier::DeliveryHandlers::Test.
  # These emails will get 'flushed' after each test.
  def delivered_emails
    Mack::Notifier::DeliveryHandlers::Test::EmailRegistry.registered_items
  end
  
  module Spec # :nodoc:
    module Example # :nodoc:
      module ExampleMethods # :nodoc:
        include Mack::Routes::Urls
        include Mack::Testing::Helpers

        alias_method :email_spec_execute, :execute

        def execute(options, instance_variables)
          @__res = email_spec_execute(options, instance_variables)
          Mack::Notifier::DeliveryHandlers::Test::EmailRegistry.reset!
          @__res
        end

      end # ExampleMethods
    end # Example
  end # Spec
  
  module Test # :nodoc:
    module Unit # :nodoc:
      class TestCase # :nodoc:

        # Let's alias the run method in the class above us so we can create a new one here
        # but still reference it.
        alias_method :super_run, :run # :nodoc:

        # We need to wrap the run method so we can do things like
        # run a cleanup method if it exists
        def run(result, &progress_block) # :nodoc:
          @__res = super_run(result)
          Mack::Notifier::DeliveryHandlers::Test::EmailRegistry.reset!
          @__res
        end

      end # TestCase
    end # Unit
  end # Test
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mack-notifier-0.6.1.1 lib/mack-notifier/testing.rb
mack-notifier-0.6.1 lib/mack-notifier/testing.rb
mack-notifier-0.6.1.2 lib/mack-notifier/testing.rb
mack-notifier-0.7.0 lib/mack-notifier/testing.rb
mack-notifier-0.7.0.1 lib/mack-notifier/testing.rb