coverband 4.2.0 → 4.2.1.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +29 -9
  3. data/.travis.yml +9 -1
  4. data/Gemfile +2 -1
  5. data/Gemfile.rails4 +1 -0
  6. data/README.md +34 -13
  7. data/Rakefile +10 -2
  8. data/changes.md +25 -10
  9. data/coverband.gemspec +5 -1
  10. data/lib/coverband.rb +30 -18
  11. data/lib/coverband/adapters/base.rb +2 -7
  12. data/lib/coverband/adapters/file_store.rb +1 -1
  13. data/lib/coverband/at_exit.rb +2 -11
  14. data/lib/coverband/collectors/coverage.rb +29 -32
  15. data/lib/coverband/collectors/delta.rb +20 -24
  16. data/lib/coverband/configuration.rb +49 -19
  17. data/lib/coverband/integrations/background.rb +6 -4
  18. data/lib/coverband/integrations/{middleware.rb → background_middleware.rb} +2 -6
  19. data/lib/coverband/integrations/bundler.rb +8 -0
  20. data/lib/coverband/integrations/report_middleware.rb +15 -0
  21. data/lib/coverband/integrations/resque.rb +3 -5
  22. data/lib/coverband/reporters/base.rb +39 -13
  23. data/lib/coverband/reporters/html_report.rb +21 -27
  24. data/lib/coverband/reporters/web.rb +2 -21
  25. data/lib/coverband/utils/file_list.rb +16 -5
  26. data/lib/coverband/utils/file_path_helper.rb +2 -0
  27. data/lib/coverband/utils/html_formatter.rb +25 -8
  28. data/lib/coverband/utils/lines_classifier.rb +5 -0
  29. data/lib/coverband/utils/railtie.rb +11 -12
  30. data/lib/coverband/utils/result.rb +5 -44
  31. data/lib/coverband/utils/results.rb +51 -0
  32. data/lib/coverband/utils/source_file.rb +29 -5
  33. data/lib/coverband/utils/tasks.rb +11 -2
  34. data/lib/coverband/version.rb +1 -1
  35. data/public/application.js +27 -0
  36. data/test/benchmarks/benchmark.rake +10 -20
  37. data/test/coverband/adapters/file_store_test.rb +5 -5
  38. data/test/coverband/adapters/redis_store_test.rb +8 -7
  39. data/test/coverband/at_exit_test.rb +0 -2
  40. data/test/coverband/collectors/coverage_test.rb +57 -9
  41. data/test/coverband/collectors/delta_test.rb +27 -6
  42. data/test/coverband/configuration_test.rb +47 -7
  43. data/test/coverband/coverband_test.rb +0 -1
  44. data/test/coverband/integrations/background_middleware_test.rb +44 -0
  45. data/test/coverband/integrations/background_test.rb +1 -3
  46. data/test/coverband/integrations/report_middleware_test.rb +44 -0
  47. data/test/coverband/integrations/resque_worker_test.rb +4 -3
  48. data/test/coverband/integrations/test_resque_job.rb +3 -1
  49. data/test/coverband/reporters/base_test.rb +4 -4
  50. data/test/coverband/reporters/console_test.rb +1 -2
  51. data/test/coverband/reporters/html_test.rb +79 -16
  52. data/test/coverband/reporters/web_test.rb +0 -10
  53. data/test/coverband/utils/file_groups_test.rb +1 -1
  54. data/test/coverband/utils/file_list_test.rb +5 -5
  55. data/test/coverband/utils/html_formatter_test.rb +45 -0
  56. data/test/coverband/utils/result_test.rb +27 -47
  57. data/test/coverband/utils/results_test.rb +54 -0
  58. data/test/coverband/utils/s3_report_test.rb +2 -0
  59. data/test/coverband/utils/source_file_test.rb +50 -0
  60. data/test/forked/rails_full_stack_test.rb +101 -0
  61. data/test/forked/rails_rake_full_stack_test.rb +32 -0
  62. data/test/integration/full_stack_test.rb +17 -15
  63. data/test/rails4_dummy/Rakefile +6 -0
  64. data/test/rails4_dummy/config/application.rb +8 -9
  65. data/test/rails4_dummy/config/coverband.rb +3 -3
  66. data/test/rails5_dummy/Rakefile +6 -0
  67. data/test/rails5_dummy/config/application.rb +6 -10
  68. data/test/rails5_dummy/config/coverband.rb +2 -2
  69. data/test/rails_test_helper.rb +23 -4
  70. data/test/test_helper.rb +26 -1
  71. data/test/unique_files.rb +6 -5
  72. data/views/file_list.erb +2 -2
  73. data/views/gem_list.erb +10 -1
  74. data/views/layout.erb +10 -3
  75. data/views/source_file.erb +13 -4
  76. data/views/source_file_loader.erb +1 -1
  77. metadata +79 -9
  78. data/test/coverband/integrations/middleware_test.rb +0 -96
  79. data/test/integration/rails_full_stack_test.rb +0 -95
