Created
November 6, 2012 11:35
-
-
Save tenderlove/4024158 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require 'active_support/core_ext/string/inflections' | |
module Ace | |
module Base | |
class Case | |
class Dice | |
end | |
end | |
class Fase < Case | |
end | |
end | |
end | |
module ConstantizeTestCases | |
end | |
class AnnoyingBehaviorTest < MiniTest::Unit::TestCase | |
### | |
# This test seems to show that the const_get inherits. `Dice` isn't defined | |
# in `Fase`, but in it's super class `Case`. | |
def test_inherits | |
assert_equal Ace::Base::Fase::Dice, "Ace::Base::Fase::Dice".constantize | |
assert_equal Ace::Base::Fase::Dice, Ace::Base::Fase.const_get('Dice') | |
end | |
### | |
# This test seems to show that the const_get *does not* inherit. `Ace` has | |
# a superclass of `Object`, and `ConstantizeTestCases` is defined on | |
# `Object` | |
def test_does_not_inherit | |
assert_raises(NameError) { | |
"Ace::ConstantizeTestCases".constantize | |
} | |
assert_equal ConstantizeTestCases, Ace.const_get('ConstantizeTestCases') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment