Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.