From d46f9e37314f18b6ee7b2600b9886ea4d47e555e Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 28 Oct 2012 17:54:06 -0200 Subject: Fix some assert_raise calls containing messages in Active Support --- .../test/core_ext/module/qualified_const_test.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'activesupport/test/core_ext') 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 -- cgit v1.2.3