Class: Rproof::TestResult
- Inherits:
-
Object
- Object
- Rproof::TestResult
- Defined in:
- lib/rproof/test_result.rb
Instance Attribute Summary collapse
-
#assertions ⇒ Object
readonly
Returns the value of attribute assertions.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#exceptions ⇒ Object
readonly
Returns the value of attribute exceptions.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
-
.get_worse_status(status_1, status_2) ⇒ Object
Return worse status between the two.
Instance Method Summary collapse
- #add_assertion(assertion) ⇒ Object
- #add_exception(exception) ⇒ Object
- #add_warning(warning) ⇒ Object
- #failures ⇒ Object
- #failures_nb ⇒ Object
-
#initialize(name, description) ⇒ TestResult
constructor
A new instance of TestResult.
- #status ⇒ Object
- #successes ⇒ Object
- #successes_nb ⇒ Object
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
#assertions ⇒ Object (readonly)
Returns the value of attribute assertions.
12 13 14 |
# File 'lib/rproof/test_result.rb', line 12 def assertions @assertions end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/rproof/test_result.rb', line 12 def description @description end |
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions.
12 13 14 |
# File 'lib/rproof/test_result.rb', line 12 def exceptions @exceptions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/rproof/test_result.rb', line 12 def name @name end |
#warnings ⇒ Object (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 |
#failures ⇒ Object
38 39 40 |
# File 'lib/rproof/test_result.rb', line 38 def failures @assertions.select { |assertion| not assertion.is_successful } end |
#failures_nb ⇒ Object
30 31 32 |
# File 'lib/rproof/test_result.rb', line 30 def failures_nb failures.count end |
#status ⇒ Object
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 |
#successes ⇒ Object
34 35 36 |
# File 'lib/rproof/test_result.rb', line 34 def successes @assertions.select { |assertion| assertion.is_successful } end |
#successes_nb ⇒ Object
26 27 28 |
# File 'lib/rproof/test_result.rb', line 26 def successes_nb successes.count end |