Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created November 6, 2012 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/4024158 to your computer and use it in GitHub Desktop.
Save tenderlove/4024158 to your computer and use it in GitHub Desktop.
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