From 29a6a17a11cd98f18ad46e882cc8f7fd669de59f Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 30 Jul 2014 23:35:30 -0300 Subject: Properly assert for the expected messages The message passed to Minitest's assert_raise is used as output in case the assertion fails, but we can test against the exact message by using the actual exception object that is returned from the assert_raise call. --- actionview/test/activerecord/polymorphic_routes_test.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'actionview/test/activerecord/polymorphic_routes_test.rb') diff --git a/actionview/test/activerecord/polymorphic_routes_test.rb b/actionview/test/activerecord/polymorphic_routes_test.rb index fef27ef492..e220dcb8cb 100644 --- a/actionview/test/activerecord/polymorphic_routes_test.rb +++ b/actionview/test/activerecord/polymorphic_routes_test.rb @@ -158,34 +158,38 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_with_nil with_test_routes do - assert_raise ArgumentError, "Nil location provided. Can't build URI." do + exception = assert_raise ArgumentError do polymorphic_url(nil) end + assert_equal "Nil location provided. Can't build URI.", exception.message end end def test_with_empty_list with_test_routes do - assert_raise ArgumentError, "Nil location provided. Can't build URI." do + exception = assert_raise ArgumentError do polymorphic_url([]) end + assert_equal "Nil location provided. Can't build URI.", exception.message end end def test_with_nil_id with_test_routes do - assert_raise ArgumentError, "Nil location provided. Can't build URI." do + exception = assert_raise ArgumentError do polymorphic_url({ :id => nil }) end + assert_equal "Nil location provided. Can't build URI.", exception.message end end def test_with_nil_in_list with_test_routes do - assert_raise ArgumentError, "Nil location provided. Can't build URI." do + exception = assert_raise ArgumentError do @series.save polymorphic_url([nil, @series]) end + assert_equal "Nil location provided. Can't build URI.", exception.message end end -- cgit v1.2.3