aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/rails_mailer_generator_test.rb
blob: 3cf8cda442873f59a4159d8331d8613963c37b25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'generators/generator_test_helper'

class RailsMailerGeneratorTest < GeneratorTestCase

  def test_generates_mailer
    run_generator('mailer', %w(Notifier reset_password))

    assert_generated_model_for :notifier, 'ActionMailer::Base' do |model|
      assert_has_method model, :reset_password do |name, body|
        assert_equal [
            "subject    'Notifier#reset_password'",
            "recipients ''",
            "from       ''",
            "sent_on    sent_at",
            "",
            "body       :action => 'reset_password'"
          ],
          body.split("\n").map{|line| line.sub(' '*4, '') }
      end
    end
    
    assert_generated_views_for :notifier, 'reset_password.erb'
    assert_generated_unit_test_for :notifier, 'ActionMailer::TestCase'
    assert_generated_file "test/fixtures/notifier/reset_password"
  end
end