Sha256: 02db14a37c40071c8dc92997c026f917278ad6932a64c134a4113ddb31e723a0

Contents?: true

Size: 1.48 KB

Versions: 18

Compression:

Stored size: 1.48 KB

Contents

ENV['RACK_ENV'] = 'test'
PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT

require 'minitest/autorun'
require 'minitest/pride'
require 'rack/test'
require 'padrino-core'
require 'padrino-helpers'
require 'padrino/rendering'
require 'padrino-mailer/ext'
require 'padrino-mailer'

require 'ext/rack-test-methods'

class MiniTest::Spec
  include Rack::Test::Methods

  # Sets up a Sinatra::Base subclass defined with the block
  # given. Used in setup or individual spec methods to establish
  # the application.
  def mock_app(base=Padrino::Application, &block)
    @app = Sinatra.new(base, &block)
  end

  def app
    Rack::Lint.new(@app)
  end

  def pop_last_delivery
    Mail::TestMailer.deliveries.pop
  end

  # Asserts that the specified email object was delivered
  def assert_email_sent(mail_attributes, options={})
    mail_message = Mail::TestMailer.deliveries.last
    raise "No mail message has been sent!" unless mail_message
    delivery_attributes = mail_attributes
    delivery_attributes.update(:to => Array(mail_attributes[:to]), :from => Array(mail_attributes[:from]))
    delivery_attributes.each_pair do |key, expected|
      next unless mail_message.respond_to?(key)
      actual = mail_message.send(key)
      actual = actual.to_s.chomp if key == :body
      actual = mail_message.content_type_without_symbol.split(';').first if key == :content_type
      assert_equal expected, actual, "Mail failure at field '#{key}'"
    end
    Mail::TestMailer.deliveries.clear
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
padrino-mailer-0.15.3 test/helper.rb
padrino-mailer-0.15.2 test/helper.rb
padrino-mailer-0.15.1 test/helper.rb
padrino-mailer-0.15.0 test/helper.rb
padrino-mailer-0.14.4 test/helper.rb
padrino-mailer-0.14.3 test/helper.rb
padrino-mailer-0.14.2 test/helper.rb
padrino-mailer-0.13.3.4 test/helper.rb
padrino-mailer-0.14.1.1 test/helper.rb
padrino-mailer-0.14.1 test/helper.rb
padrino-mailer-0.14.0.2 test/helper.rb
padrino-mailer-0.14.0.1 test/helper.rb
padrino-mailer-0.14.0 test/helper.rb
padrino-mailer-0.14.0.rc2 test/helper.rb
padrino-mailer-0.14.0.rc1 test/helper.rb
padrino-mailer-0.13.3.3 test/helper.rb
padrino-mailer-0.13.3.2 test/helper.rb
padrino-mailer-0.13.3.1 test/helper.rb