Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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)"
+ return false if self.equal?(mod)
_each_ancestor { |m| return true if mod.equal?(m) }
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
+ 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment