mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix some assert_raise calls containing messages in Active Support
This commit is contained in:
parent
ed80dd7a56
commit
d46f9e3731
2 changed files with 15 additions and 7 deletions
|
@ -89,13 +89,20 @@ class QualifiedConstTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test "reject absolute paths" do
|
||||
assert_raise(NameError, "wrong constant name ::X") { Object.qualified_const_defined?("::X")}
|
||||
assert_raise(NameError, "wrong constant name ::X") { Object.qualified_const_defined?("::X::Y")}
|
||||
assert_raise_with_message(NameError, "wrong constant name ::X") { Object.qualified_const_defined?("::X")}
|
||||
assert_raise_with_message(NameError, "wrong constant name ::X") { Object.qualified_const_defined?("::X::Y")}
|
||||
|
||||
assert_raise(NameError, "wrong constant name ::X") { Object.qualified_const_get("::X")}
|
||||
assert_raise(NameError, "wrong constant name ::X") { Object.qualified_const_get("::X::Y")}
|
||||
assert_raise_with_message(NameError, "wrong constant name ::X") { Object.qualified_const_get("::X")}
|
||||
assert_raise_with_message(NameError, "wrong constant name ::X") { Object.qualified_const_get("::X::Y")}
|
||||
|
||||
assert_raise(NameError, "wrong constant name ::X") { Object.qualified_const_set("::X", nil)}
|
||||
assert_raise(NameError, "wrong constant name ::X") { Object.qualified_const_set("::X::Y", nil)}
|
||||
assert_raise_with_message(NameError, "wrong constant name ::X") { Object.qualified_const_set("::X", nil)}
|
||||
assert_raise_with_message(NameError, "wrong constant name ::X") { Object.qualified_const_set("::X::Y", nil)}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_raise_with_message(expected_exception, expected_message, &block)
|
||||
exception = assert_raise(expected_exception, &block)
|
||||
assert_equal expected_message, exception.message
|
||||
end
|
||||
end
|
||||
|
|
|
@ -147,7 +147,8 @@ class DependenciesTest < ActiveSupport::TestCase
|
|||
|
||||
def test_circular_autoloading_detection
|
||||
with_autoloading_fixtures do
|
||||
assert_raise(RuntimeError, "Circular dependency detected while autoloading constant Circular1") { Circular1 }
|
||||
e = assert_raise(RuntimeError) { Circular1 }
|
||||
assert_equal "Circular dependency detected while autoloading constant Circular1", e.message
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue