Class: QUnited::QUnitTestResult
- Inherits:
-
Object
- Object
- QUnited::QUnitTestResult
- Defined in:
- lib/qunited/qunit_test_result.rb
Overview
Contains results data from a QUnit JavaScript test. Useful for passing data to formatters.
Defined Under Namespace
Classes: AssertionResult
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #assertions ⇒ Object
- #error? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(test_data) ⇒ QUnitTestResult
constructor
A new instance of QUnitTestResult.
- #passed? ⇒ Boolean
- #result ⇒ Object
Constructor Details
#initialize(test_data) ⇒ QUnitTestResult
Returns a new instance of QUnitTestResult.
44 45 46 |
# File 'lib/qunited/qunit_test_result.rb', line 44 def initialize(test_data) @data = test_data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
42 43 44 |
# File 'lib/qunited/qunit_test_result.rb', line 42 def data @data end |
Class Method Details
.from_json(json) ⇒ Object
38 39 40 |
# File 'lib/qunited/qunit_test_result.rb', line 38 def self.from_json(json) self.new clean_up_result(::YAML.load(json)) end |
Instance Method Details
#assertions ⇒ Object
60 61 62 |
# File 'lib/qunited/qunit_test_result.rb', line 60 def assertions @assertions ||= data[:assertion_data].map { |assertion_data| AssertionResult.new assertion_data } end |
#error? ⇒ Boolean
50 |
# File 'lib/qunited/qunit_test_result.rb', line 50 def error?; result == :error end |
#failed? ⇒ Boolean
49 |
# File 'lib/qunited/qunit_test_result.rb', line 49 def failed?; result == :failed end |
#passed? ⇒ Boolean
48 |
# File 'lib/qunited/qunit_test_result.rb', line 48 def passed?; result == :passed end |
#result ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/qunited/qunit_test_result.rb', line 52 def result @result ||= if assertions.find { |a| a.error? } :error else assertions.find { |a| a.failed? } ? :failed : :passed end end |