From 6a485c3100090fbf474336802c851b842b8a96f3 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Sat, 9 Dec 2006 05:21:33 +0000 Subject: Fix remove_constant to correctly handle constant names of the form "::A::...". References #6720. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5710 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/array_ext_test.rb | 2 +- activesupport/test/dependencies_test.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'activesupport/test') diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb index 709df84f06..87608de8d5 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -176,7 +176,7 @@ class ArrayToXmlTests < Test::Unit::TestCase { :name => "Jason", :age => 31, :age_in_millis => BigDecimal.new('1.0') } ].to_xml(:skip_instruct => false, :indent => 0) - assert /^<\?xml [^>]*/.match(xml) + assert(/^<\?xml [^>]*/.match(xml)) assert xml.rindex(/<\?xml /) == 0 end end diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 954f2f4a85..52f83e0f9f 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -691,4 +691,15 @@ class DependenciesTest < Test::Unit::TestCase ensure Object.send(:remove_const, :RaisesNameError) if defined?(::RaisesNameError) end + + def test_remove_constant_handles_double_colon_at_start + Object.const_set 'DeleteMe', Module.new + DeleteMe.const_set 'OrMe', Module.new + Dependencies.send :remove_constant, "::DeleteMe::OrMe" + assert ! defined?(DeleteMe::OrMe) + assert defined?(DeleteMe) + Dependencies.send :remove_constant, "::DeleteMe" + assert ! defined?(DeleteMe) + end + end -- cgit v1.2.3