Sha256: 9d27b723cd556579470ab80ab8ff3a321ea35052179edddc1c643d9044b7af53

Contents?: true

Size: 1.05 KB

Versions: 17

Compression:

Stored size: 1.05 KB

Contents

class TestRunStatistics

  def initialize(project)
    @project = project
  end

  attr_reader :project

  def last_completed_test_runs(n)
    project.test_runs.where("total_count > 0").limit(n)
  end


  def duration(n=20)
    durations = last_completed_test_runs(n).pluck(:duration).map { |n| n / 1000.0 }
    ljust(durations, 0, n).reverse
  end


  def coverage(n=20)
    percentages = last_completed_test_runs(n).pluck(:covered_percent).map { |n| n * 100.0 }
    ljust(percentages, 0.0, n).reverse
  end



  def tests(n=20)
    [ skips(n), regressions(n), fails(n), passes(n) ]
  end

  def skips(n=20)
    ljust(last_completed_test_runs(n).pluck(:skip_count), 0, n).reverse
  end

  def regressions(n=20)
    ljust(last_completed_test_runs(n).pluck(:regression_count), 0, n).reverse
  end

  def fails(n=20)
    ljust(last_completed_test_runs(n).pluck(:fail_count), 0, n).reverse
  end

  def passes(n=20)
    ljust(last_completed_test_runs(n).pluck(:pass_count), 0, n).reverse
  end



  def ljust(array, value, n)
    array.dup.fill(value, array.length...n)
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
houston-core-0.8.0.pre app/models/test_run_statistics.rb
houston-core-0.7.0 app/models/test_run_statistics.rb
houston-core-0.7.0.beta4 app/models/test_run_statistics.rb
houston-core-0.7.0.beta3 app/models/test_run_statistics.rb
houston-core-0.7.0.beta2 app/models/test_run_statistics.rb
houston-core-0.7.0.beta app/models/test_run_statistics.rb
houston-core-0.6.3 app/models/test_run_statistics.rb
houston-core-0.6.2 app/models/test_run_statistics.rb
houston-core-0.6.1 app/models/test_run_statistics.rb
houston-core-0.6.0 app/models/test_run_statistics.rb
houston-core-0.5.6 app/models/test_run_statistics.rb
houston-core-0.5.5 app/models/test_run_statistics.rb
houston-core-0.5.4 app/models/test_run_statistics.rb
houston-core-0.5.3 app/models/test_run_statistics.rb
houston-core-0.5.2 app/models/test_run_statistics.rb
houston-core-0.5.1 app/models/test_run_statistics.rb
houston-core-0.5.0 app/models/test_run_statistics.rb