Skip to content

Commit

Permalink
Fix some assert_raise calls containing messages in Active Support
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Oct 28, 2012
1 parent ed80dd7 commit d46f9e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
19 changes: 13 additions & 6 deletions activesupport/test/core_ext/module/qualified_const_test.rb
Expand Up @@ -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
3 changes: 2 additions & 1 deletion activesupport/test/dependencies_test.rb
Expand Up @@ -147,7 +147,8 @@ def test_mutual_dependencies_dont_infinite_loop

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

Expand Down

0 comments on commit d46f9e3

Please sign in to comment.