Issue #5876 has been reported by Nick Gunther.

----------------------------------------
Bug #5876: Within one module, including second module in a class causes errors in class equivalence ('object.class ==' is wrong)
https://bugs.ruby-lang.org/issues/5876

Author: Nick Gunther
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]


If within one module, another module is included in a class, including a built-in class like Array, the equivalence operators '==' and '!=' for that class produce errors.  The general form that produces the error is:
module Module1
     class C
           include Module2
     end
end
c = Module1::C.new
puts (c.class == C ? 'correct' : 'incorrect')

produces 'incorrect'

The output from the attached code illustrates the problem with the built-in class Array:
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
FIRST: Testing Within a Module: Displays the Problem and the Workaround
 = Converting to Strings

Compare the results for Testing Equivalences of 
Classes and Classes Converted to String:
******
Testing Class Equivalence:
The class is an array: Array
But we're in the branch where array class equivalence
tested false, so there's a problem!
WORKAROUND: Testing Equivalence After Converting to Strings:
No Problem
SECOND: Testing Outside a Module: No problem

Class and Class Converted to String:
******
Testing Class Equivalence
No Problem
Testing Equivalence After Converting to Strings
No Problem


-- 
http://bugs.ruby-lang.org/