Class: Test::Unit::Assertions::AssertionMessage::MaybeContainer

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

Instance Method Summary collapse

Constructor Details

#initialize(value, &formatter) ⇒ MaybeContainer

Returns a new instance of MaybeContainer.



1794
1795
1796
1797
# File 'lib/test/unit/assertions.rb', line 1794

def initialize(value, &formatter)
  @value = value
  @formatter = formatter
end

Instance Method Details

#inspectObject



1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
# File 'lib/test/unit/assertions.rb', line 1799

def inspect
  if @value.is_a?(Array)
    values = @value.collect do |value|
      @formatter.call(AssertionMessage.convert(value))
    end
    "[#{values.join(', ')}]"
  else
    @formatter.call(AssertionMessage.convert(@value))
  end
end