提交 49a59cc6 编写于 作者: Y yuuji.yaginuma

`assert_emails` in block form use the given number as expected value

上级 684bbe86
* `assert_emails` in block form use the given number as expected value.
This makes the error message much easier to understand.
*Yuji Yaginuma*
* Add support for inline images in mailer previews by using an interceptor
class to convert cid: urls in image src attributes to data urls.
......
......@@ -34,7 +34,7 @@ def assert_emails(number)
original_count = ActionMailer::Base.deliveries.size
yield
new_count = ActionMailer::Base.deliveries.size
assert_equal original_count + number, new_count, "#{number} emails expected, but #{new_count - original_count} were sent"
assert_equal number, new_count - original_count, "#{number} emails expected, but #{new_count - original_count} were sent"
else
assert_equal number, ActionMailer::Base.deliveries.size
end
......
......@@ -112,6 +112,17 @@ def test_assert_emails_too_many_sent
assert_match(/1 .* but 2/, error.message)
end
def test_assert_emails_message
TestHelperMailer.test.deliver_now
error = assert_raise ActiveSupport::TestCase::Assertion do
assert_emails 2 do
TestHelperMailer.test.deliver_now
end
end
assert_match "Expected: 2", error.message
assert_match "Actual: 1", error.message
end
def test_assert_no_emails_failure
error = assert_raise ActiveSupport::TestCase::Assertion do
assert_no_emails do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册