Class: Ruptr::TestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/ruptr/result.rb,
lib/ruptr/runner.rb

Constant Summary collapse

VALID_STATUSES =

NOTE: Objects of this class will get dumped/loaded with Marshal.

%i[passed skipped failed blocked].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, exception: nil, assertions: 0, ineffective_assertions: 0, user_time: nil, system_time: nil, captured_stdout: nil, captured_stderr: nil) ⇒ TestResult

Returns a new instance of TestResult.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ruptr/result.rb', line 12

def initialize(status,
               exception: nil,
               assertions: 0, ineffective_assertions: 0,
               user_time: nil, system_time: nil,
               captured_stdout: nil, captured_stderr: nil)
  raise ArgumentError unless VALID_STATUSES.include?(status)
  raise ArgumentError if exception && status == :passed
  @status = status
  @exception = exception
  @assertions = assertions
  @ineffective_assertions = ineffective_assertions
  @user_time = user_time
  @system_time = system_time
  @captured_stdout = captured_stdout
  @captured_stderr = captured_stderr
end

Instance Attribute Details

#assertionsObject (readonly)

Returns the value of attribute assertions.



29
30
31
# File 'lib/ruptr/result.rb', line 29

def assertions
  @assertions
end

#captured_stderrObject (readonly)

Returns the value of attribute captured_stderr.



29
30
31
# File 'lib/ruptr/result.rb', line 29

def captured_stderr
  @captured_stderr
end

#captured_stdoutObject (readonly)

Returns the value of attribute captured_stdout.



29
30
31
# File 'lib/ruptr/result.rb', line 29

def captured_stdout
  @captured_stdout
end

#exceptionObject (readonly)

Returns the value of attribute exception.



29
30
31
# File 'lib/ruptr/result.rb', line 29

def exception
  @exception
end

#ineffective_assertionsObject (readonly)

Returns the value of attribute ineffective_assertions.



29
30
31
# File 'lib/ruptr/result.rb', line 29

def ineffective_assertions
  @ineffective_assertions
end

#statusObject (readonly)

Returns the value of attribute status.



29
30
31
# File 'lib/ruptr/result.rb', line 29

def status
  @status
end

#system_timeObject (readonly)

Returns the value of attribute system_time.



29
30
31
# File 'lib/ruptr/result.rb', line 29

def system_time
  @system_time
end

#user_timeObject (readonly)

Returns the value of attribute user_time.



29
30
31
# File 'lib/ruptr/result.rb', line 29

def user_time
  @user_time
end

Instance Method Details

#blocked?Boolean

Returns:

  • (Boolean)


38
# File 'lib/ruptr/result.rb', line 38

def blocked? = @status == :blocked

#captured_stderr?Boolean

Returns:

  • (Boolean)


43
# File 'lib/ruptr/result.rb', line 43

def captured_stderr? = @captured_stderr && !@captured_stderr.empty?

#captured_stdout?Boolean

Returns:

  • (Boolean)


42
# File 'lib/ruptr/result.rb', line 42

def captured_stdout? = @captured_stdout && !@captured_stdout.empty?

#failed?Boolean

Returns:

  • (Boolean)


37
# File 'lib/ruptr/result.rb', line 37

def failed? = @status == :failed

#make_marshallableObject



81
82
83
84
85
86
87
88
# File 'lib/ruptr/runner.rb', line 81

def make_marshallable
  return unless @exception
  begin
    Marshal.dump(@exception)
  rescue TypeError
    @exception = SurrogateException.from(@exception)
  end
end

#passed?Boolean

Returns:

  • (Boolean)


35
# File 'lib/ruptr/result.rb', line 35

def passed? = @status == :passed

#processor_timeObject



40
# File 'lib/ruptr/result.rb', line 40

def processor_time = !@user_time ? @system_time : !@system_time ? @user_time : @user_time + @system_time

#skipped?Boolean

Returns:

  • (Boolean)


36
# File 'lib/ruptr/result.rb', line 36

def skipped? = @status == :skipped