summaryrefslogtreecommitdiff
path: root/spec/ruby/core/module/const_missing_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/module/const_missing_spec.rb')
-rw-r--r--spec/ruby/core/module/const_missing_spec.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/spec/ruby/core/module/const_missing_spec.rb b/spec/ruby/core/module/const_missing_spec.rb
index 24f2b49edc..80a2caccab 100644
--- a/spec/ruby/core/module/const_missing_spec.rb
+++ b/spec/ruby/core/module/const_missing_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../../../fixtures/constants', __FILE__)
+require_relative '../../spec_helper'
+require_relative '../../fixtures/constants'
describe "Module#const_missing" do
it "is called when an undefined constant is referenced via literal form" do
@@ -11,9 +11,9 @@ describe "Module#const_missing" do
end
it "raises NameError and includes the name of the value that wasn't found" do
- lambda {
+ -> {
ConstantSpecs.const_missing("HelloMissing")
- }.should raise_error(NameError, /ConstantSpecs::HelloMissing/)
+ }.should.raise(NameError, /ConstantSpecs::HelloMissing/)
end
it "raises NameError and does not include toplevel Object" do
@@ -24,4 +24,13 @@ describe "Module#const_missing" do
end
end
+ it "is called regardless of visibility" do
+ klass = Class.new do
+ def self.const_missing(name)
+ "Found:#{name}"
+ end
+ private_class_method :const_missing
+ end
+ klass::Hello.should == 'Found:Hello'
+ end
end