Sha256: 8a81ec5204d305ad256061919147b7c560ff31d664e73920060456f149b120ef

Contents?: true

Size: 1003 Bytes

Versions: 6

Compression:

Stored size: 1003 Bytes

Contents

require File.dirname(__FILE__) + '/../test_helper'
require '<%= file_name %>'

class <%= class_name %>Test < Test::Unit::TestCase
  FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
  CHARSET = "utf-8"

  def setup
    ActionMailer::Base.delivery_method = :test
    ActionMailer::Base.perform_deliveries = true
    ActionMailer::Base.deliveries = []

    @expected = TMail::Mail.new
    @expected.set_content_type "text", "plain", { "charset" => CHARSET }
  end

<% for action in actions -%>
  def test_<%= action %>
    @expected.subject = encode '<%= class_name %>#<%= action %>'
    @expected.body    = read_fixture('<%= action %>')
    @expected.date    = Time.now

    assert_equal @expected.encoded, <%= class_name %>.create_<%= action %>(@expected.date).encoded
  end

<% end -%>
  private
    def read_fixture(action)
      IO.readlines("#{FIXTURES_PATH}/<%= file_name %>/#{action}")
    end

    def encode(subject)
      ActionMailer::Base.quoted_printable(subject, CHARSET)
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails-0.10.1 lib/rails_generator/generators/components/mailer/templates/unit_test.rb
rails-0.11.1 lib/rails_generator/generators/components/mailer/templates/unit_test.rb
rails-0.11.0 lib/rails_generator/generators/components/mailer/templates/unit_test.rb
rails-0.10.0 lib/rails_generator/generators/components/mailer/templates/unit_test.rb
rails-0.12.0 lib/rails_generator/generators/components/mailer/templates/unit_test.rb
rails-0.12.1 lib/rails_generator/generators/components/mailer/templates/unit_test.rb