Class: Rproof::TestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/rproof/test_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description) ⇒ TestResult

Returns a new instance of TestResult.



5
6
7
8
9
10
11
# File 'lib/rproof/test_result.rb', line 5

def initialize(name, description)
  @name = name
  @description = description
  @assertions = []
  @warnings = []
  @exceptions = []
end

Instance Attribute Details

#assertionsObject (readonly)

Returns the value of attribute assertions.



12
13
14
# File 'lib/rproof/test_result.rb', line 12

def assertions
  @assertions
end

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/rproof/test_result.rb', line 12

def description
  @description
end

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



12
13
14
# File 'lib/rproof/test_result.rb', line 12

def exceptions
  @exceptions
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/rproof/test_result.rb', line 12

def name
  @name
end

#warningsObject (readonly)

Returns the value of attribute warnings.



12
13
14
# File 'lib/rproof/test_result.rb', line 12

def warnings
  @warnings
end

Class Method Details

.get_worse_status(status_1, status_2) ⇒ Object

Return worse status between the two



53
54
55
56
57
58
59
60
61
# File 'lib/rproof/test_result.rb', line 53

def self.get_worse_status(status_1, status_2)
  if [status_1, status_2].include? :exception
    :exception
  elsif [status_1, status_2].include? :failed
    :failed
  else
    :succeed
  end
end

Instance Method Details

#add_assertion(assertion) ⇒ Object



14
15
16
# File 'lib/rproof/test_result.rb', line 14

def add_assertion(assertion)
  @assertions << assertion
end

#add_exception(exception) ⇒ Object



22
23
24
# File 'lib/rproof/test_result.rb', line 22

def add_exception(exception)
  @exceptions << exception
end

#add_warning(warning) ⇒ Object



18
19
20
# File 'lib/rproof/test_result.rb', line 18

def add_warning(warning)
  @warnings << warning
end

#failuresObject



38
39
40
# File 'lib/rproof/test_result.rb', line 38

def failures
  @assertions.select { |assertion| not assertion.is_successful }
end

#failures_nbObject



30
31
32
# File 'lib/rproof/test_result.rb', line 30

def failures_nb
  failures.count
end

#statusObject



42
43
44
45
46
47
48
49
50
# File 'lib/rproof/test_result.rb', line 42

def status
  if @exceptions.count > 0
    :exception
  elsif failures_nb > 0
    :failed
  else
    :succeed
  end
end

#successesObject



34
35
36
# File 'lib/rproof/test_result.rb', line 34

def successes
  @assertions.select { |assertion| assertion.is_successful }
end

#successes_nbObject



26
27
28
# File 'lib/rproof/test_result.rb', line 26

def successes_nb
  successes.count
end