mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Support mailer tests using spec DSL
Improve how mailer tests to resolve mailers from the test name. Add tests for mailer tests using the minitest spec DSL.
This commit is contained in:
parent
0ce383db58
commit
58434e05fe
2 changed files with 149 additions and 3 deletions
|
@ -49,9 +49,11 @@ module ActionMailer
|
|||
end
|
||||
|
||||
def determine_default_mailer(name)
|
||||
name.sub(/Test$/, '').constantize
|
||||
rescue NameError
|
||||
raise NonInferrableMailerError.new(name)
|
||||
mailer = determine_constant_from_test_name(name) do |constant|
|
||||
Class === constant && constant < ActionMailer::Base
|
||||
end
|
||||
raise NonInferrableMailerError.new(name) if mailer.nil?
|
||||
mailer
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -26,3 +26,147 @@ class CrazyStringNameMailerTest < ActionMailer::TestCase
|
|||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
||||
describe TestTestMailer do
|
||||
it "gets the mailer from the test name" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
||||
describe TestTestMailer, :action do
|
||||
it "gets the mailer from the test name" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
||||
describe TestTestMailer do
|
||||
describe "nested" do
|
||||
it "gets the mailer from the test name" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe TestTestMailer, :action do
|
||||
describe "nested" do
|
||||
it "gets the mailer from the test name" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "TestTestMailer" do
|
||||
it "gets the mailer from the test name" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
||||
describe "TestTestMailerTest" do
|
||||
it "gets the mailer from the test name" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
||||
describe "TestTestMailer" do
|
||||
describe "nested" do
|
||||
it "gets the mailer from the test name" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "TestTestMailerTest" do
|
||||
describe "nested" do
|
||||
it "gets the mailer from the test name" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "AnotherCrazySymbolNameMailerTest" do
|
||||
tests :test_test_mailer
|
||||
|
||||
it "gets the mailer after setting it with a symbol" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
||||
describe "AnotherCrazyStringNameMailerTest" do
|
||||
tests 'test_test_mailer'
|
||||
|
||||
it "gets the mailer after setting it with a string" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
||||
describe "Another Crazy Name Mailer Test" do
|
||||
tests TestTestMailer
|
||||
|
||||
it "gets the mailer after setting it manually" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
||||
describe "Another Crazy Symbol Name Mailer Test" do
|
||||
tests :test_test_mailer
|
||||
|
||||
it "gets the mailer after setting it with a symbol" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
||||
describe "Another Crazy String Name Mailer Test" do
|
||||
tests 'test_test_mailer'
|
||||
|
||||
it "gets the mailer after setting it with a string" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
||||
describe "AnotherCrazySymbolNameMailerTest" do
|
||||
tests :test_test_mailer
|
||||
|
||||
describe "nested" do
|
||||
it "gets the mailer after setting it with a symbol" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "AnotherCrazyStringNameMailerTest" do
|
||||
tests 'test_test_mailer'
|
||||
|
||||
describe "nested" do
|
||||
it "gets the mailer after setting it with a string" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Another Crazy Name Mailer Test" do
|
||||
tests TestTestMailer
|
||||
|
||||
describe "nested" do
|
||||
it "gets the mailer after setting it manually" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Another Crazy Symbol Name Mailer Test" do
|
||||
tests :test_test_mailer
|
||||
|
||||
describe "nested" do
|
||||
it "gets the mailer after setting it with a symbol" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Another Crazy String Name Mailer Test" do
|
||||
tests 'test_test_mailer'
|
||||
|
||||
it "gets the mailer after setting it with a string" do
|
||||
assert_equal TestTestMailer, self.class.mailer_class
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue