Sha256: 3159848a5f69f648efd29acf487a0ac372a37c33f223fcb04f8dc80cc02f37c6

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'spec/helper'

class MockSMTP
  INSTANCES = []

  def self.start(*args, &block)
    INSTANCES << new(*args, &block)
  end

  attr_reader :start_args, :result, :send_message_args

  def initialize(*args, &block)
    @start_args = args
    yield(self)
  end

  def send_message(*args)
    @send_message_args = args
  end
end

Mailit::Mail::OPTIONS[:message_id] = lambda{|mail| '1234' }

describe Mailit::Mailer do
  it 'sends a mail' do
    mail = Mailit::Mail.new(
      :to => 'test@example.com',
      :from => 'sender@example.com',
      :subject => 'Here are some files for you!',
      :text => 'Some text about that')

    mailer = Mailit::Mailer.new

    mailer.send(mail, :server => 'smtp.example.com', :port => 25,
                :domain => 'example.com', :password => 'foo',
                :mailer => MockSMTP)

    mock = MockSMTP::INSTANCES.last
    mock.start_args.should == [
      'smtp.example.com', 25,
      'example.com',
      'sender@example.com',
      'foo',
      :login
    ]
    mock.send_message_args.should == [mail.to_s, mail.from, mail.to]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mailit-2010.06.03 spec/mailit/mailer.rb