Class: TestRunStatistics
- Inherits:
-
Object
- Object
- TestRunStatistics
- Defined in:
- app/models/test_run_statistics.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #coverage(n = 20) ⇒ Object
- #duration(n = 20) ⇒ Object
- #fails(n = 20) ⇒ Object
-
#initialize(project) ⇒ TestRunStatistics
constructor
A new instance of TestRunStatistics.
- #last_completed_test_runs(n) ⇒ Object
- #ljust(array, value, n) ⇒ Object
- #passes(n = 20) ⇒ Object
- #regressions(n = 20) ⇒ Object
- #skips(n = 20) ⇒ Object
- #tests(n = 20) ⇒ Object
Constructor Details
#initialize(project) ⇒ TestRunStatistics
Returns a new instance of TestRunStatistics.
3 4 5 |
# File 'app/models/test_run_statistics.rb', line 3 def initialize(project) @project = project end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
7 8 9 |
# File 'app/models/test_run_statistics.rb', line 7 def project @project end |
Instance Method Details
#coverage(n = 20) ⇒ Object
20 21 22 23 |
# File 'app/models/test_run_statistics.rb', line 20 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 |
#duration(n = 20) ⇒ Object
14 15 16 17 |
# File 'app/models/test_run_statistics.rb', line 14 def duration(n=20) durations = last_completed_test_runs(n).pluck(:duration).map { |n| n / 1000.0 } ljust(durations, 0, n).reverse end |
#fails(n = 20) ⇒ Object
39 40 41 |
# File 'app/models/test_run_statistics.rb', line 39 def fails(n=20) ljust(last_completed_test_runs(n).pluck(:fail_count), 0, n).reverse end |
#last_completed_test_runs(n) ⇒ Object
9 10 11 |
# File 'app/models/test_run_statistics.rb', line 9 def last_completed_test_runs(n) project.test_runs.where("total_count > 0").limit(n) end |
#ljust(array, value, n) ⇒ Object
49 50 51 |
# File 'app/models/test_run_statistics.rb', line 49 def ljust(array, value, n) array.dup.fill(value, array.length...n) end |
#passes(n = 20) ⇒ Object
43 44 45 |
# File 'app/models/test_run_statistics.rb', line 43 def passes(n=20) ljust(last_completed_test_runs(n).pluck(:pass_count), 0, n).reverse end |
#regressions(n = 20) ⇒ Object
35 36 37 |
# File 'app/models/test_run_statistics.rb', line 35 def regressions(n=20) ljust(last_completed_test_runs(n).pluck(:regression_count), 0, n).reverse end |
#skips(n = 20) ⇒ Object
31 32 33 |
# File 'app/models/test_run_statistics.rb', line 31 def skips(n=20) ljust(last_completed_test_runs(n).pluck(:skip_count), 0, n).reverse end |
#tests(n = 20) ⇒ Object
27 28 29 |
# File 'app/models/test_run_statistics.rb', line 27 def tests(n=20) [ skips(n), regressions(n), fails(n), passes(n) ] end |