@@ -17,7 +17,7 @@ class CollectorsDeltaTest < Minitest::Test
17
17
 
18
18
  test 'No previous results' do
19
19
  current_coverage = {
20
- 'car.rb' => [0,5,1]
20
+ 'car.rb' => [0, 5, 1]
21
21
  }
22
22
  results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
23
23
  assert_equal(current_coverage, results)
@@ -25,16 +25,16 @@ class CollectorsDeltaTest < Minitest::Test
25
25
 
26
26
  test 'Coverage has gone up' do
27
27
  current_coverage = {
28
- 'car.rb' => [nil,1,5,1]
28
+ 'car.rb' => [nil, 1, 5, 1]
29
29
  }
30
30
  results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
31
31
  assert_equal(current_coverage, results)
32
32
 
33
33
  current_coverage = {
34
- 'car.rb' => [nil,1,7,1]
34
+ 'car.rb' => [nil, 1, 7, 1]
35
35
  }
36
36
  results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
37
- assert_equal({'car.rb' => [nil, 0, 2, 0]}, results)
37
+ assert_equal({ 'car.rb' => [nil, 0, 2, 0] }, results)
38
38
  end
39
39
 
40
40
  test 'New file added to coverage' do
@@ -43,10 +43,31 @@ class CollectorsDeltaTest < Minitest::Test
43
43
  assert_equal(current_coverage, results)
44
44
 
45
45
  current_coverage = {
46
- 'dealership.rb' => [nil,1,1,nil]
46
+ 'dealership.rb' => [nil, 1, 1, nil]
47
47
  }
48
48
  results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
49
49
  assert_equal(current_coverage, results)
50
50
  end
51
- end
52
51
 
52
+ if Coverband.configuration.one_shot_coverage_implemented_in_ruby_version?
53
+ test 'one shot lines results' do
54
+
55
+ Coverband.configuration.stubs(:use_oneshot_lines_coverage).returns(true)
56
+ current_coverage = {}
57
+ results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
58
+ assert_equal(current_coverage, results)
59
+
60
+ current_coverage = {
61
+ 'dealership.rb' => {
62
+ :oneshot_lines => [2,3]
63
+ }
64
+ }
65
+ ::Coverage.expects(:line_stub).with('dealership.rb').returns([nil, 0, 0, nil])
66
+ results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
67
+ expected = {
68
+ 'dealership.rb' => [nil, 1, 1, nil]
69
+ }
70
+ assert_equal(expected, results)
71
+ end
72
+ end
73
+ end
@@ -5,31 +5,53 @@ require File.expand_path('../test_helper', File.dirname(__FILE__))
5
5
  class BaseTest < Minitest::Test
6
6
  def setup
7
7
  super
8
+ Coverband.configuration.reset
8
9
  Coverband.configure do |config|
9
10
  config.root = Dir.pwd
10
11
  config.s3_bucket = nil
11
12
  config.root_paths = ['/app_path/']
12
- config.ignore = ['vendor']
13
- config.reporting_frequency = 100.0
13
+ config.ignore = ['config/envionments']
14
14
  config.reporter = 'std_out'
15
- config.store = Coverband::Adapters::RedisStore.new(Redis.new)
15
+ config.store = Coverband::Adapters::RedisStore.new(Redis.new, redis_namespace: 'coverband_test')
16
16
  end
17
17
  end
18
18
 
19
- test 'defaults' do
19
+ test 'ignore works with equal' do
20
20
  coverband = Coverband::Collectors::Coverage.instance.reset_instance
