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,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
3
+ require File.expand_path("../../test_helper", File.dirname(__FILE__))
4
4
 
5
5
  ####
6
6
  # Thanks for all the help SimpleCov https://github.com/colszowka/simplecov-html
@@ -8,32 +8,32 @@ require File.expand_path('../../test_helper', File.dirname(__FILE__))
8
8
  ####
9
9
  describe Coverband::Utils::SourceFile do
10
10
  COVERAGE_FOR_SAMPLE_RB = [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil, nil, nil, nil, nil, nil, nil].freeze
11
- describe 'a source file initialized with some coverage data' do
11
+ describe "a source file initialized with some coverage data" do
12
12
  subject do
13
- Coverband::Utils::SourceFile.new(source_fixture('sample.rb'), COVERAGE_FOR_SAMPLE_RB)
13
+ Coverband::Utils::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB)
14
14
  end
15
15
 
16
- it 'has a filename' do
16
+ it "has a filename" do
17
17
  assert subject.filename
18
18
  end
19
19
 
20
- it 'has source equal to src' do
20
+ it "has source equal to src" do
21
21
  assert_equal subject.source, subject.src
22
22
  end
23
23
 
24
- it 'has a project filename which removes the project directory' do
25
- assert_equal '/test/fixtures/sample.rb', subject.project_filename
24
+ it "has a project filename which removes the project directory" do
25
+ assert_equal "/test/fixtures/sample.rb", subject.project_filename
26
26
  end
27
27
 
28
- it 'has source_lines equal to lines' do
28
+ it "has source_lines equal to lines" do
29
29
  assert_equal subject.source_lines, subject.lines
30
30
  end
31
31
 
32
- it 'has 16 source lines' do
32
+ it "has 16 source lines" do
33
33
  assert_equal 16, subject.lines.count
34
34
  end
35
35
 
36
- it 'has all source lines of type Coverband::Utils::SourceFile::Line' do
36
+ it "has all source lines of type Coverband::Utils::SourceFile::Line" do
37
37
  subject.lines.each do |line|
38
38
  assert line.is_a?(Coverband::Utils::SourceFile::Line)
39
39
  end
@@ -43,161 +43,111 @@ describe Coverband::Utils::SourceFile do
43
43
  assert_equal "class Foo\n", subject.line(2).source
44
44
  end
45
45
 
46
- it 'returns lines number 2, 3, 4, 7 for covered_lines' do
46
+ it "returns lines number 2, 3, 4, 7 for covered_lines" do
47
47
  assert_equal [2, 3, 4, 7], subject.covered_lines.map(&:line)
48
48
  end
49
49
 
50
- it 'returns lines number 8 for missed_lines' do
50
+ it "returns lines number 8 for missed_lines" do
51
51
  assert_equal [8], subject.missed_lines.map(&:line)
52
52
  end
53
53
 
54
- it 'returns lines number 1, 5, 6, 9, 10, 16 for never_lines' do
54
+ it "returns lines number 1, 5, 6, 9, 10, 16 for never_lines" do
55
55
  assert_equal [1, 5, 6, 9, 10, 16], subject.never_lines.map(&:line)
56
56
  end
57
57
 
58
- it 'returns line numbers 11, 12, 13, 14, 15 for skipped_lines' do
58
+ it "returns line numbers 11, 12, 13, 14, 15 for skipped_lines" do
59
59
  assert_equal [11, 12, 13, 14, 15], subject.skipped_lines.map(&:line)
60
60
  end
61
61
 
62
- it 'has 80% covered_percent' do
62
+ it "has 80% covered_percent" do
63
63
  assert_equal 80.0, subject.covered_percent
64
64
  end
65
65
 
66
- it 'working for nil last_updated_at' do
66
+ it "working for nil last_updated_at" do
67
67
  assert_equal "not available", subject.last_updated_at
68
68
  end
69
69
  end
70
70
 
71
- describe 'simulating potential Ruby 1.9 defect -- see Issue #56' do
71
+ describe "simulating potential Ruby 1.9 defect -- see Issue #56" do
72
72
  subject do
