Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 29a6a17a11cd98f18ad46e882cc8f7fd669de59f 1 parent 811604f
@carlosantoniodasilva carlosantoniodasilva authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 actionview/test/activerecord/polymorphic_routes_test.rb
View
12 actionview/test/activerecord/polymorphic_routes_test.rb
@@ -158,34 +158,38 @@ def test_namespaced_model_with_nested_resources
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
Please sign in to comment.
Something went wrong with that request. Please try again.