Class: ProbeDockRSpec::TestRun
- Inherits:
-
Object
- Object
- ProbeDockRSpec::TestRun
- Defined in:
- lib/probe_dock_rspec/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(example, groups = [], 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.
8 9 10 11 |
# File 'lib/probe_dock_rspec/test_run.rb', line 8 def initialize project @results = [] @project = project end |
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
6 7 8 |
# File 'lib/probe_dock_rspec/test_run.rb', line 6 def duration @duration end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
5 6 7 |
# File 'lib/probe_dock_rspec/test_run.rb', line 5 def project @project end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
5 6 7 |
# File 'lib/probe_dock_rspec/test_run.rb', line 5 def results @results end |
#uid ⇒ Object
Returns the value of attribute uid.
6 7 8 |
# File 'lib/probe_dock_rspec/test_run.rb', line 6 def uid @uid end |
Instance Method Details
#add_result(example, groups = [], options = {}) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/probe_dock_rspec/test_run.rb', line 13 def add_result example, groups = [], = {} if TestResult.extract_grouped(example, groups) and (existing_result = @results.find{ |r| r.grouped? && r.key == TestResult.extract_key(example, groups) }) existing_result.update else @results << TestResult.new(@project, example, groups, ) end end |
#results_by_key ⇒ Object
25 26 27 28 29 30 |
# File 'lib/probe_dock_rspec/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/probe_dock_rspec/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 |
# File 'lib/probe_dock_rspec/test_run.rb', line 32 def to_h = {} validate! { 'projectId' => @project.api_id, 'version' => @project.version, 'duration' => @duration, 'results' => @results.collect{ |r| r.to_h } }.tap do |h| h['reports'] = [ { 'uid' => @uid } ] if @uid end end |