Class: Res::IR
- Inherits:
-
Object
- Object
- Res::IR
- Defined in:
- lib/res/ir.rb
Instance Attribute Summary collapse
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#hive_job_id ⇒ Object
Returns the value of attribute hive_job_id.
-
#project ⇒ Object
Returns the value of attribute project.
-
#results ⇒ Object
Returns the value of attribute results.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#suite ⇒ Object
Returns the value of attribute suite.
-
#target ⇒ Object
Returns the value of attribute target.
-
#type ⇒ Object
Returns the value of attribute type.
-
#values ⇒ Object
Returns the value of attribute values.
-
#world ⇒ Object
Returns the value of attribute world.
Class Method Summary collapse
Instance Method Summary collapse
- #count(status) ⇒ Object
-
#flat_format ⇒ Object
Returns a simple array of test information [ { :name => ‘test1’, :urn => ‘file/tests.t:32’, :status => ‘passed’, :time => 12.04 }, { :name => ‘test2’, :urn => ‘file/tests.t:36’, :status => ‘failed’, :time => } ].
-
#initialize(options = {}) ⇒ IR
constructor
Expects hash of: :results => { } :type => test_runner :start_time => Time the tests started :end_time => Time they completed.
- #initialize_values(initial_values, results_hash) ⇒ Object
-
#json ⇒ Object
Dump as json.
-
#tests ⇒ Object
Pluck out the actual test nodes from the contexts.
Constructor Details
#initialize(options = {}) ⇒ IR
Expects hash of: :results => { } :type => test_runner :start_time => Time the tests started :end_time => Time they completed
19 20 21 22 23 24 25 |
# File 'lib/res/ir.rb', line 19 def initialize( = {} ) @results = [:results] or raise "No results data" @type = [:type] or raise "No type provided (e.g. 'Cucumber')" @started = [:started] or raise "Need to provide a start time" @finished = [:finished] or raise "Need to provide an end time" @values = initialize_values( [:values], [:results] ) end |
Instance Attribute Details
#end_time ⇒ Object
Returns the value of attribute end_time.
5 6 7 |
# File 'lib/res/ir.rb', line 5 def end_time @end_time end |
#hash ⇒ Object
Returns the value of attribute hash.
5 6 7 |
# File 'lib/res/ir.rb', line 5 def hash @hash end |
#hive_job_id ⇒ Object
Returns the value of attribute hive_job_id.
6 7 8 |
# File 'lib/res/ir.rb', line 6 def hive_job_id @hive_job_id end |
#project ⇒ Object
Returns the value of attribute project.
6 7 8 |
# File 'lib/res/ir.rb', line 6 def project @project end |
#results ⇒ Object
Returns the value of attribute results.
5 6 7 |
# File 'lib/res/ir.rb', line 5 def results @results end |
#start_time ⇒ Object
Returns the value of attribute start_time.
5 6 7 |
# File 'lib/res/ir.rb', line 5 def start_time @start_time end |
#suite ⇒ Object
Returns the value of attribute suite.
6 7 8 |
# File 'lib/res/ir.rb', line 6 def suite @suite end |
#target ⇒ Object
Returns the value of attribute target.
6 7 8 |
# File 'lib/res/ir.rb', line 6 def target @target end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/res/ir.rb', line 5 def type @type end |
#values ⇒ Object
Returns the value of attribute values.
5 6 7 |
# File 'lib/res/ir.rb', line 5 def values @values end |
#world ⇒ Object
Returns the value of attribute world.
5 6 7 |
# File 'lib/res/ir.rb', line 5 def world @world end |
Class Method Details
Instance Method Details
#count(status) ⇒ Object
66 67 68 |
# File 'lib/res/ir.rb', line 66 def count(status) tests.count { |t| t[:status].to_sym == status.to_sym } end |
#flat_format ⇒ Object
Returns a simple array of test information [ { :name => ‘test1’, :urn => ‘file/tests.t:32’, :status => ‘passed’, :time => 12.04 },
{ :name => 'test2', :urn => 'file/tests.t:36', :status => 'failed', :time => } ]
73 74 75 76 77 78 79 |
# File 'lib/res/ir.rb', line 73 def flat_format self.tests.collect do |t| { :name => t[:name], :urn => t[:urn], :status => t[:status] } end end |
#initialize_values(initial_values, results_hash) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/res/ir.rb', line 27 def initialize_values( initial_values, results_hash ) h = {} if initial_values && !initial_values.empty? initial_values.each do |k,v| h[k.to_s] = v end end IR.find_values( results_hash ).each do |i| if !i.empty? i.each do |k,v| h[k.to_s] = v end end end h end |
#json ⇒ Object
Dump as json
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/res/ir.rb', line 47 def json hash = { :started => @started, :finished => @finished, :results => @results, :type => @type } # Merge in the world information if it's available hash[:world] = world if world hash[:hive_job_id] = hive_job_id if hive_job_id JSON.pretty_generate( hash ) end |
#tests ⇒ Object
Pluck out the actual test nodes from the contexts
62 63 64 |
# File 'lib/res/ir.rb', line 62 def tests IR.find_tests(results).flatten end |