21
- assert_equal ['vendor', 'internal:prelude', 'schema.rb'], coverband.instance_variable_get('@ignore_patterns')
21
+ expected = ["vendor", ".erb$", ".slim$", "/tmp", "internal:prelude", "schema.rb", "config/envionments"]
22
+ assert_equal expected, Coverband.configuration.ignore
23
+ end
24
+
25
+ test 'ignore works with plus equal' do
26
+ Coverband.configure do |config|
27
+ config.ignore += ['config/initializers']
28
+ end
29
+ coverband = Coverband::Collectors::Coverage.instance.reset_instance
30
+ expected = ["vendor",
31
+ ".erb$",
32
+ ".slim$",
33
+ "/tmp",
34
+ "internal:prelude",
35
+ "schema.rb",
36
+ "config/envionments",
37
+ "config/initializers"]
38
+ assert_equal expected, Coverband.configuration.ignore
39
+ end
40
+
41
+ test 'ignore' do
42
+ Coverband::Collectors::Coverage.instance.reset_instance
43
+ assert !Coverband.configuration.gem_paths.first.nil?
22
44
  end
23
45
 
24
46
  test 'gem_paths' do
25
47
  Coverband::Collectors::Coverage.instance.reset_instance
26
- assert Coverband.configuration.gem_paths.first != nil
48
+ assert !Coverband.configuration.gem_paths.first.nil?
27
49
  end
28
50
 
29
51
  test 'groups' do
30
52
  Coverband::Collectors::Coverage.instance.reset_instance
31
53
  Coverband.configuration.track_gems = true
32
- assert_equal %w(App Gems), Coverband.configuration.groups.keys
54
+ assert_equal %w[App Gems], Coverband.configuration.groups.keys
33
55
  end
34
56
 
35
57
  test 'all_root_paths' do
@@ -64,4 +86,22 @@ class BaseTest < Minitest::Test
64
86
  end
65
87
  end
66
88
  end
89
+
90
+ test 'use_oneshot_lines_coverage' do
91
+ refute Coverband.configuration.use_oneshot_lines_coverage
92
+
93
+ Coverband.configuration.stubs(:one_shot_coverage_implemented_in_ruby_version?).returns(true)
94
+ Coverband.configuration.use_oneshot_lines_coverage = true
95
+ assert Coverband.configuration.use_oneshot_lines_coverage
96
+
97
+ Coverband.configuration.use_oneshot_lines_coverage = false
98
+ refute Coverband.configuration.use_oneshot_lines_coverage
99
+
100
+ Coverband.configuration.stubs(:one_shot_coverage_implemented_in_ruby_version?).returns(false)
101
+ exception = assert_raises Exception do
102
+ Coverband.configuration.use_oneshot_lines_coverage = true
103
+ end
104
+ assert_equal 'One shot line coverage is only available in ruby >= 2.6', exception.message
105
+ refute Coverband.configuration.use_oneshot_lines_coverage
106
+ end
67
107
  end
@@ -3,7 +3,6 @@
3
3
  require File.expand_path('../test_helper', File.dirname(__FILE__))
4
4
 
5
5
  class CoverbandTest < Minitest::Test
6
-
7
6
  test 'Coverband#start kicks off background reporting if enabled and not in rack server' do
8
7
  Coverband.configuration.stubs(:background_reporting_enabled).returns(:true)
9
8
  Coverband::RackServerCheck.expects(:running?).returns(false)
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
+ require 'rack'
5
+
6
+ class BackgroundMiddlewareTest < Minitest::Test
7
+ def setup
8
+ super
9
+ Coverband.configure do |config|
10
+ config.background_reporting_enabled = false
11
+ end
12
+ end
13
+
14
+ test 'call app' do
15
+ request = Rack::MockRequest.env_for('/anything.json')
16
+ Coverband::Collectors::Coverage.instance.reset_instance
17
+ middleware = Coverband::BackgroundMiddleware.new(fake_app)
18
+ results = middleware.call(request)
19
+ assert_equal '/anything.json', results.last
20
+ end
21
+
22
+ test 'pass all rack lint checks' do
23
+ Coverband::Collectors::Coverage.instance.reset_instance
24
+ app = Rack::Lint.new(Coverband::BackgroundMiddleware.new(fake_app))
25
+ env = Rack::MockRequest.env_for('/hello')
26
+ app.call(env)
27
+ end
28
+
29
+ test 'starts background reporter when configured' do
30
+ request = Rack::MockRequest.env_for('/anything.json')
31
+ Coverband.configuration.stubs(:background_reporting_enabled).returns(true)
32
+ Coverband::Background.expects(:start)
33
+ middleware = Coverband::BackgroundMiddleware.new(fake_app)
34
+ middleware.call(request)
35
+ end
36
+
37
+ private
38
+
39
+ def fake_app
40
+ @fake_app ||= lambda do |env|
41
+ [200, { 'Content-Type' => 'text/plain' }, env['PATH_INFO']]
42
+ end
43
+ end
44
+ end
@@ -4,8 +4,7 @@ require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
4
 
