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.
This commit is contained in:
Carlos Antonio da Silva 2014-07-30 23:35:30 -03:00
parent 811604f3f7
commit 29a6a17a11

@ -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