From cc14a3b2c1d5684c88355230faa263515358776d Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sat, 14 Jul 2012 16:01:28 -0500 Subject: Fix ActiveSupport tests that depend on run order --- .../class_folder/class_folder_subclass.rb | 2 +- .../test/core_ext/module/qualified_const_test.rb | 29 ++++++++++++++-------- activesupport/test/dependencies_test.rb | 2 ++ activesupport/test/inflector_test.rb | 4 +-- 4 files changed, 23 insertions(+), 14 deletions(-) (limited to 'activesupport/test') diff --git a/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb b/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb index ef66ddaac7..402609c583 100644 --- a/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb +++ b/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb @@ -1,3 +1,3 @@ class ClassFolder::ClassFolderSubclass < ClassFolder - ConstantInClassFolder + ConstantInClassFolder = 'indeed' end diff --git a/activesupport/test/core_ext/module/qualified_const_test.rb b/activesupport/test/core_ext/module/qualified_const_test.rb index 8af0b9a023..343a848a42 100644 --- a/activesupport/test/core_ext/module/qualified_const_test.rb +++ b/activesupport/test/core_ext/module/qualified_const_test.rb @@ -67,17 +67,24 @@ class QualifiedConstTest < ActiveSupport::TestCase end test "qualified_const_set" do - m = Module.new - assert_equal m, Object.qualified_const_set("QualifiedConstTestMod2", m) - assert_equal m, ::QualifiedConstTestMod2 - - # We are going to assign to existing constants on purpose, so silence warnings. - silence_warnings do - assert_equal true, QualifiedConstTestMod.qualified_const_set("QualifiedConstTestMod::X", true) - assert_equal true, QualifiedConstTestMod::X - - assert_equal 10, QualifiedConstTestMod::M.qualified_const_set("X", 10) - assert_equal 10, QualifiedConstTestMod::M::X + begin + m = Module.new + assert_equal m, Object.qualified_const_set("QualifiedConstTestMod2", m) + assert_equal m, ::QualifiedConstTestMod2 + + # We are going to assign to existing constants on purpose, so silence warnings. + silence_warnings do + assert_equal true, QualifiedConstTestMod.qualified_const_set("QualifiedConstTestMod::X", true) + assert_equal true, QualifiedConstTestMod::X + + assert_equal 10, QualifiedConstTestMod::M.qualified_const_set("X", 10) + assert_equal 10, QualifiedConstTestMod::M::X + end + ensure + silence_warnings do + QualifiedConstTestMod.qualified_const_set('QualifiedConstTestMod::X', false) + QualifiedConstTestMod::M.qualified_const_set('X', 1) + end end end diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 69829bcda5..f1da6378a7 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -679,6 +679,8 @@ class DependenciesTest < ActiveSupport::TestCase assert_equal true, M.unloadable assert_equal false, M.unloadable end + ensure + Object.class_eval { remove_const :M } end def test_unloadable_constants_should_receive_callback diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index cd91002147..aa41e57928 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -169,11 +169,11 @@ class InflectorTest < ActiveSupport::TestCase def test_underscore_acronym_sequence ActiveSupport::Inflector.inflections do |inflect| inflect.acronym("API") - inflect.acronym("HTML5") + inflect.acronym("JSON") inflect.acronym("HTML") end - assert_equal("html5_html_api", ActiveSupport::Inflector.underscore("HTML5HTMLAPI")) + assert_equal("json_html_api", ActiveSupport::Inflector.underscore("JSONHTMLAPI")) end def test_underscore -- cgit v1.2.3