5
5
  class BackgroundTest < Minitest::Test
6
6
  class ThreadDouble < Struct.new(:alive)
7
- def exit
8
- end
7
+ def exit; end
9
8
 
10
9
  def alive?
11
10
  alive
@@ -27,5 +26,4 @@ class BackgroundTest < Minitest::Test
27
26
  Coverband::Collectors::Coverage.instance.expects(:report_coverage).twice
28
27
  2.times { Coverband::Background.start }
29
28
  end
30
-
31
29
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
+ require 'coverband/integrations/report_middleware'
5
+
6
+ class ReportMiddlewareTest < Minitest::Test
7
+ def setup
8
+ super
9
+ Coverband.configure do |config|
10
+ config.background_reporting_enabled = false
11
+ end
12
+ end
13
+
14
+ test 'reports coverage' do
15
+ request = Rack::MockRequest.env_for('/anything.json')
16
+ Coverband::Collectors::Coverage.instance.expects(:report_coverage)
17
+ middleware = Coverband::ReportMiddleware.new(fake_app)
18
+ middleware.call(request)
19
+ end
20
+
21
+ test 'reports coverage when an error is raised' do
22
+ request = Rack::MockRequest.env_for('/anything.json')
23
+ Coverband::Collectors::Coverage.instance.reset_instance
24
+ Coverband::Collectors::Coverage.instance.expects(:report_coverage).once
25
+ middleware = Coverband::ReportMiddleware.new(fake_app_raise_error)
26
+ begin
27
+ middleware.call(request)
28
+ rescue StandardError
29
+ nil
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def fake_app
36
+ @fake_app ||= lambda do |env|
37
+ [200, { 'Content-Type' => 'text/plain' }, env['PATH_INFO']]
38
+ end
39
+ end
40
+
41
+ def fake_app_raise_error
42
+ @fake_app_raise_error ||= -> { raise 'hell' }
43
+ end
44
+ end
@@ -5,7 +5,7 @@ require File.expand_path('../../test_helper', File.dirname(__FILE__))
5
5
  class ResqueWorkerTest < Minitest::Test
6
6
  def enqueue_and_run_job
7
7
  Resque.enqueue(TestResqueJob)
8
- queue = ENV['QUEUE'] ='resque_coverband'
8
+ queue = ENV['QUEUE'] = 'resque_coverband'
9
9
  worker = Resque::Worker.new
10
10
  worker.startup
11
11
  worker.work_one_job
@@ -17,6 +17,7 @@ class ResqueWorkerTest < Minitest::Test
17
17
  config.background_reporting_enabled = false
18
18
  config.root_paths = ["#{File.expand_path('../', File.dirname(__FILE__))}/"]
19
19
  end
20
+ Coverband.configuration.store.instance_variable_set(:@redis_namespace, 'coverband_test')
20
21
  Coverband.start
21
22
  redis = Coverband.configuration.store.send(:redis)
22
23
  Resque.redis = redis
@@ -36,7 +37,7 @@ class ResqueWorkerTest < Minitest::Test
36
37
  Coverband.runtime_coverage!
37
38
  report = Coverband.configuration.store.get_coverage_report
38
39
 
39
- assert_equal 0, report[Coverband::EAGER_TYPE][relative_job_file]['data'][4]
40
- assert_equal 1, report[Coverband::RUNTIME_TYPE][relative_job_file]['data'][4]
40
+ assert_equal 0, report[Coverband::EAGER_TYPE][relative_job_file]['data'][6]
41
+ assert_equal 1, report[Coverband::RUNTIME_TYPE][relative_job_file]['data'][6]
41
42
  end
