summaryrefslogtreecommitdiff
path: root/spec/ruby/language/module_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/module_spec.rb')
-rw-r--r--spec/ruby/language/module_spec.rb32
1 files changed, 28 insertions, 4 deletions
diff --git a/spec/ruby/language/module_spec.rb b/spec/ruby/language/module_spec.rb
index 4db00bd7fb..fba4aa8c6e 100644
--- a/spec/ruby/language/module_spec.rb
+++ b/spec/ruby/language/module_spec.rb
@@ -31,10 +31,34 @@ describe "The module keyword" do
end
it "does not reopen a module included in Object" do
- module IncludedModuleSpecs; Reopened = true; end
- ModuleSpecs::IncludedInObject::IncludedModuleSpecs.should_not == Object::IncludedModuleSpecs
- ensure
- IncludedModuleSpecs.send(:remove_const, :Reopened)
+ ruby_exe(<<~RUBY).should == "false"
+ module IncludedInObject
+ module IncludedModule; end
+ end
+ class Object
+ include IncludedInObject
+ end
+ module IncludedModule; end
+ print IncludedInObject::IncludedModule == Object::IncludedModule
+ RUBY
+ end
+
+ it "does not reopen a module included in non-Object modules" do
+ ruby_exe(<<~RUBY).should == "false/false"
+ module Included
+ module IncludedModule; end
+ end
+ module M
+ include Included
+ module IncludedModule; end
+ end
+ class C
+ include Included
+ module IncludedModule; end
+ end
+ print Included::IncludedModule == M::IncludedModule, "/",
+ Included::IncludedModule == C::IncludedModule
+ RUBY
end
it "raises a TypeError if the constant is a Class" do