Class: Crucible::Tests::TestResult
- Inherits:
-
Object
- Object
- Crucible::Tests::TestResult
- Defined in:
- lib/test_result.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#data ⇒ Object
Returns the value of attribute data.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#key ⇒ Object
Returns the value of attribute key.
-
#links ⇒ Object
Returns the value of attribute links.
-
#message ⇒ Object
Returns the value of attribute message.
-
#requires ⇒ Object
Returns the value of attribute requires.
-
#status ⇒ Object
Returns the value of attribute status.
-
#validates ⇒ Object
Returns the value of attribute validates.
-
#warnings ⇒ Object
Returns the value of attribute warnings.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(key, description, status, message, data) ⇒ TestResult
constructor
A new instance of TestResult.
- #passed? ⇒ Boolean
- #to_hash ⇒ Object
- #update(status, message, data) ⇒ Object
Constructor Details
#initialize(key, description, status, message, data) ⇒ TestResult
Returns a new instance of TestResult.
17 18 19 20 21 22 23 |
# File 'lib/test_result.rb', line 17 def initialize(key, description, status, , data) @key = key @status = status @description = description @message = @data = data end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
15 16 17 |
# File 'lib/test_result.rb', line 15 def code @code end |
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/test_result.rb', line 10 def data @data end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/test_result.rb', line 7 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/test_result.rb', line 6 def id @id end |
#key ⇒ Object
Returns the value of attribute key.
5 6 7 |
# File 'lib/test_result.rb', line 5 def key @key end |
#links ⇒ Object
Returns the value of attribute links.
14 15 16 |
# File 'lib/test_result.rb', line 14 def links @links end |
#message ⇒ Object
Returns the value of attribute message.
9 10 11 |
# File 'lib/test_result.rb', line 9 def @message end |
#requires ⇒ Object
Returns the value of attribute requires.
12 13 14 |
# File 'lib/test_result.rb', line 12 def requires @requires end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/test_result.rb', line 8 def status @status end |
#validates ⇒ Object
Returns the value of attribute validates.
13 14 15 |
# File 'lib/test_result.rb', line 13 def validates @validates end |
#warnings ⇒ Object
Returns the value of attribute warnings.
11 12 13 |
# File 'lib/test_result.rb', line 11 def warnings @warnings end |
Instance Method Details
#failed? ⇒ Boolean
36 37 38 |
# File 'lib/test_result.rb', line 36 def failed? !self.passed? end |
#passed? ⇒ Boolean
32 33 34 |
# File 'lib/test_result.rb', line 32 def passed? return ( (@status==true) or (@status=='passed') ) end |
#to_hash ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/test_result.rb', line 40 def to_hash hash = {} hash['key'] = @key hash['id'] = @id || @key hash['description'] = force_encoding(@description) hash['status'] = force_encoding(@status) if @message.class == Array hash['message'] = @message.map { |m| force_encoding(m) } else hash['message'] = force_encoding(@message) end hash['data'] = force_encoding(@data) unless hash['status'] == 'pass' hash['warnings'] = warnings if warnings hash['requires'] = requires if requires hash['validates'] = validates if validates hash['links'] = links if links hash['code'] = @code hash end |
#update(status, message, data) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/test_result.rb', line 25 def update(status, , data) @status = status @message = @data = data self end |