42
43
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class TestResqueJob
2
4
  @queue = :resque_coverband
3
5
 
4
6
  def self.perform
5
- "resque job perform"
7
+ 'resque job perform'
6
8
  end
7
9
  end
@@ -27,7 +27,7 @@ class ReportsBaseTest < Minitest::Test
27
27
 
28
28
  expected_path = '/full/remote_app/path/app/models/user.rb'
29
29
  key = '/box/apps/app_name/releases/20140725203539/app/models/user.rb'
30
- roots = ["/box/apps/app_name/releases/\\d+/", '/full/remote_app/path/']
30
+ roots = ['/box/apps/app_name/releases/\\d+/', '/full/remote_app/path/']
31
31
  File.expects(:exist?).with('/box/apps/app_name/releases/\\d+/app/models/user.rb').returns(false)
32
32
  File.expects(:exist?).with(expected_path).returns(true)
33
33
  assert_equal expected_path, Coverband::Reporters::Base.send(:relative_path_to_full, key, roots)
@@ -53,7 +53,7 @@ class ReportsBaseTest < Minitest::Test
53
53
  assert_equal expected_path, Coverband::Reporters::Base.send(:relative_path_to_full, key, roots)
54
54
  File.expects(:exist?).with('/var/local/company/company.d/[0-9]*/app/controllers/dashboard_controller.rb').returns(false)
55
55
  File.expects(:exist?).with(expected_path).returns(true)
56
- roots = ["/var/local/company/company.d/[0-9]*/", "#{current_app_root}/"]
56
+ roots = ['/var/local/company/company.d/[0-9]*/', "#{current_app_root}/"]
57
57
  assert_equal expected_path, Coverband::Reporters::Base.send(:relative_path_to_full, key, roots)
58
58
  end
59
59
 
@@ -97,7 +97,7 @@ class ReportsBaseTest < Minitest::Test
97
97
 
98
98
  test "#get_current_scov_data_imp doesn't ignore folders with default ignore keys" do
99
99
  @redis = Redis.new
100
- store = Coverband::Adapters::RedisStore.new(@redis)
100
+ store = Coverband::Adapters::RedisStore.new(@redis, redis_namespace: 'coverband_test')
101
101
  store.clear!
102
102
 
103
103
  Coverband.configure do |config|
@@ -140,7 +140,7 @@ class ReportsBaseTest < Minitest::Test
140
140
  "data"=>[16, 16, 16, nil, 16, 16, nil, nil, 16, nil, 16, 32, 32, nil, 32, 32, 32, 32, 32, 32, 32, nil, nil, 16, nil, 16, 32, 23, 0, 0, 0, 0, nil, nil, nil, nil, 0, 0, nil, nil, 16, 32, 32, 32, nil, nil, nil, nil, nil, 16, 32, nil, nil, 16, 32, nil, nil]}
141
141
  }
142
142
  @redis = Redis.new
143
- store = Coverband::Adapters::RedisStore.new(@redis)
143
+ store = Coverband::Adapters::RedisStore.new(@redis, redis_namespace: 'coverband_test')
144
144
  store.clear!
145
145
 
146
146
  Coverband.configure do |config|
@@ -8,7 +8,7 @@ class HTMLReportTest < Minitest::Test
8
8
  def setup
9
9
  super
10
10
  @redis = Redis.new
11
- @store = Coverband::Adapters::RedisStore.new(@redis)
11
+ @store = Coverband::Adapters::RedisStore.new(@redis, redis_namespace: 'coverband_test')
12
12
  @store.clear!
13
13
  end
14
14
 
@@ -16,7 +16,6 @@ class HTMLReportTest < Minitest::Test
16
16
  Coverband.configure do |config|
17
17
  config.reporter = 'std_out'
18
18
  config.store = @store
19
- config.reporting_frequency = 100.0
20
19
  end
21
20
  Coverband.configuration.logger.stubs('info')
22
21
  mock_file_hash
@@ -6,40 +6,103 @@ class ReportHTMLTest < Minitest::Test
6
6
  def setup
7
7
  super
8
8
  @redis = Redis.new