73
- Coverband::Utils::SourceFile.new(source_fixture('sample.rb'), COVERAGE_FOR_SAMPLE_RB + [nil])
73
+ Coverband::Utils::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB + [nil])
74
74
  end
75
75
 
76
- it 'has 16 source lines regardless of extra data in coverage array' do
76
+ it "has 16 source lines regardless of extra data in coverage array" do
77
77
  # Do not litter test output with known warning
78
78
  capture_stderr { assert_equal 16, subject.lines.count }
79
79
  end
80
80
 
81
- it 'prints a warning to stderr if coverage array contains more data than lines in the file' do
82
- captured_output = capture_stderr do
81
+ it "prints a warning to stderr if coverage array contains more data than lines in the file" do
82
+ captured_output = capture_stderr {
83
83
  subject.lines
84
- end
84
+ }
85
85
 
86
86
  assert(captured_output.match(/^Warning: coverage data/))
87
87
  end
88
88
  end
89
89
 
90
- describe 'a file that is never relevant' do
90
+ describe "a file that is never relevant" do
91
91
  COVERAGE_FOR_NEVER_RB = [nil, nil].freeze
92
92
 
93
93
  subject do
94
- Coverband::Utils::SourceFile.new(source_fixture('never.rb'), COVERAGE_FOR_NEVER_RB)
94
+ Coverband::Utils::SourceFile.new(source_fixture("never.rb"), COVERAGE_FOR_NEVER_RB)
95
95
  end
96
96
 
97
- it 'has 0.0 covered_strength' do
97
+ it "has 0.0 covered_strength" do
98
98
  assert_equal 0.0, subject.covered_strength
99
99
  end
100
100
 
101
- it 'has 0.0 covered_percent' do
101
+ it "has 0.0 covered_percent" do
102
102
  assert_equal 100.0, subject.covered_percent
103
103
  end
104
104
  end
105
105
 
106
- describe 'a file where nothing is ever executed mixed with skipping #563' do
106
+ describe "a file where nothing is ever executed mixed with skipping #563" do
107
107
  COVERAGE_FOR_SKIPPED_RB = [nil, nil, nil, nil].freeze
108
108
 
109
109
  subject do
110
- Coverband::Utils::SourceFile.new(source_fixture('skipped.rb'), COVERAGE_FOR_SKIPPED_RB)
110
+ Coverband::Utils::SourceFile.new(source_fixture("skipped.rb"), COVERAGE_FOR_SKIPPED_RB)
111
111
  end
112
112
 
113
- it 'has 0.0 covered_strength' do
113
+ it "has 0.0 covered_strength" do
114
114
  assert_equal 0.0, subject.covered_strength
115
115
  end
116
116
 
117
- it 'has 0.0 covered_percent' do
117
+ it "has 0.0 covered_percent" do
118
118
  assert_equal 0.0, subject.covered_percent
119
119
  end
120
120
  end
121
121
 
122
- describe 'a file where everything is skipped and missed #563' do
122
+ describe "a file where everything is skipped and missed #563" do
123
123
  COVERAGE_FOR_SKIPPED_RB_2 = [nil, nil, 0, nil].freeze
124
124
 
125
125
  subject do
126
- Coverband::Utils::SourceFile.new(source_fixture('skipped.rb'), COVERAGE_FOR_SKIPPED_RB_2)
126
+ Coverband::Utils::SourceFile.new(source_fixture("skipped.rb"), COVERAGE_FOR_SKIPPED_RB_2)
127
127
  end
128
128
 
129
- it 'has 0.0 covered_strength' do
129
+ it "has 0.0 covered_strength" do
130
130
  assert_equal 0.0, subject.covered_strength
131
131
  end
132
132
 
133
- it 'has 0.0 covered_percent' do
133
+ it "has 0.0 covered_percent" do
134
134
  assert_equal 0.0, subject.covered_percent
135
135
  end
136
136
  end
137
137
 
138
- describe 'a file where everything is skipped/irrelevamt but executed #563' do
138
+ describe "a file where everything is skipped/irrelevamt but executed #563" do
139
139
  COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB = [nil, nil, 1, 1, 0, nil, nil, nil].freeze
