Class: Test::Unit::Assertions::AssertionMessage::Inspector

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/test/unit/assertions.rb

Constant Summary collapse

@@inspector_classes =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, inspected_objects = {}) ⇒ Inspector

Returns a new instance of Inspector.



1643
1644
1645
1646
1647
1648
# File 'lib/test/unit/assertions.rb', line 1643

def initialize(object, inspected_objects={})
  @inspected_objects = inspected_objects
  @object = object
  @inspected_objects[@object.object_id] = self
  @inspect_target = inspect_target
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



1642
1643
1644
# File 'lib/test/unit/assertions.rb', line 1642

def object
  @object
end

Class Method Details

.cached_new(object, inspected_objects) ⇒ Object



1623
1624
1625
1626
# File 'lib/test/unit/assertions.rb', line 1623

def cached_new(object, inspected_objects)
  inspected_objects[object.object_id] ||=
    new(object, inspected_objects)
end

.inspector_classesObject



1629
1630
1631
# File 'lib/test/unit/assertions.rb', line 1629

def inspector_classes
  @@inspector_classes
end

.register_inspector_class(inspector_class) ⇒ Object



1633
1634
1635
# File 'lib/test/unit/assertions.rb', line 1633

def register_inspector_class(inspector_class)
  @@inspector_classes << inspector_class
end

.unregister_inspector_class(inspector_class) ⇒ Object



1637
1638
1639
# File 'lib/test/unit/assertions.rb', line 1637

def unregister_inspector_class(inspector_class)
  @@inspector_classes.delete(inspector_class)
end

Instance Method Details

#<=>(other) ⇒ Object



1663
1664
1665
1666
1667
1668
1669
# File 'lib/test/unit/assertions.rb', line 1663

def <=>(other)
  if other.is_a?(self.class)
    @object <=> other.object
  else
    @object <=> other
  end
end

#inspectObject



1651
1652
1653
# File 'lib/test/unit/assertions.rb', line 1651

def inspect
  @inspect_target.inspect
end

#native_inspectObject



1650
# File 'lib/test/unit/assertions.rb', line 1650

alias_method :native_inspect, :inspect

#pretty_print(q) ⇒ Object



1655
1656
1657
# File 'lib/test/unit/assertions.rb', line 1655

def pretty_print(q)
  @inspect_target.pretty_print(q)
end

#pretty_print_cycle(q) ⇒ Object



1659
1660
1661
# File 'lib/test/unit/assertions.rb', line 1659

def pretty_print_cycle(q)
  @inspect_target.pretty_print_cycle(q)
end