Class: Specwrk::CompletedStore

Inherits:
Store
  • Object
show all
Defined in:
lib/specwrk/store.rb

Instance Method Summary collapse

Methods inherited from Store

#[], #[]=, adapter_klass, #any?, #clear, #delete, #empty?, #initialize, #inspect, #keys, #length, #merge!, #multi_read, #reload, #to_h, with_lock

Constructor Details

This class inherits a constructor from Specwrk::Store

Instance Method Details

#dumpObject



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/specwrk/store.rb', line 281

def dump
  @run_times = []
  @first_started_at = Time.new(2999, 1, 1, 0, 0, 0) # TODO: Make future proof /s
  @last_finished_at = Time.new(1900, 1, 1, 0, 0, 0)

  @output = {
    file_totals: Hash.new { |h, filename| h[filename] = 0.0 },
    meta: {failures: 0, passes: 0, pending: 0},
    examples: {}
  }

  to_h.values.each { |example| calculate(example) }

  @output[:meta][:total_run_time] = @run_times.sum
  @output[:meta][:average_run_time] = @output[:meta][:total_run_time] / [@run_times.length, 1].max.to_f
  @output[:meta][:first_started_at] = @first_started_at.iso8601(6)
  @output[:meta][:last_finished_at] = @last_finished_at.iso8601(6)

  @output
end