Sha256: 961c438dcb475d6a5bc23fc1c4aec6a4ed012a02462203cd9e314b66ea998012

Contents?: true

Size: 672 Bytes

Versions: 3

Compression:

Stored size: 672 Bytes

Contents

module Emailer
  
  class MockNetSmtp
    def start(*args); end
    def sendmail(*args); end
    def finish; end
  end
  
  class MockSmtpFacade < SmtpFacade
    
    attr_reader :sent
    
    def initialize(settings = {})
      @sent = []
      super
    end
    
    # Don't open connections...
    def get_net_smtp_instance
      MockNetSmtp.new
    end
    
    # And save, don't send, mail...
    def send_mail(options)
      raise ConnectionNotOpenError unless @open
      @sent << options
      true
    rescue ConnectionNotOpenError => e
      raise e
    rescue StandardError => e
      @error = e
      @offending_mail = mail
      false
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
erikhansson-emailer-0.1.1 lib/emailer/mock_smtp_facade.rb
erikhansson-emailer-0.1.2 lib/emailer/mock_smtp_facade.rb
erikhansson-emailer-0.1.3 lib/emailer/mock_smtp_facade.rb