diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2012-05-04 23:57:11 -0400 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2012-05-19 15:47:35 +0100 |
commit | 99e9a733c8852f4ff065f2ede9c9cd03475411a2 (patch) | |
tree | f008edad42da92cb6c96a30edf346bf4e0b0c7fb /activesupport/test | |
parent | 1551de3c04bf872423683926f92916abe2a49ad1 (diff) | |
download | rails-99e9a733c8852f4ff065f2ede9c9cd03475411a2.tar.gz rails-99e9a733c8852f4ff065f2ede9c9cd03475411a2.tar.bz2 rails-99e9a733c8852f4ff065f2ede9c9cd03475411a2.zip |
Make constantize look down the ancestor chain (excluding Object)
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/constantize_test_cases.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activesupport/test/constantize_test_cases.rb b/activesupport/test/constantize_test_cases.rb index 135f894056..908f9e9a37 100644 --- a/activesupport/test/constantize_test_cases.rb +++ b/activesupport/test/constantize_test_cases.rb @@ -1,7 +1,14 @@ module Ace module Base class Case + class Dice + end end + class Fase < Case + end + end + class Gas + include Base end end @@ -9,6 +16,9 @@ module ConstantizeTestCases def run_constantize_tests_on assert_nothing_raised { assert_equal Ace::Base::Case, yield("Ace::Base::Case") } assert_nothing_raised { assert_equal Ace::Base::Case, yield("::Ace::Base::Case") } + assert_nothing_raised { assert_equal Ace::Base::Case::Dice, yield("Ace::Base::Case::Dice") } + assert_nothing_raised { assert_equal Ace::Base::Fase::Dice, yield("Ace::Base::Fase::Dice") } + assert_nothing_raised { assert_equal Ace::Gas::Case, yield("Ace::Gas::Case") } assert_nothing_raised { assert_equal ConstantizeTestCases, yield("ConstantizeTestCases") } assert_nothing_raised { assert_equal ConstantizeTestCases, yield("::ConstantizeTestCases") } assert_raise(NameError) { yield("UnknownClass") } @@ -18,11 +28,16 @@ module ConstantizeTestCases assert_raise(NameError) { yield("InvalidClass\n") } assert_raise(NameError) { yield("Ace::ConstantizeTestCases") } assert_raise(NameError) { yield("Ace::Base::ConstantizeTestCases") } + assert_raise(NameError) { yield("Ace::Gas::Base") } + assert_raise(NameError) { yield("Ace::Gas::ConstantizeTestCases") } end def run_safe_constantize_tests_on assert_nothing_raised { assert_equal Ace::Base::Case, yield("Ace::Base::Case") } assert_nothing_raised { assert_equal Ace::Base::Case, yield("::Ace::Base::Case") } + assert_nothing_raised { assert_equal Ace::Base::Case::Dice, yield("Ace::Base::Case::Dice") } + assert_nothing_raised { assert_equal Ace::Base::Fase::Dice, yield("Ace::Base::Fase::Dice") } + assert_nothing_raised { assert_equal Ace::Gas::Case, yield("Ace::Gas::Case") } assert_nothing_raised { assert_equal ConstantizeTestCases, yield("ConstantizeTestCases") } assert_nothing_raised { assert_equal ConstantizeTestCases, yield("::ConstantizeTestCases") } assert_nothing_raised { assert_equal nil, yield("UnknownClass") } @@ -33,6 +48,8 @@ module ConstantizeTestCases assert_nothing_raised { assert_equal nil, yield("blargle") } assert_nothing_raised { assert_equal nil, yield("Ace::ConstantizeTestCases") } assert_nothing_raised { assert_equal nil, yield("Ace::Base::ConstantizeTestCases") } + assert_nothing_raised { assert_equal nil, yield("Ace::Gas::Base") } + assert_nothing_raised { assert_equal nil, yield("Ace::Gas::ConstantizeTestCases") } assert_nothing_raised { assert_equal nil, yield("#<Class:0x7b8b718b>::Nested_1") } end end |