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

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

Defined Under Namespace

Classes: WrappedException

Instance Method Summary collapse

Constructor Details

#initialize(test_case, expected_exceptions) ⇒ AssertExceptionHelper

Returns a new instance of AssertExceptionHelper.



1762
1763
1764
1765
1766
1767
# File 'lib/test/unit/assertions.rb', line 1762

def initialize(test_case, expected_exceptions)
  @test_case = test_case
  @expected_exceptions = expected_exceptions
  @expected_classes, @expected_modules, @expected_objects =
    split_expected_exceptions(expected_exceptions)
end

Instance Method Details

#expected?(actual_exception, equality = nil) ⇒ Boolean

Returns:

  • (Boolean)


1784
1785
1786
1787
1788
1789
# File 'lib/test/unit/assertions.rb', line 1784

def expected?(actual_exception, equality=nil)
  equality ||= :instance_of?
  expected_class?(actual_exception, equality) or
    expected_module?(actual_exception) or
    expected_object?(actual_exception)
end

#expected_exceptionsObject



1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
# File 'lib/test/unit/assertions.rb', line 1769

def expected_exceptions
  exceptions = @expected_exceptions.collect do |exception|
    if exception.is_a?(Exception)
      WrappedException.new(exception)
    else
      exception
    end
  end
  if exceptions.size == 1
    exceptions[0]
  else
    exceptions
  end
end