Class: Minitest::TestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/minitap/minitest5.rb

Overview

TestResult delegtes to Minitest’s own test result object.

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ TestResult

Create new TestResult instance.

result - MiniTest’s test result object.



644
645
646
# File 'lib/minitap/minitest5.rb', line 644

def initialize(result)
  @result = result
end

Instance Method Details

#assertionsObject

Number of assertions made by test.

Returns [Integer].



681
682
683
# File 'lib/minitap/minitest5.rb', line 681

def assertions
  @result.assertions
end

#exceptionObject



691
692
693
# File 'lib/minitap/minitest5.rb', line 691

def exception
  @result.failure
end

#labelObject



660
661
662
663
664
665
666
# File 'lib/minitap/minitest5.rb', line 660

def label
  if spec?
    name.sub(/^test_\d+_/, '').gsub('_', ' ')
  else
    name
  end
end

#nameObject Also known as: test

Name of the test.



654
655
656
# File 'lib/minitap/minitest5.rb', line 654

def name
  @result.name
end

#spec?Boolean

Is this a Minitest::Spec?

Returns [Boolean].

Returns:

  • (Boolean)


671
672
673
674
675
676
# File 'lib/minitap/minitest5.rb', line 671

def spec?
  @is_spec ||= (
    Minitest.const_defined?(:Spec) && @result.class < Minitest::Spec
    #@result.class.methods.include?(:it) || @result.class.methods.include?('it')
  )
end

#test_caseObject Also known as: testcase



648
649
650
# File 'lib/minitap/minitest5.rb', line 648

def test_case
  @result.class
end

#timeObject



686
687
688
# File 'lib/minitap/minitest5.rb', line 686

def time
  @result.time
end

#typeObject

Result type.



696
697
698
699
700
701
702
703
704
705
706
707
708
709
# File 'lib/minitap/minitest5.rb', line 696

def type
  case exception
  when UnexpectedError
    :err
  when Skip
    :skip
  when Assertion
    :fail
  when nil 
    :pass
  else 
    :err
  end
end