Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup generator tests by extracting repeated code into generator_te…
…st_helper. Add test for mailer generator. Signed-off-by: Joshua Peek <josh@joshpeek.com>
- Loading branch information
Showing
6 changed files
with
227 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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'", | ||
"@body = {}", | ||
"@recipients = ''", | ||
"@from = ''", | ||
"@sent_on = sent_at", | ||
"@headers = {}" | ||
], | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.