diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-10-28 17:54:06 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-10-28 17:54:24 -0200 |
commit | d46f9e37314f18b6ee7b2600b9886ea4d47e555e (patch) | |
tree | 0e2073538dacadf8ed4cc16a1e795632ff7a7d22 | |
parent | ed80dd7a568f4045a26863d8a126d0a5e39d258c (diff) | |
download | rails-d46f9e37314f18b6ee7b2600b9886ea4d47e555e.tar.gz rails-d46f9e37314f18b6ee7b2600b9886ea4d47e555e.tar.bz2 rails-d46f9e37314f18b6ee7b2600b9886ea4d47e555e.zip |
Fix some assert_raise calls containing messages in Active Support
-rw-r--r-- | activesupport/test/core_ext/module/qualified_const_test.rb | 19 | ||||
-rw-r--r-- | activesupport/test/dependencies_test.rb | 3 |
2 files changed, 15 insertions, 7 deletions
diff --git a/activesupport/test/core_ext/module/qualified_const_test.rb b/activesupport/test/core_ext/module/qualified_const_test.rb index 343a848a42..37c9228a64 100644 --- a/activesupport/test/core_ext/module/qualified_const_test.rb +++ b/activesupport/test/core_ext/module/qualified_const_test.rb @@ -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 diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index e5bc806397..670a04e5df 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -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 |