提交 58434e05 编写于 作者: M Mike Moore

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.
上级 0ce383db
......@@ -49,9 +49,11 @@ def mailer_class
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 @@ def test_set_mailer_class_manual_using_string
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册