Sha256: 594c0d4bf271d89c4aa696a484da044c38e64b3e3c034634e870229c8295f6fc

Contents?: true

Size: 851 Bytes

Versions: 6

Compression:

Stored size: 851 Bytes

Contents

require 'benchmark'

module Defekt
  class Runner
    attr_reader :collection, :benchmark

    def initialize(collection)
      @collection = collection
    end

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

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

    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

    private

    def report_broken
      collection.broken.flat_map do |test|
        [test.summary, "  #{test.error.message}"]
      end.join("\n")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
defekt-0.0.7 lib/defekt/runner.rb
defekt-0.0.6 lib/defekt/runner.rb
defekt-0.0.5 lib/defekt/runner.rb
defekt-0.0.4 lib/defekt/runner.rb
defekt-0.0.3 lib/defekt/runner.rb
defekt-0.0.2 lib/defekt/runner.rb