Sha256: 5b7eafebedb5290557fd0b5165ec0c46dc47fb348e1c7479f72209681e8a31cf

Contents?: true

Size: 692 Bytes

Versions: 5

Compression:

Stored size: 692 Bytes

Contents

module Emailer
  
  class MockNetSmtp
    def start(*args); end
    def sendmail(*args); end
    def finish; end
    def started?; 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

5 entries across 5 versions & 2 rubygems

Version Path
bjornblomqvist-emailer-0.1.4 lib/emailer/mock_smtp_facade.rb
bjornblomqvist-emailer-0.1.5 lib/emailer/mock_smtp_facade.rb
bjornblomqvist-emailer-0.1.6 lib/emailer/mock_smtp_facade.rb
bjornblomqvist-emailer-0.1.7 lib/emailer/mock_smtp_facade.rb
erikhansson-emailer-0.1.4 lib/emailer/mock_smtp_facade.rb