summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-06 13:56:58 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-06 13:56:58 +0000
commit7387c08373a9421356da2581b1035903ac0a301a (patch)
treea4e3baed84a314430ecdb21402c3081404edaadd /spec
parent5e7167f8fb954ec46eb12a4a0a1191a8f7d9543d (diff)
const_missing on private constants
* variable.c (rb_const_search): call #const_missing method on private constants, as well as uninitialized constants. [Feature #14328] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/language/constants_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/ruby/language/constants_spec.rb b/spec/ruby/language/constants_spec.rb
index 4f9429c126..49ff8844af 100644
--- a/spec/ruby/language/constants_spec.rb
+++ b/spec/ruby/language/constants_spec.rb
@@ -458,6 +458,18 @@ describe "Module#private_constant marked constants" do
lambda {mod::Foo}.should raise_error(NameError)
end
+ it "sends #const_missing to the original class or module" do
+ mod = Module.new
+ mod.const_set :Foo, true
+ mod.send :private_constant, :Foo
+ def mod.const_missing(name)
+ @const_missing_arg = name
+ name == :Foo ? name : super
+ end
+
+ mod::Foo.should == :Foo
+ end
+
describe "in a module" do
it "cannot be accessed from outside the module" do
lambda do