140
140
 
141
141
  subject do
142
- Coverband::Utils::SourceFile.new(source_fixture('skipped_and_executed.rb'), COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB)
142
+ Coverband::Utils::SourceFile.new(source_fixture("skipped_and_executed.rb"), COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB)
143
143
  end
144
144
 
145
- it 'has 0.0 covered_strength' do
145
+ it "has 0.0 covered_strength" do
146
146
  assert_equal 0.0, subject.covered_strength
147
147
  end
148
148
 
149
- it 'has 0.0 covered_percent' do
149
+ it "has 0.0 covered_percent" do
150
150
  assert_equal 0.0, subject.covered_percent
151
151
  end
152
152
  end
153
-
154
- describe 'correctly identifies gems' do
155
- COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB = [nil, nil, 1, 1, 0, 1, 1, nil].freeze
156
-
157
- describe 'the word gem in a path' do
158
- subject do
159
- Coverband::Utils::SourceFile.new('lib/rubocop/cop/gemspec/required_ruby_version.rb', COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB)
160
- end
161
-
162
- it 'allows the word gem in path' do
163
- assert_equal nil, subject.gem?
164
- end
165
- end
166
-
167
- describe 'a folder gem in the path' do
168
- subject do
169
- Coverband::Utils::SourceFile.new('/var/gems/rubocop-0.67.0/lib/rubocop/cop/gemspec/required_ruby_version.rb', COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB)
170
- end
171
-
172
- it 'allows the word gem in path' do
173
- assert subject.gem?
174
- end
175
- end
176
- end
177
-
178
- describe 'correctly reports gem name' do
179
- COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB = [nil, nil, 1, 1, 0, 1, 1, nil].freeze
180
-
181
- describe 'the word gem in a path' do
182
- subject do
183
- Coverband::Utils::SourceFile.new('lib/rubocop/cop/gemspec/required_ruby_version.rb', COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB)
184
- end
185
-
186
- it 'allows the word gem in path' do
187
- assert_equal nil, subject.gem_name
188
- end
189
- end
190
-
191
- describe 'a folder gem in the path' do
192
- subject do
193
- Coverband::Utils::SourceFile.new('/var/gems/rubocop-0.67.0/lib/rubocop/cop/gemspec/required_ruby_version.rb', COVERAGE_FOR_SKIPPED_AND_EXECUTED_RB)
194
- end
195
-
196
- it 'allows the word gem in path' do
197
- assert_equal 'rubocop-0.67.0', subject.gem_name
198
- end
199
- end
200
- end
201
-
202
-
203
153
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Dog
4
4
  def bark
5
- 'woof'
5
+ "woof"
6
6
  end
7
7
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rack'
3
+ require "rack"
4
4
 
5
5
  class HelloWorld
6
6
  def call(_env)
7
- [200, { 'Content-Type' => 'text/html' }, 'Hello Rack!']
7
+ [200, {"Content-Type" => "text/html"}, "Hello Rack!"]
8
8
  end
9
9
  end
@@ -1,7 +1,7 @@
1
1
  # Foo class
2
2
  class Foo
3
3
  def initialize
4
- @foo = 'baz'
4
+ @foo = "baz"
5
5
  end
6
6
 
7
7
  def bar
@@ -1,7 +1,7 @@
1
1
  # Foo class
2
2
  class Foo
3
3
  def initialize
4
- @foo = 'baz'
4
+ @foo = "baz"
5
5
  end
6
6
 
7
7
  def bar
@@ -1,7 +1,7 @@
1
1
  # Foo class
2
2
  class Foo
3
3
  def initialize
4
- @foo = 'baz'
4
+ @foo = "baz"
5
5
  end
6
6
 
7
7
  def bar
@@ -1,3 +1 @@
1
- # encoding: utf-8
2
-
3
1
  puts "135°C"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../rails_test_helper', File.dirname(__FILE__))
3
+ require File.expand_path("../rails_test_helper", File.dirname(__FILE__))
4
4
 
5
5
  class RailsFullStackTest < Minitest::Test
6
6
  include Capybara::DSL
