123456789_123456789_123456789_123456789_123456789_

Class: Test::Unit::Assertions::AssertExceptionHelper::WrappedException

Relationships & Source Files
Inherits: Object
Defined in: lib/test/unit/assertions.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(exception) ⇒ WrappedException

[ GitHub ]

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

def initialize(exception)
  @exception = exception
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block)

[ GitHub ]

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

def method_missing(name, *args, &block)
  @exception.__send__(name, *args, &block)
end

Instance Attribute Details

#default_inspect?Boolean (readonly, private)

[ GitHub ]

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

def default_inspect?
  inspect_method = @exception.method(:inspect)
  if inspect_method.respond_to?(:owner) and
      inspect_method.owner == Exception
    true
  else
    default_inspect_method = Exception.instance_method(:inspect)
    default_inspect_method.bind(@exception).call == @exception.inspect
  end
end

#exception (readonly)

[ GitHub ]

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

attr_reader :exception

Instance Method Details

#inspect

[ GitHub ]

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

def inspect
  if default_inspect?
    inspected = "#{@exception.class.inspect}(<#{@exception.message}>)"
    unless (@exception.backtrace || []).empty?
      inspected += "\n"
      @exception.backtrace.each do |trace|
        inspected << "#{trace}\n"
      end
    end
    inspected
  else
    @exception.inspect
  end
end