Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.