提交 cc14a3b2 编写于 作者: F Francesco Rodriguez

Fix ActiveSupport tests that depend on run order

上级 e8afb84b
class ClassFolder::ClassFolderSubclass < ClassFolder class ClassFolder::ClassFolderSubclass < ClassFolder
ConstantInClassFolder ConstantInClassFolder = 'indeed'
end end
...@@ -67,17 +67,24 @@ class QualifiedConstTest < ActiveSupport::TestCase ...@@ -67,17 +67,24 @@ class QualifiedConstTest < ActiveSupport::TestCase
end end
test "qualified_const_set" do test "qualified_const_set" do
m = Module.new begin
assert_equal m, Object.qualified_const_set("QualifiedConstTestMod2", m) m = Module.new
assert_equal m, ::QualifiedConstTestMod2 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 # We are going to assign to existing constants on purpose, so silence warnings.
assert_equal true, QualifiedConstTestMod.qualified_const_set("QualifiedConstTestMod::X", true) silence_warnings do
assert_equal true, QualifiedConstTestMod::X 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 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
end end
......
...@@ -679,6 +679,8 @@ def test_unloadable_should_return_change_flag ...@@ -679,6 +679,8 @@ def test_unloadable_should_return_change_flag
assert_equal true, M.unloadable assert_equal true, M.unloadable
assert_equal false, M.unloadable assert_equal false, M.unloadable
end end
ensure
Object.class_eval { remove_const :M }
end end
def test_unloadable_constants_should_receive_callback def test_unloadable_constants_should_receive_callback
......
...@@ -169,11 +169,11 @@ def test_acronyms_camelize_lower ...@@ -169,11 +169,11 @@ def test_acronyms_camelize_lower
def test_underscore_acronym_sequence def test_underscore_acronym_sequence
ActiveSupport::Inflector.inflections do |inflect| ActiveSupport::Inflector.inflections do |inflect|
inflect.acronym("API") inflect.acronym("API")
inflect.acronym("HTML5") inflect.acronym("JSON")
inflect.acronym("HTML") inflect.acronym("HTML")
end end
assert_equal("html5_html_api", ActiveSupport::Inflector.underscore("HTML5HTMLAPI")) assert_equal("json_html_api", ActiveSupport::Inflector.underscore("JSONHTMLAPI"))
end end
def test_underscore def test_underscore
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册