@@ -11,8 +11,8 @@ class RailsFullStackTest < Minitest::Test
11
11
  rails_setup
12
12
  # preload first coverage hit
13
13
  Coverband.report_coverage
14
- require 'rainbow'
15
- Rainbow('this text is red').red
14
+ require "rainbow"
15
+ Rainbow("this text is red").red
16
16
  end
17
17
 
18
18
  def teardown
@@ -24,30 +24,27 @@ class RailsFullStackTest < Minitest::Test
24
24
  # We have to combine everything in one test
25
25
  # because we can only initialize rails once per test
26
26
  # run. Possibly fork test runs to avoid this problem in future?
27
- unless ENV['COVERBAND_MEMORY_TEST']
28
- test 'this is how we do it' do
29
- visit '/dummy/show'
27
+ unless ENV["COVERBAND_MEMORY_TEST"]
28
+ test "this is how we do it" do
29
+ visit "/dummy/show"
30
30
  Coverband.report_coverage
31
- assert_content('I am no dummy')
32
- visit '/coverage'
33
- within page.find('a', text: /dummy_controller.rb/).find(:xpath, '../..') do
34
- assert_selector('td', text: '100.0 %')
31
+ assert_content("I am no dummy")
32
+ visit "/coverage"
33
+ within page.find("a", text: /dummy_controller.rb/).find(:xpath, "../..") do
34
+ assert_selector("td", text: "100.0 %")
35
35
  end
36
36
 
37
- # Test gems are reporting coverage
38
- assert_content('Gems')
39
- assert page.html.match('rainbow/wrapper.rb')
40
-
41
37
  # Test eager load data stored separately
42
38
  dummy_controller = "./test/rails#{Rails::VERSION::MAJOR}_dummy/app/controllers/dummy_controller.rb"
43
39
  store.type = :eager_loading
44
40
  eager_expected = [1, 1, 0, nil, nil]
45
- results = store.coverage[dummy_controller]['data']
41
+ results = store.coverage[dummy_controller]["data"]
46
42
  assert_equal(eager_expected, results)
47
43
 
48
44
  store.type = Coverband::RUNTIME_TYPE
49
45
  runtime_expected = [0, 0, 1, nil, nil]
50
- results = store.coverage[dummy_controller]['data']
46
+ results = store.coverage[dummy_controller]["data"]
47
+ assert_equal(runtime_expected, results)
51
48
  end
52
49
  end
53
50
 
@@ -55,20 +52,20 @@ class RailsFullStackTest < Minitest::Test
55
52
  # as we run it in single test mode via the benchmarks.
56
53
  # Add new tests below this test
57
54
  ###
58
- if ENV['COVERBAND_MEMORY_TEST']
59
- test 'memory usage' do
60
- return unless ENV['COVERBAND_MEMORY_TEST']
55
+ if ENV["COVERBAND_MEMORY_TEST"]
56
+ test "memory usage" do
57
+ return unless ENV["COVERBAND_MEMORY_TEST"]
61
58
 
62
59
  # we don't want this to run during our standard test suite
63
60
  # as the below profiler changes the runtime
64
61
  # and shold only be included for isolated processes
65
62
  begin
66
- require 'memory_profiler'
63
+ require "memory_profiler"
67
64
 
68
65
  # warmup
69
66
  3.times do
70
- visit '/dummy/show'
71
- assert_content('I am no dummy')
67
+ visit "/dummy/show"
68
+ assert_content("I am no dummy")
72
69
  Coverband.report_coverage
73
70
  end
74
71
 
@@ -76,10 +73,10 @@ class RailsFullStackTest < Minitest::Test
76
73
  capture = StringIO.new
77
74
  $stdout = capture
78
75
 
79
- MemoryProfiler.report do
76
+ MemoryProfiler.report {
80
77
  15.times do
81
- visit '/dummy/show'
82
- assert_content('I am no dummy')
78
+ visit "/dummy/show"
79
+ assert_content("I am no dummy")
83
80
  Coverband.report_coverage
84
81
  ###
85
82
  # Set to nil not {} as it is easier to verify that no memory is retained when nil gets released
@@ -91,12 +88,12 @@ class RailsFullStackTest < Minitest::Test
91
88
  # needed to test older versions to discover when we had the regression
92
89
  # Coverband::Collectors::Coverage.instance.send(:add_previous_results, nil)
93
90
  end
94
- end.pretty_print
91
+ }.pretty_print
95
92
  data = $stdout.string
