Class: RoxClient::TestRun
- Inherits:
-
Object
- Object
- RoxClient::TestRun
- Defined in:
- lib/rox-client-ruby/test_run.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#uid ⇒ Object
Returns the value of attribute uid.
Instance Method Summary collapse
- #add_result(options = {}) ⇒ Object
-
#initialize(project) ⇒ TestRun
constructor
A new instance of TestRun.
- #results_by_key ⇒ Object
- #results_without_key ⇒ Object
- #to_h(options = {}) ⇒ Object
Constructor Details
#initialize(project) ⇒ TestRun
Returns a new instance of TestRun.
7 8 9 10 |
# File 'lib/rox-client-ruby/test_run.rb', line 7 def initialize project @results = [] @project = project end |
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
5 6 7 |
# File 'lib/rox-client-ruby/test_run.rb', line 5 def duration @duration end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
4 5 6 |
# File 'lib/rox-client-ruby/test_run.rb', line 4 def project @project end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
4 5 6 |
# File 'lib/rox-client-ruby/test_run.rb', line 4 def results @results end |
#uid ⇒ Object
Returns the value of attribute uid.
5 6 7 |
# File 'lib/rox-client-ruby/test_run.rb', line 5 def uid @uid end |
Instance Method Details
#add_result(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/rox-client-ruby/test_run.rb', line 12 def add_result = {} if [:grouped] && existing_result = @results.find{ |r| r.grouped? && r.key == [:key] } existing_result.update else @results << TestResult.new(@project, ) end end |
#results_by_key ⇒ Object
25 26 27 28 29 30 |
# File 'lib/rox-client-ruby/test_run.rb', line 25 def results_by_key @results.inject({}) do |memo,r| (memo[r.key] ||= []) << r unless !r.key or r.key.to_s.strip.empty? memo end end |
#results_without_key ⇒ Object
21 22 23 |
# File 'lib/rox-client-ruby/test_run.rb', line 21 def results_without_key @results.select{ |r| !r.key or r.key.to_s.strip.empty? } end |
#to_h(options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rox-client-ruby/test_run.rb', line 32 def to_h = {} validate! { 'd' => @duration, 'r' => [ { 'j' => @project.api_id, 'v' => @project.version, 't' => @results.collect{ |r| r.to_h } } ] }.tap do |h| h['u'] = @uid if @uid end end |