I would like to test whether a class inherits from another class, but there doesn\'t seem to exist a method for that.
class A end class B < A end B.is_a? A
Also available:
B.ancestors.include? A
This differs slightly from the (shorter) answer of B < A because B is included in B.ancestors:
B < A
B
B.ancestors
B.ancestors #=> [B, A, Object, Kernel, BasicObject] B < B #=> false B.ancestors.include? B #=> true
Whether or not this is desirable depends on your use case.