public
Created

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
diff --git a/kernel/common/module.rb b/kernel/common/module.rb
index cd463b8..fe15498 100644
--- a/kernel/common/module.rb
+++ b/kernel/common/module.rb
@@ -396,6 +396,8 @@ class Module
raise TypeError, "wrong argument type #{mod.class} (expected Module)"
end
+ return false if self.equal?(mod)
+
_each_ancestor { |m| return true if mod.equal?(m) }
false
diff --git a/spec/ruby/core/module/include_spec.rb b/spec/ruby/core/module/include_spec.rb
index 799226e..333d2b4 100644
--- a/spec/ruby/core/module/include_spec.rb
+++ b/spec/ruby/core/module/include_spec.rb
@@ -263,6 +263,10 @@ describe "Module#include?" do
ModuleSpecs::Basic.include?(ModuleSpecs::Super).should == false
end
+ it "returns false if given module is equal to self" do
+ ModuleSpecs.include?(ModuleSpecs).should == false
+ end
+
it "raises a TypeError when no module was given" do
lambda { ModuleSpecs::Child.include?("Test") }.should raise_error(TypeError)
lambda { ModuleSpecs::Child.include?(ModuleSpecs::Parent) }.should raise_error(TypeError)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.