Class: Defekt::Runner

Inherits:
Object show all
Defined in:
lib/defekt/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection) ⇒ Runner

Returns a new instance of Runner.



7
8
9
# File 'lib/defekt/runner.rb', line 7

def initialize(collection)
  @collection = collection
end

Instance Attribute Details

#benchmarkObject (readonly)

Returns the value of attribute benchmark.



5
6
7
# File 'lib/defekt/runner.rb', line 5

def benchmark
  @benchmark
end

#collectionObject (readonly)

Returns the value of attribute collection.



5
6
7
# File 'lib/defekt/runner.rb', line 5

def collection
  @collection
end

Instance Method Details

#reportObject



18
19
20
21
22
23
# File 'lib/defekt/runner.rb', line 18

def report
  puts nil, nil
  puts report_broken, nil if collection.broken.any?
  puts statistics
  self
end

#runObject



11
12
13
14
15
16
# File 'lib/defekt/runner.rb', line 11

def run
  @benchmark = Benchmark.measure do
    collection.all.shuffle.each { |test| print test.run }
  end
  self
end

#statisticsObject



25
26
27
28
29
# File 'lib/defekt/runner.rb', line 25

def statistics
  "#{collection.passed.length} passed, #{collection.failed.length} failed" +
    ", #{collection.errored.length} errored of #{collection.all.length} " +
    "tests (in #{benchmark.real.round(3)} seconds)"
end