9
- @store = Coverband::Adapters::RedisStore.new(@redis)
9
+ @store = Coverband::Adapters::RedisStore.new(@redis, redis_namespace: 'coverband_test')
10
10
  @store.clear!
11
- end
12
-
13
- test 'generate scov html report' do
14
11
  Coverband.configure do |config|
15
- config.reporter = 'scov'
16
12
  config.store = @store
17
- config.s3_bucket = nil
13
+ config.root = fixtures_root
18
14
  config.ignore = ['notsomething.rb']
19
15
  end
20
16
  mock_file_hash
17
+ end
18
+
19
+ test 'generate dynamic content hosted html report' do
21
20
  @store.send(:save_report, basic_coverage)
22
21
 
23
22
  html = Coverband::Reporters::HTMLReport.new(@store,
24
- html: true,
25
- open_report: false).report
23
+ static: false,
24
+ open_report: false).report
26
25
  assert_match 'Generated by', html
27
26
  end
28
27
 
29
- test 'generate scov report file' do
28
+ test 'files with no Coverage but in project are shown in reports' do
29
+ @store.send(:save_report, basic_source_fixture_coverage)
30
+
31
+ html = Coverband::Reporters::HTMLReport.new(@store,
32
+ static: false,
33
+ open_report: false).report
34
+ assert_match 'sample.rb', html
35
+ # in project, but not in coverage data
36
+ assert_match 'app/models/user.rb', html
37
+ end
38
+
39
+ test 'Gem files with no coverage are shown in report' do
30
40
  Coverband.configure do |config|
31
- config.reporter = 'scov'
32
- config.store = @store
33
- config.s3_bucket = nil
34
- config.ignore = ['notsomething.rb']
41
+ config.track_gems = true
35
42
  end
36
- mock_file_hash
43
+ @store.send(:save_report, basic_source_fixture_coverage)
44
+
45
+ html = Coverband::Reporters::HTMLReport.new(@store,
46
+ static: false,
47
+ open_report: false).report
48
+ assert_match 'rainbow', html
49
+ end
50
+
51
+ test 'Gem files are not shown in report when not configured' do
52
+ Coverband.configure do |config|
53
+ config.track_gems = false
54
+ end
55
+ @store.send(:save_report, basic_source_fixture_coverage)
56
+
57
+ html = Coverband::Reporters::HTMLReport.new(@store,
58
+ static: false,
59
+ open_report: false).report
60
+ refute_match 'rainbow', html
61
+ end
62
+
63
+ test 'generate static HTML report file' do
37
64
  @store.send(:save_report, basic_coverage)
38
65
 
39
66
  reporter = Coverband::Reporters::HTMLReport.new(@store,
40
- html: false,
67
+ static: true,
41
68
  open_report: false)
42
- Coverband::Utils::HTMLFormatter.any_instance.expects(:format!).once
69
+ Coverband::Utils::HTMLFormatter.any_instance.expects(:format_static_html!).once
43
70
  reporter.report
44
71
  end
72
+
73
+ test 'generate dynamic content detailed file report' do
74
+ @store.send(:save_report, basic_coverage_full_path)
75
+
76
+ filename = basic_coverage_file_full_path
77
+ base_path = '/coverage'
78
+ html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
79
+ filename: filename,
80
+ base_path: base_path,
81
+ open_report: false).file_details
82
+ assert_match 'Coverage first seen', html
83
+ end
84
+
85
+ test 'generate dynamic content detailed file report handles missing file' do
86
+ @store.send(:save_report, basic_coverage_full_path)
87
+
88
+ filename = 'missing_path'
89
+ base_path = '/coverage'
90
+ html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
91
+ filename: filename,
92
+ base_path: base_path,
93
+ open_report: false).file_details
94
+ assert_match 'File No Longer Available', html
95
+ end
96
+
97
+ test 'generate dynamic content detailed file report does not allow loading real non project files' do
98
+ @store.send(:save_report, basic_coverage_full_path)
99
+
100
+ filename = "#{test_root}/test_helper.rb"
101
+ base_path = '/coverage'
102
+ html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
103
+ filename: filename,
104
+ base_path: base_path,
105
+ open_report: false).file_details
106
+ assert_match 'File No Longer Available', html
107
+ end
45
108
  end