coverband 4.2.6 → 5.0.0.rc.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +26 -0
  3. data/.travis.yml +2 -1
  4. data/Gemfile +5 -7
  5. data/Gemfile.rails4 +0 -3
  6. data/Gemfile.rails6 +0 -3
  7. data/README.md +24 -77
  8. data/Rakefile +17 -17
  9. data/changes.md +30 -28
  10. data/config.ru +1 -1
  11. data/coverband.gemspec +31 -34
  12. data/lib/alternative_coverband_patch.rb +5 -0
  13. data/lib/coverband.rb +68 -44
  14. data/lib/coverband/adapters/base.rb +17 -18
  15. data/lib/coverband/adapters/file_store.rb +38 -6
  16. data/lib/coverband/adapters/hash_redis_store.rb +24 -21
  17. data/lib/coverband/adapters/redis_store.rb +12 -12
  18. data/lib/coverband/adapters/stdout_store.rb +41 -0
  19. data/lib/coverband/adapters/web_service_store.rb +155 -0
  20. data/lib/coverband/at_exit.rb +1 -1
  21. data/lib/coverband/collectors/coverage.rb +15 -27
  22. data/lib/coverband/collectors/delta.rb +29 -9
  23. data/lib/coverband/collectors/view_tracker.rb +10 -10
  24. data/lib/coverband/collectors/view_tracker_service.rb +59 -0
  25. data/lib/coverband/configuration.rb +150 -113
  26. data/lib/coverband/integrations/background.rb +6 -6
  27. data/lib/coverband/integrations/rack_server_check.rb +3 -3
  28. data/lib/coverband/integrations/resque.rb +13 -1
  29. data/lib/coverband/reporters/base.rb +11 -12
  30. data/lib/coverband/reporters/console_report.rb +1 -1
  31. data/lib/coverband/reporters/html_report.rb +10 -30
  32. data/lib/coverband/reporters/web.rb +55 -50
  33. data/lib/coverband/utils/absolute_file_converter.rb +6 -6
  34. data/lib/coverband/utils/html_formatter.rb +32 -61
  35. data/lib/coverband/utils/railtie.rb +23 -6
  36. data/lib/coverband/utils/relative_file_converter.rb +2 -2
  37. data/lib/coverband/utils/result.rb +6 -11
  38. data/lib/coverband/utils/results.rb +0 -10
  39. data/lib/coverband/utils/source_file.rb +21 -30
  40. data/lib/coverband/utils/tasks.rb +8 -11
  41. data/lib/coverband/version.rb +1 -1
  42. data/public/application.js +0 -30
  43. data/test/benchmarks/benchmark.rake +97 -92
  44. data/test/benchmarks/dog.rb +1 -1
  45. data/test/benchmarks/init_rails.rake +4 -4
  46. data/test/coverband/adapters/base_test.rb +29 -30
  47. data/test/coverband/adapters/file_store_test.rb +19 -20
  48. data/test/coverband/adapters/hash_redis_store_test.rb +57 -57
  49. data/test/coverband/adapters/redis_store_test.rb +26 -26
  50. data/test/coverband/adapters/web_service_store_test.rb +56 -0
  51. data/test/coverband/at_exit_test.rb +2 -2
  52. data/test/coverband/collectors/coverage_test.rb +33 -47
  53. data/test/coverband/collectors/delta_test.rb +52 -23
  54. data/test/coverband/collectors/view_tracker_test.rb +35 -35
  55. data/test/coverband/configuration_test.rb +61 -48
  56. data/test/coverband/coverband_test.rb +11 -11
  57. data/test/coverband/integrations/background_middleware_test.rb +10 -10
  58. data/test/coverband/integrations/background_test.rb +17 -5
  59. data/test/coverband/integrations/rack_server_check_test.rb +7 -7
  60. data/test/coverband/integrations/report_middleware_test.rb +9 -9
  61. data/test/coverband/integrations/resque_worker_test.rb +9 -9
  62. data/test/coverband/integrations/test_resque_job.rb +1 -1
  63. data/test/coverband/reporters/base_test.rb +9 -9
  64. data/test/coverband/reporters/console_test.rb +6 -6
  65. data/test/coverband/reporters/html_test.rb +36 -48
  66. data/test/coverband/reporters/web_test.rb +16 -18
  67. data/test/coverband/utils/absolute_file_converter_test.rb +22 -22
  68. data/test/coverband/utils/file_hasher_test.rb +6 -12
  69. data/test/coverband/utils/file_list_test.rb +13 -13
  70. data/test/coverband/utils/html_formatter_test.rb +9 -23
  71. data/test/coverband/utils/lines_classifier_test.rb +29 -29
  72. data/test/coverband/utils/relative_file_converter_test.rb +13 -13
  73. data/test/coverband/utils/result_test.rb +18 -18
  74. data/test/coverband/utils/results_test.rb +17 -17
  75. data/test/coverband/utils/source_file_line_test.rb +46 -46
  76. data/test/coverband/utils/source_file_test.rb +38 -88
  77. data/test/dog.rb +1 -1
  78. data/test/fake_app/basic_rack.rb +2 -2
  79. data/test/fixtures/app/controllers/sample_controller.rb +1 -1
  80. data/test/fixtures/app/models/user.rb +1 -1
  81. data/test/fixtures/sample.rb +1 -1
  82. data/test/fixtures/utf-8.rb +0 -2
  83. data/test/forked/rails_full_stack_test.rb +24 -27
  84. data/test/forked/rails_rake_full_stack_test.rb +7 -26
  85. data/test/integration/full_stack_test.rb +11 -22
  86. data/test/jruby_check.rb +2 -3
  87. data/test/rails4_dummy/Rakefile +1 -1
  88. data/test/rails4_dummy/config.ru +1 -1
  89. data/test/rails4_dummy/config/application.rb +4 -4
  90. data/test/rails4_dummy/config/boot.rb +2 -2
  91. data/test/rails4_dummy/config/coverband.rb +1 -1
  92. data/test/rails4_dummy/config/coverband_missing_redis.rb +1 -1
  93. data/test/rails4_dummy/config/environment.rb +1 -1
  94. data/test/rails4_dummy/config/routes.rb +2 -2
  95. data/test/rails5_dummy/Rakefile +1 -1
  96. data/test/rails5_dummy/config.ru +1 -1
  97. data/test/rails5_dummy/config/application.rb +3 -3
  98. data/test/rails5_dummy/config/coverband.rb +8 -8
  99. data/test/rails5_dummy/config/coverband_missing_redis.rb +8 -8
  100. data/test/rails5_dummy/config/environment.rb +1 -1
  101. data/test/rails5_dummy/config/routes.rb +2 -2
  102. data/test/rails6_dummy/Rakefile +1 -1
  103. data/test/rails6_dummy/config.ru +1 -1
  104. data/test/rails6_dummy/config/application.rb +4 -4
  105. data/test/rails6_dummy/config/boot.rb +2 -2
  106. data/test/rails6_dummy/config/coverband.rb +1 -1
  107. data/test/rails6_dummy/config/coverband_missing_redis.rb +1 -1
  108. data/test/rails6_dummy/config/environment.rb +1 -1
  109. data/test/rails6_dummy/config/routes.rb +2 -2
  110. data/test/rails_test_helper.rb +11 -11
  111. data/test/test_helper.rb +44 -34
  112. data/test/unique_files.rb +10 -10
  113. data/views/layout.erb +2 -12
  114. metadata +29 -34
  115. data/.rubocop.yml +0 -84
  116. data/lib/coverband/integrations/bundler.rb +0 -8
  117. data/lib/coverband/utils/file_groups.rb +0 -53
  118. data/lib/coverband/utils/gem_list.rb +0 -31
  119. data/lib/coverband/utils/s3_report.rb +0 -105
  120. data/test/coverband/utils/file_groups_test.rb +0 -61
  121. data/test/coverband/utils/gem_list_test.rb +0 -48
  122. data/test/coverband/utils/s3_report_test.rb +0 -44
  123. data/views/gem_list.erb +0 -63
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
-
5
- describe Coverband::Utils::FileGroups do
6
- FAKE_GEM_PATH = '/Users/danmayer/.rvm/gems/ruby-2.6.2/gems'
7
- SECONDAY_GEM_PATH = '/Users/danmayer/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems'
8
- subject do
9
- controller_lines = [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]
10
- files = [
11
- Coverband::Utils::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]),
12
- Coverband::Utils::SourceFile.new(source_fixture('app/models/user.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]),
13
- Coverband::Utils::SourceFile.new(source_fixture('app/controllers/sample_controller.rb'), controller_lines),
14
- Coverband::Utils::SourceFile.new("#{FAKE_GEM_PATH}/gem_name-1.0.0/gem_name.rb", controller_lines),
15
- Coverband::Utils::SourceFile.new("#{SECONDAY_GEM_PATH}/gem_two_name-1.1.1/gem_two.rb", controller_lines)
16
- ]
17
- Coverband.configuration.expects(:gem_paths).at_least_once.returns([FAKE_GEM_PATH, SECONDAY_GEM_PATH])
18
- Coverband.configuration.track_gems = true
19
- Coverband::Utils::FileGroups.new(files)
20
- end
21
-
22
- it 'has app files' do
23
- assert_equal 'test/fixtures/sample.rb', subject.grouped_results['App'].first.short_name
24
- end
25
-
26
- it 'has gem files' do
27
- assert_equal "gem_name-1.0.0", subject.grouped_results['Gems'].first.first.gem_name
28
- end
29
-
30
- it 'has gem files from secondary gem paths' do
31
- assert_equal "gem_two_name-1.1.1", subject.grouped_results['Gems'][1].first.gem_name
32
- end
33
- end
34
-
35
- describe Coverband::Utils::FileGroups, :vendored_gems do
36
- FAKE_VENDOR_GEM_PATH = "#{test_root}/app/vendor/bundle/ruby/2.5.0/gems"
37
- subject do
38
- controller_lines = [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]
39
- files = [
40
- Coverband::Utils::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]),
41
- Coverband::Utils::SourceFile.new(source_fixture('app/models/user.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]),
42
- Coverband::Utils::SourceFile.new(source_fixture('app/controllers/sample_controller.rb'), controller_lines),
43
- Coverband::Utils::SourceFile.new("#{FAKE_VENDOR_GEM_PATH}/gem_name.rb", controller_lines)
44
- ]
45
- Coverband.configuration.expects(:gem_paths).at_least_once.returns([FAKE_VENDOR_GEM_PATH])
46
- Coverband.configuration.track_gems = true
47
- Coverband::Utils::FileGroups.new(files)
48
- end
49
-
50
- it 'has app files' do
51
- assert_equal 'test/fixtures/sample.rb', subject.grouped_results['App'].first.short_name
52
- end
53
-
54
- it "doesn't include vendor gems in app files app files" do
55
- assert_nil subject.grouped_results['App'].select { |files| files.short_name.match(/gem_name/) }.first
56
- end
57
-
58
- it 'does has gem files' do
59
- assert_equal '.gem_name.rb', subject.grouped_results['Gems'].first.first.short_name
60
- end
61
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
-
5
- ####
6
- # Thanks for all the help SimpleCov https://github.com/colszowka/simplecov-html
7
- # initial version of test pulled into Coverband from Simplecov 12/19/2018
8
- ####
9
- describe Coverband::Utils::GemList do
10
- subject do
11
- controller_lines = [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]
12
- gem_files = [
13
- Coverband::Utils::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]),
14
- Coverband::Utils::SourceFile.new(source_fixture('app/models/user.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]),
15
- Coverband::Utils::SourceFile.new(source_fixture('app/controllers/sample_controller.rb'), controller_lines)
16
- ]
17
- gem_lists = [Coverband::Utils::FileList.new(gem_files), Coverband::Utils::FileList.new(gem_files)]
18
- Coverband::Utils::GemList.new(gem_lists)
19
- end
20
-
21
- it 'has 22 covered lines' do
22
- assert_equal 22, subject.covered_lines
23
- end
24
-
25
- it 'has 6 missed lines' do
26
- assert_equal 6, subject.missed_lines
27
- end
28
-
29
- it 'has 34 never lines' do
30
- assert_equal 34, subject.never_lines
31
- end
32
-
33
- it 'has 28 lines of code' do
34
- assert_equal 28, subject.lines_of_code
35
- end
36
-
37
- it 'has 10 skipped lines' do
38
- assert_equal 10, subject.skipped_lines
39
- end
40
-
41
- it 'has the correct covered percent' do
42
- assert_equal 78.57142857142857, subject.covered_percent
43
- end
44
-
45
- it 'has the correct covered strength' do
46
- assert_equal 0.9285714285714286, subject.covered_strength
47
- end
48
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
-
5
- module Coverband
6
- class S3ReportTest < Minitest::Test
7
- def html_version
8
- Coverband::VERSION
9
- end
10
-
11
- test 'it writes the coverage report to s3' do
12
- if defined?(Aws::S3::Resource)
13
- # AWS v2
14
- s3 = mock('s3_resource')
15
- bucket = mock('bucket')
16
- object = mock('object')
17
- s3.expects(:bucket).with('coverage-bucket').returns(bucket)
18
- bucket.expects(:object).with('coverband/index.html').returns(object)
19
- File.expects(:read).with("#{Coverband.configuration.root}/coverage/index.html").returns("content ./assets/#{html_version}/")
20
- object.expects(:put).with(body: 'content ')
21
- Aws::S3::Client.expects(:new).returns(nil)
22
- Aws::S3::Resource.expects(:new).returns(s3)
23
- else
24
- # AWS v1
25
- object = mock('object')
26
- object.expects(:write).with('content ')
27
- bucket = mock('bucket')
28
- bucket.expects(:objects).returns('coverband/index.html' => object)
29
- local_s3 = mock('s3_resource')
30
- local_s3.expects(:buckets).returns('coverage-bucket' => bucket)
31
- File.expects(:read).at_least(0).returns("content ./assets/#{html_version}/")
32
- AWS::S3::Client.expects(:new).returns(nil)
33
- AWS::S3.expects(:new).returns(local_s3)
34
- end
35
-
36
- s3_options = {
37
- region: 'us-west-1',
38
- access_key_id: '',
39
- secret_access_key: ''
40
- }
41
- Coverband::Utils::S3Report.new('coverage-bucket', s3_options).persist!
42
- end
43
- end
44
- end
@@ -1,63 +0,0 @@
1
- <div class="file_list_container" id="<%= title_id %>">
2
- <h2>
3
- <span class="group_name"><%= title %></span>
4
- (<span class="covered_percent"><span class="<%= coverage_css_class(source_files.covered_percent) %>"><%= source_files.covered_percent.round(2) %>%</span></span>
5
- covered at
6
- <span class="covered_strength">
7
- <span class="<%= strength_css_class(source_files.covered_strength) %>">
8
- <%= source_files.covered_strength.round(2) %>
9
- </span>
10
- </span> hits/line)
11
- </h2>
12
- <div>
13
- <b><%= source_files.length %></b> files in total.
14
- <b><%= source_files.lines_of_code %></b> relevant lines.
15
- <span class="green"><b><%= source_files.covered_lines %></b> lines covered</span> and
16
- <span class="red"><b><%= source_files.missed_lines %></b> lines missed </span>
17
- </div>
18
- <table class="gem_list">
19
- <thead>
20
- <tr>
21
- <th>Gem</th>
22
- <th>% covered</th>
23
- <th>% runtime</th>
24
- <th>Relevant Lines</th>
25
- <th>Lines covered</th>
26
- <th>Lines runtime</th>
27
- <th>Lines missed</th>
28
- <th>Avg. Hits / Line</th>
29
- </tr>
30
- </thead>
31
- <tbody>
32
- <% source_files.each do |source_file| %>
33
- <tr>
34
- <td class="strong">
35
- <% if gem_details? %>
36
- <%= link_to_gem_list(source_file.first.gem_name) %>
37
- <% else %>
38
- <%= source_file.first.gem_name %>
39
- <% end %>
40
- </td>
41
- <td class="<%= coverage_css_class(source_file.covered_percent) %> strong"><%= source_file.covered_percent.round(2).to_s %> %</td>
42
- <% runtime_percentage = result.group_file_list_with_type(title, source_file, Coverband::RUNTIME_TYPE)&.formatted_covered_percent %>
43
- <td class="<%= "#{coverage_css_class(runtime_percentage)}" %> strong">
44
- <%= "#{runtime_percentage || '0'} %" %>
45
- </td>
46
- <td><%= source_file.covered_lines + source_file.missed_lines %></td>
47
- <td><%= source_file.covered_lines %></td>
48
- <td>
49
- <%= result.group_file_list_with_type(title, source_file, Coverband::RUNTIME_TYPE)&.covered_lines || 0 %>
50
- </td>
51
- <td><%= source_file.missed_lines %></td>
52
- <td><%= source_file.covered_strength.round(1) %></td>
53
- </tr>
54
- <% end %>
55
- </tbody>
56
- </table>
57
- </div>
58
-
59
- <% if gem_details? %>
60
- <% source_files.each do |gem_files| %>
61
- <%= formatted_file_list(gem_files.first.gem_name, result, gem_files, skip_nav: true) %>
62
- <% end %>
63
- <% end %>