96
93
  $stdout = previous_out
97
94
  if data.match(/retained objects by gem(.*)retained objects by file/m)[0]&.match(/coverband/)
98
95
  puts data
99
- raise 'leaking memory!!!'
96
+ raise "leaking memory!!!"
100
97
  end
101
98
  ensure
102
99
  $stdout = previous_out
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../rails_test_helper', File.dirname(__FILE__))
4
- require 'rails'
5
- require 'pundit'
3
+ require File.expand_path("../rails_test_helper", File.dirname(__FILE__))
4
+ require "rails"
6
5
 
7
6
  class RailsRakeFullStackTest < Minitest::Test
8
7
  def setup
@@ -11,31 +10,13 @@ class RailsRakeFullStackTest < Minitest::Test
11
10
  Coverband.configure("./test/rails#{Rails::VERSION::MAJOR}_dummy/config/coverband.rb")
12
11
  end
13
12
 
14
- test 'rake tasks shows coverage properly within eager_loading' do
15
- store.instance_variable_set(:@redis_namespace, 'coverband_test')
16
- store.clear!
17
- system("COVERBAND_CONFIG=./test/rails#{Rails::VERSION::MAJOR}_dummy/config/coverband.rb bundle exec rake -f test/rails#{Rails::VERSION::MAJOR}_dummy/Rakefile middleware")
18
- store.instance_variable_set(:@redis_namespace, 'coverband_test')
19
- store.type = :eager_loading
20
- pundit_file = store.coverage.keys.grep(/pundit.rb/).first
21
- refute_nil pundit_file
22
- pundit_coverage = store.coverage[pundit_file]
23
- refute_nil pundit_coverage
24
- assert_includes pundit_coverage['data'], 1
25
-
26
- store.type = Coverband::RUNTIME_TYPE
27
- if ENV['SIMULATE_ONESHOT']
28
- pundit_coverage = store.get_coverage_report[Coverband::RUNTIME_TYPE][pundit_file]
29
- assert pundit_coverage['data'].compact.all? { |el| el == 0 }
30
- else
31
- pundit_coverage = store.coverage[pundit_file]
32
- assert_nil pundit_coverage
33
- end
34
- end
13
+ # test 'rake tasks shows coverage properly within eager_loading' do
14
+ # this was testing gem data, which we no logner support and I dont know if this makes sense anymre
15
+ # end
35
16
 
36
17
  test "ignored rake tasks don't add coverage" do
37
18
  store.clear!
38
- store.instance_variable_set(:@redis_namespace, 'coverband_test')
19
+ store.instance_variable_set(:@redis_namespace, "coverband_test")
39
20
  store.send(:save_report, basic_coverage_full_path)
40
21
  output = `COVERBAND_CONFIG=./test/rails#{Rails::VERSION::MAJOR}_dummy/config/coverband.rb bundle exec rake -f test/rails#{Rails::VERSION::MAJOR}_dummy/Rakefile coverband:clear`
41
22
  assert_nil output.match(/Coverband: Reported coverage via thread/)
@@ -49,7 +30,7 @@ class RailsRakeFullStackTest < Minitest::Test
49
30
  test "doesn't exit non-zero with error on missing redis" do
50
31
  output = `COVERBAND_CONFIG=./test/rails#{Rails::VERSION::MAJOR}_dummy/config/coverband_missing_redis.rb bundle exec rake -f test/rails#{Rails::VERSION::MAJOR}_dummy/Rakefile -T`
51
32
  assert_equal 0, $?.to_i
52
- if ENV['COVERBAND_HASH_REDIS_STORE']
33
+ if ENV["COVERBAND_HASH_REDIS_STORE"]
53
34
  assert output.match(/Redis is not available/)
54
35
  else
55
36
  assert output.match(/coverage failed to store/)