coverband 4.2.5.rc.2 → 5.0.0.rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +25 -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 +26 -30
  10. data/config.ru +1 -1
  11. data/coverband.gemspec +29 -34
  12. data/lib/alternative_coverband_patch.rb +5 -0
  13. data/lib/coverband.rb +55 -43
  14. data/lib/coverband/adapters/base.rb +17 -17
  15. data/lib/coverband/adapters/file_store.rb +2 -2
  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/at_exit.rb +1 -1
  19. data/lib/coverband/collectors/coverage.rb +15 -27
  20. data/lib/coverband/collectors/delta.rb +19 -9
  21. data/lib/coverband/collectors/view_tracker.rb +19 -11
  22. data/lib/coverband/configuration.rb +48 -84
  23. data/lib/coverband/integrations/background.rb +3 -3
  24. data/lib/coverband/integrations/rack_server_check.rb +3 -3
  25. data/lib/coverband/integrations/resque.rb +13 -1
  26. data/lib/coverband/reporters/base.rb +10 -10
  27. data/lib/coverband/reporters/console_report.rb +1 -1
  28. data/lib/coverband/reporters/html_report.rb +10 -30
  29. data/lib/coverband/reporters/web.rb +56 -49
  30. data/lib/coverband/utils/absolute_file_converter.rb +6 -6
  31. data/lib/coverband/utils/html_formatter.rb +32 -61
  32. data/lib/coverband/utils/railtie.rb +16 -4
  33. data/lib/coverband/utils/relative_file_converter.rb +2 -2
  34. data/lib/coverband/utils/result.rb +6 -11
  35. data/lib/coverband/utils/results.rb +0 -10
  36. data/lib/coverband/utils/source_file.rb +21 -30
  37. data/lib/coverband/utils/tasks.rb +7 -11
  38. data/lib/coverband/version.rb +1 -1
  39. data/public/application.js +0 -30
  40. data/test/benchmarks/benchmark.rake +97 -92
  41. data/test/benchmarks/dog.rb +1 -1
  42. data/test/benchmarks/init_rails.rake +4 -4
  43. data/test/coverband/adapters/base_test.rb +29 -30
  44. data/test/coverband/adapters/file_store_test.rb +15 -16
  45. data/test/coverband/adapters/hash_redis_store_test.rb +57 -57
  46. data/test/coverband/adapters/redis_store_test.rb +26 -26
  47. data/test/coverband/at_exit_test.rb +2 -2
  48. data/test/coverband/collectors/coverage_test.rb +33 -47
  49. data/test/coverband/collectors/delta_test.rb +51 -23
  50. data/test/coverband/collectors/view_tracker_test.rb +35 -35
  51. data/test/coverband/configuration_test.rb +27 -53
  52. data/test/coverband/coverband_test.rb +11 -11
  53. data/test/coverband/integrations/background_middleware_test.rb +10 -10
  54. data/test/coverband/integrations/background_test.rb +3 -2
  55. data/test/coverband/integrations/rack_server_check_test.rb +7 -7
  56. data/test/coverband/integrations/report_middleware_test.rb +9 -9
  57. data/test/coverband/integrations/resque_worker_test.rb +9 -9
  58. data/test/coverband/integrations/test_resque_job.rb +1 -1
  59. data/test/coverband/reporters/base_test.rb +9 -9
  60. data/test/coverband/reporters/console_test.rb +6 -6
  61. data/test/coverband/reporters/html_test.rb +36 -48
  62. data/test/coverband/reporters/web_test.rb +16 -18
  63. data/test/coverband/utils/absolute_file_converter_test.rb +22 -22
  64. data/test/coverband/utils/file_hasher_test.rb +6 -12
  65. data/test/coverband/utils/file_list_test.rb +13 -13
  66. data/test/coverband/utils/html_formatter_test.rb +9 -23
  67. data/test/coverband/utils/lines_classifier_test.rb +29 -29
  68. data/test/coverband/utils/relative_file_converter_test.rb +13 -13
  69. data/test/coverband/utils/result_test.rb +18 -18
  70. data/test/coverband/utils/results_test.rb +17 -17
  71. data/test/coverband/utils/source_file_line_test.rb +46 -46
  72. data/test/coverband/utils/source_file_test.rb +38 -88
  73. data/test/dog.rb +1 -1
  74. data/test/fake_app/basic_rack.rb +2 -2
  75. data/test/fixtures/app/controllers/sample_controller.rb +1 -1
  76. data/test/fixtures/app/models/user.rb +1 -1
  77. data/test/fixtures/sample.rb +1 -1
  78. data/test/fixtures/utf-8.rb +0 -2
  79. data/test/forked/rails_full_stack_test.rb +24 -27
  80. data/test/forked/rails_rake_full_stack_test.rb +7 -26
  81. data/test/integration/full_stack_test.rb +11 -22
  82. data/test/jruby_check.rb +2 -3
  83. data/test/rails4_dummy/Rakefile +1 -1
  84. data/test/rails4_dummy/config.ru +1 -1
  85. data/test/rails4_dummy/config/application.rb +4 -4
  86. data/test/rails4_dummy/config/boot.rb +2 -2
  87. data/test/rails4_dummy/config/coverband.rb +1 -1
  88. data/test/rails4_dummy/config/coverband_missing_redis.rb +1 -1
  89. data/test/rails4_dummy/config/environment.rb +1 -1
  90. data/test/rails4_dummy/config/routes.rb +2 -2
  91. data/test/rails5_dummy/Rakefile +1 -1
  92. data/test/rails5_dummy/config.ru +1 -1
  93. data/test/rails5_dummy/config/application.rb +3 -3
  94. data/test/rails5_dummy/config/coverband.rb +8 -8
  95. data/test/rails5_dummy/config/coverband_missing_redis.rb +8 -8
  96. data/test/rails5_dummy/config/environment.rb +1 -1
  97. data/test/rails5_dummy/config/routes.rb +2 -2
  98. data/test/rails6_dummy/Rakefile +1 -1
  99. data/test/rails6_dummy/config.ru +1 -1
  100. data/test/rails6_dummy/config/application.rb +4 -4
  101. data/test/rails6_dummy/config/boot.rb +2 -2
  102. data/test/rails6_dummy/config/coverband.rb +1 -1
  103. data/test/rails6_dummy/config/coverband_missing_redis.rb +1 -1
  104. data/test/rails6_dummy/config/environment.rb +1 -1
  105. data/test/rails6_dummy/config/routes.rb +2 -2
  106. data/test/rails_test_helper.rb +11 -11
  107. data/test/test_helper.rb +41 -34
  108. data/test/unique_files.rb +10 -10
  109. data/views/layout.erb +2 -12
  110. metadata +5 -43
  111. data/.rubocop.yml +0 -84
  112. data/lib/coverband/integrations/bundler.rb +0 -8
  113. data/lib/coverband/utils/file_groups.rb +0 -53
  114. data/lib/coverband/utils/gem_list.rb +0 -31
  115. data/lib/coverband/utils/s3_report.rb +0 -105
  116. data/test/coverband/utils/file_groups_test.rb +0 -61
  117. data/test/coverband/utils/gem_list_test.rb +0 -48
  118. data/test/coverband/utils/s3_report_test.rb +0 -44
  119. data/views/gem_list.erb +0 -63
@@ -1,95 +1,83 @@
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
  class ReportHTMLTest < Minitest::Test
6
6
  def setup
7
7
  super
8
8
  @store = Coverband.configuration.store
9
9
  Coverband.configure do |config|
10
- config.store = @store
11
- config.root = fixtures_root
12
- config.ignore = ['notsomething.rb', 'lib/*']
10
+ config.store = @store
11
+ config.root = fixtures_root
12
+ config.ignore = ["notsomething.rb", "lib/*"]
13
13
  end
14
14
  mock_file_hash
15
15
  end
16
16
 
17
- test 'generate dynamic content hosted html report' do
17
+ test "generate dynamic content hosted html report" do
18
18
  @store.send(:save_report, basic_coverage)
19
19
 
20
20
  html = Coverband::Reporters::HTMLReport.new(@store,
21
- static: false,
22
- open_report: false).report
23
- assert_match 'Generated by', html
21
+ open_report: false).report
22
+ assert_match "Generated by", html
24
23
  end
25
24
 
26
- test 'files with no Coverage but in project are shown in reports' do
25
+ test "files with no Coverage but in project are shown in reports" do
27
26
  @store.send(:save_report, basic_source_fixture_coverage)
28
27
 
29
28
  html = Coverband::Reporters::HTMLReport.new(@store,
30
- static: false,
31
- open_report: false).report
32
- assert_match 'sample.rb', html
29
+ open_report: false).report
30
+ assert_match "sample.rb", html
33
31
  # in project, but not in coverage data
34
- assert_match 'app/models/user.rb', html
32
+ assert_match "app/models/user.rb", html
35
33
  end
36
34
 
37
- test 'files with no Coverage but in project details page list warning' do
35
+ test "files with no Coverage but in project details page list warning" do
38
36
  @store.send(:save_report, basic_coverage_full_path)
39
37
 
40
- filename = basic_coverage_file_full_path
38
+ basic_coverage_file_full_path
41
39
  base_path = Dir.pwd
42
40
  # in project, but not in coverage data
43
41
  html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
44
- filename: "#{Dir.pwd}/test/fixtures/app/models/user.rb",
45
- base_path: base_path,
46
- open_report: false).file_details
47
- assert_match 'This file was never loaded', html
48
- end
49
-
50
- test 'generate static HTML report file' do
51
- @store.send(:save_report, basic_coverage)
52
-
53
- reporter = Coverband::Reporters::HTMLReport.new(@store,
54
- static: true,
55
- open_report: false)
56
- Coverband::Utils::HTMLFormatter.any_instance.expects(:format_static_html!).once
57
- reporter.report
42
+ filename: "#{Dir.pwd}/test/fixtures/app/models/user.rb",
43
+ base_path: base_path,
44
+ open_report: false).file_details
45
+ assert_match "This file was never loaded", html
58
46
  end
59
47
 
60
- test 'generate dynamic content detailed file report' do
48
+ test "generate dynamic content detailed file report" do
61
49
  @store.send(:save_report, basic_coverage_full_path)
62
50
 
63
51
  filename = basic_coverage_file_full_path
64
- base_path = '/coverage'
52
+ base_path = "/coverage"
65
53
  html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
66
- filename: filename,
67
- base_path: base_path,
68
- open_report: false).file_details
69
- assert_match 'Coverage first seen', html
54
+ filename: filename,
55
+ base_path: base_path,
56
+ open_report: false).file_details
57
+ assert_match "Coverage first seen", html
70
58
  end
71
59
 
72
- test 'generate dynamic content detailed file report handles missing file' do
60
+ test "generate dynamic content detailed file report handles missing file" do
73
61
  @store.send(:save_report, basic_coverage_full_path)
74
62
 
75
- filename = 'missing_path'
76
- base_path = '/coverage'
63
+ filename = "missing_path"
64
+ base_path = "/coverage"
77
65
  html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
78
- filename: filename,
79
- base_path: base_path,
80
- open_report: false).file_details
81
- assert_match 'File No Longer Available', html
66
+ filename: filename,
67
+ base_path: base_path,
68
+ open_report: false).file_details
69
+ assert_match "File No Longer Available", html
82
70
  end
83
71
 
84
- test 'generate dynamic content detailed file report does not allow loading real non project files' do
72
+ test "generate dynamic content detailed file report does not allow loading real non project files" do
85
73
  @store.send(:save_report, basic_coverage_full_path)
86
74
 
87
75
  filename = "#{test_root}/test_helper.rb"
88
- base_path = '/coverage'
76
+ base_path = "/coverage"
89
77
  html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
90
- filename: filename,
91
- base_path: base_path,
92
- open_report: false).file_details
93
- assert_match 'File No Longer Available', html
78
+ filename: filename,
79
+ base_path: base_path,
80
+ open_report: false).file_details
81
+ assert_match "File No Longer Available", html
94
82
  end
95
83
  end
@@ -1,13 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
- require 'aws-sdk-s3'
5
- require File.expand_path('../../../lib/coverband/reporters/web', File.dirname(__FILE__))
6
- require 'rack/test'
3
+ require File.expand_path("../../test_helper", File.dirname(__FILE__))
4
+ require File.expand_path("../../../lib/coverband/reporters/web", File.dirname(__FILE__))
5
+ require "rack/test"
7
6
 
8
- ENV['RACK_ENV'] = 'test'
7
+ ENV["RACK_ENV"] = "test"
9
8
 
10
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
9
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.2.0")
11
10
  module Coverband
12
11
  class WebTest < Minitest::Test
13
12
  include Rack::Test::Methods
@@ -18,29 +17,28 @@ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
18
17
 
19
18
  def teardown
20
19
  super
21
- Coverband.configuration.s3_bucket = nil
22
20
  end
23
21
 
24
- test 'renders index content' do
25
- get '/'
22
+ test "renders index content" do
23
+ get "/"
26
24
  assert last_response.ok?
27
- assert_match 'Coverband Admin', last_response.body
25
+ assert_match "Coverband Admin", last_response.body
28
26
  end
29
27
 
30
- test 'renders index content for empty path' do
31
- get ''
28
+ test "renders index content for empty path" do
29
+ get ""
32
30
  assert last_response.ok?
33
- assert_match 'Coverband Admin', last_response.body
31
+ assert_match "Coverband Admin", last_response.body
34
32
  end
35
33
 
36
- test 'renders 404' do
37
- get '/show'
34
+ test "renders 404" do
35
+ get "/show"
38
36
  assert last_response.not_found?
39
- assert_equal '404 error!', last_response.body
37
+ assert_equal "404 error!", last_response.body
40
38
  end
41
39
 
42
- test 'clears coverband' do
43
- post '/clear'
40
+ test "clears coverband" do
41
+ post "/clear"
44
42
  assert_equal 301, last_response.status
45
43
  end
46
44
  end
@@ -1,53 +1,53 @@
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
  module Coverband
6
6
  module Utils
7
7
  class AbsoluteFileConverterTest < ::Minitest::Test
8
8
  def test_convert
9
9
  converter = AbsoluteFileConverter.new([FileUtils.pwd])
10
- assert_equal("#{FileUtils.pwd}/lib/coverband.rb", converter.convert('./lib/coverband.rb'))
10
+ assert_equal("#{FileUtils.pwd}/lib/coverband.rb", converter.convert("./lib/coverband.rb"))
11
11
  end
12
12
 
13
13
  def test_convert_multiple_roots
14
- converter = AbsoluteFileConverter.new(['/foo/bar', FileUtils.pwd])
15
- assert_equal("#{FileUtils.pwd}/Rakefile", converter.convert('./Rakefile'))
14
+ converter = AbsoluteFileConverter.new(["/foo/bar", FileUtils.pwd])
15
+ assert_equal("#{FileUtils.pwd}/Rakefile", converter.convert("./Rakefile"))
16
16
  end
17
17
 
18
- test 'relative_path_to_full leave filename from a key with a local path' do
19
- converter = AbsoluteFileConverter.new(['/app/', '/full/remote_app/path/'])
20
- assert_equal '/full/remote_app/path/is/a/path.rb', converter.convert('/full/remote_app/path/is/a/path.rb')
18
+ test "relative_path_to_full leave filename from a key with a local path" do
19
+ converter = AbsoluteFileConverter.new(["/app/", "/full/remote_app/path/"])
20
+ assert_equal "/full/remote_app/path/is/a/path.rb", converter.convert("/full/remote_app/path/is/a/path.rb")
21
21
  end
22
22
 
23
- test 'relative_path_to_full fix filename from a key with a swappable path' do
24
- key = '/app/is/a/path.rb'
25
- converter = AbsoluteFileConverter.new(['/app/', '/full/remote_app/path/'])
26
- expected_path = '/full/remote_app/path/is/a/path.rb'
23
+ test "relative_path_to_full fix filename from a key with a swappable path" do
24
+ key = "/app/is/a/path.rb"
25
+ converter = AbsoluteFileConverter.new(["/app/", "/full/remote_app/path/"])
26
+ expected_path = "/full/remote_app/path/is/a/path.rb"
27
27
  File.expects(:exist?).with(key).returns(false)
28
28
  File.expects(:exist?).with(expected_path).returns(true)
29
29
  assert_equal expected_path, converter.convert(key)
30
30
  end
31
31
 
32
- test 'relative_path_to_full fix filename a changing deploy path with quotes' do
33
- converter = AbsoluteFileConverter.new(['/box/apps/app_name/releases/\\d+/', '/full/remote_app/path/'])
34
- expected_path = '/full/remote_app/path/app/models/user.rb'
35
- key = '/box/apps/app_name/releases/20140725203539/app/models/user.rb'
32
+ test "relative_path_to_full fix filename a changing deploy path with quotes" do
33
+ converter = AbsoluteFileConverter.new(['/box/apps/app_name/releases/\\d+/', "/full/remote_app/path/"])
34
+ expected_path = "/full/remote_app/path/app/models/user.rb"
35
+ key = "/box/apps/app_name/releases/20140725203539/app/models/user.rb"
36
36
  File.expects(:exist?).with('/box/apps/app_name/releases/\\d+/app/models/user.rb').returns(false)
37
37
  File.expects(:exist?).with(expected_path).returns(true)
38
38
  assert_equal expected_path, converter.convert(key)
39
39
  assert_equal expected_path, converter.convert(key)
40
40
  end
41
41
 
42
- test 'relative_path_to_full fix filename a changing deploy path real world examples' do
43
- current_app_root = '/var/local/company/company.d/79'
44
- converter = AbsoluteFileConverter.new(['/var/local/company/company.d/[0-9]*/', "#{current_app_root}/"])
42
+ test "relative_path_to_full fix filename a changing deploy path real world examples" do
43
+ current_app_root = "/var/local/company/company.d/79"
44
+ converter = AbsoluteFileConverter.new(["/var/local/company/company.d/[0-9]*/", "#{current_app_root}/"])
45
45
 
46
- expected_path = '/var/local/company/company.d/79/app/controllers/dashboard_controller.rb'
47
- key = '/var/local/company/company.d/78/app/controllers/dashboard_controller.rb'
48
- File.expects(:exist?).with('/var/local/company/company.d/[0-9]*/app/controllers/dashboard_controller.rb').returns(false)
46
+ expected_path = "/var/local/company/company.d/79/app/controllers/dashboard_controller.rb"
47
+ key = "/var/local/company/company.d/78/app/controllers/dashboard_controller.rb"
48
+ File.expects(:exist?).with("/var/local/company/company.d/[0-9]*/app/controllers/dashboard_controller.rb").returns(false)
49
49
  File.expects(:exist?).with(expected_path).returns(true)
50
- roots = ['/var/local/company/company.d/[0-9]*/', "#{current_app_root}/"]
50
+ # roots = ["/var/local/company/company.d/[0-9]*/", "#{current_app_root}/"]
51
51
  assert_equal expected_path, converter.convert(key)
52
52
  assert_equal expected_path, converter.convert(key)
53
53
  end
@@ -1,28 +1,22 @@
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
  module Coverband
6
6
  module Utils
7
7
  class FileHasherTest < Minitest::Test
8
8
  def test_hash_same_file
9
- refute_nil FileHasher.hash('./test/dog.rb')
10
- assert_equal(FileHasher.hash('./test/dog.rb'), FileHasher.hash('./test/dog.rb'))
11
- assert_equal(FileHasher.hash(File.expand_path('./test/dog.rb')), FileHasher.hash('./test/dog.rb'))
9
+ refute_nil FileHasher.hash("./test/dog.rb")
10
+ assert_equal(FileHasher.hash("./test/dog.rb"), FileHasher.hash("./test/dog.rb"))
11
+ assert_equal(FileHasher.hash(File.expand_path("./test/dog.rb")), FileHasher.hash("./test/dog.rb"))
12
12
  end
13
13
 
14
14
  def test_hash_different_files
15
- refute_equal(FileHasher.hash('./test/dog.rb'), FileHasher.hash('./lib/coverband.rb'))
15
+ refute_equal(FileHasher.hash("./test/dog.rb"), FileHasher.hash("./lib/coverband.rb"))
16
16
  end
17
17
 
18
18
  def test_hash_file_not_exists
19
- assert_nil(FileHasher.hash('./made_up_file.py'))
20
- end
21
-
22
- def test_hash_gem_file
23
- spec = Gem::Specification.find_by_name('rainbow')
24
- assert FileHasher.hash("./gems/rainbow-#{spec.version}/lib/rainbow.rb",
25
- path_converter: AbsoluteFileConverter.new(Coverband.configuration.gem_paths))
19
+ assert_nil(FileHasher.hash("./made_up_file.py"))
26
20
  end
27
21
  end
28
22
  end
@@ -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
@@ -9,46 +9,46 @@ require File.expand_path('../../test_helper', File.dirname(__FILE__))
9
9
  describe Coverband::Utils::FileList do
10
10
  subject do
11
11
  original_result = {
12
- source_fixture('sample.rb') => {'first_updated_at' => Time.at(0), 'data' => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]},
13
- source_fixture('app/models/user.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
14
- source_fixture('app/controllers/sample_controller.rb') => [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]
12
+ source_fixture("sample.rb") => {"first_updated_at" => Time.at(0), "data" => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]},
13
+ source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
14
+ source_fixture("app/controllers/sample_controller.rb") => [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]
15
15
  }
16
16
  Coverband::Utils::Result.new(original_result).files
17
17
  end
18
18
 
19
- it 'has 11 covered lines' do
19
+ it "has 11 covered lines" do
20
20
  assert_equal 11, subject.covered_lines
21
21
  end
22
22
 
23
- it 'has 3 missed lines' do
23
+ it "has 3 missed lines" do
24
24
  assert_equal 3, subject.missed_lines
25
25
  end
26
26
 
27
- it 'has 17 never lines' do
27
+ it "has 17 never lines" do
28
28
  assert_equal 17, subject.never_lines
29
29
  end
30
30
 
31
- it 'has 14 lines of code' do
31
+ it "has 14 lines of code" do
32
32
  assert_equal 14, subject.lines_of_code
33
33
  end
34
34
 
35
- it 'has 5 skipped lines' do
35
+ it "has 5 skipped lines" do
36
36
  assert_equal 5, subject.skipped_lines
37
37
  end
38
38
 
39
- it 'has the correct covered percent' do
39
+ it "has the correct covered percent" do
40
40
  assert_equal 78.57142857142857, subject.covered_percent
41
41
  end
42
42
 
43
- it 'has the correct covered percentages' do
43
+ it "has the correct covered percentages" do
44
44
  assert_equal [50.0, 80.0, 100.0], subject.covered_percentages
45
45
  end
46
46
 
47
- it 'has the correct covered strength' do
47
+ it "has the correct covered strength" do
48
48
  assert_equal 0.9285714285714286, subject.covered_strength
49
49
  end
50
50
 
51
- it 'has correct first_seen_at' do
51
+ it "has correct first_seen_at" do
52
52
  assert_equal Time.at(0), subject.first_seen_at
53
53
  end
54
54
  end
@@ -1,41 +1,27 @@
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
  class HTMLFormatterTest < Minitest::Test
6
6
  def setup
7
7
  super
8
- @store = Coverband::Adapters::RedisStore.new(Coverband::Test.redis, redis_namespace: 'coverband_test')
8
+ @store = Coverband::Adapters::RedisStore.new(Coverband::Test.redis, redis_namespace: "coverband_test")
9
9
  end
10
10
 
11
- test 'generate dynamic content hosted html report' do
11
+ test "generate dynamic content hosted html report" do
12
12
  Coverband.configure do |config|
13
- config.store = @store
14
- config.ignore = ['notsomething.rb']
13
+ config.store = @store
14
+ config.ignore = ["notsomething.rb"]
15
15
  end
16
16
  mock_file_hash
17
17
  @store.send(:save_report, basic_coverage_full_path)
18
18
 
19
19
  notice = nil
20
- base_path = '/coverage'
20
+ base_path = "/coverage"
21
21
  filtered_report_files = Coverband::Reporters::Base.report(@store, {})
22
22
  html = Coverband::Utils::HTMLFormatter.new(filtered_report_files,
23
- base_path: base_path,
24
- notice: notice).format_dynamic_html!
25
- assert_match 'loading source data', html
26
- end
27
-
28
- test 'generate static HTML report file' do
29
- Coverband.configure do |config|
30
- config.store = @store
31
- config.ignore = ['notsomething.rb']
32
- end
33
- mock_file_hash
34
- @store.send(:save_report, basic_coverage_full_path)
35
-
36
- filtered_report_files = Coverband::Reporters::Base.report(@store, {})
37
- Coverband::Utils::HTMLFormatter.new(filtered_report_files).format_static_html!
38
- html = File.read("#{Coverband.configuration.root}/coverage/index.html")
39
- assert_match 'Coverage first seen', html
23
+ base_path: base_path,
24
+ notice: notice).format_dynamic_html!
25
+ assert_match "loading source data", html
40
26
  end
41
27
  end
@@ -1,34 +1,34 @@
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
7
7
  # initial version of test pulled into Coverband from Simplecov 12/17/2018
8
8
  ####
9
9
  describe Coverband::Utils::LinesClassifier do
10
- describe '#classify' do
10
+ describe "#classify" do
11
11
  def subject
12
12
  Coverband::Utils::LinesClassifier.new
13
13
  end
14
14
 
15
- describe 'relevant lines' do
16
- it 'determines code as relevant' do
15
+ describe "relevant lines" do
16
+ it "determines code as relevant" do
17
17
  classified_lines = subject.classify [
18
- 'module Foo',
19
- ' class Baz',
20
- ' def Bar',
18
+ "module Foo",
19
+ " class Baz",
20
+ " def Bar",
21
21
  " puts 'hi'",
22
- ' end',
23
- ' end',
24
- 'end'
22
+ " end",
23
+ " end",
24
+ "end"
25
25
  ]
26
26
 
27
27
  assert_equal 7, classified_lines.length
28
28
  assert(classified_lines.all? { |line| line == Coverband::Utils::LinesClassifier::RELEVANT })
29
29
  end
30
30
 
31
- it 'determines invalid UTF-8 byte sequences as relevant' do
31
+ it "determines invalid UTF-8 byte sequences as relevant" do
32
32
  classified_lines = subject.classify [
33
33
  "bytes = \"\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\""
34
34
  ]
@@ -38,11 +38,11 @@ describe Coverband::Utils::LinesClassifier do
38
38
  end
39
39
  end
40
40
 
41
- describe 'not-relevant lines' do
42
- it 'determines whitespace is not-relevant' do
41
+ describe "not-relevant lines" do
42
+ it "determines whitespace is not-relevant" do
43
43
  classified_lines = subject.classify [
44
- '',
45
- ' ',
44
+ "",
45
+ " ",
46
46
  "\t\t"
47
47
  ]
48
48
 
@@ -50,11 +50,11 @@ describe Coverband::Utils::LinesClassifier do
50
50
  assert(classified_lines.all? { |line| line == Coverband::Utils::LinesClassifier::NOT_RELEVANT })
51
51
  end
52
52
 
53
- describe 'comments' do
54
- it 'determines comments are not-relevant' do
53
+ describe "comments" do
54
+ it "determines comments are not-relevant" do
55
55
  classified_lines = subject.classify [
56
- '#Comment',
57
- ' # Leading space comment',
56
+ "#Comment",
57
+ " # Leading space comment",
58
58
  "\t# Leading tab comment"
59
59
  ]
60
60
 
@@ -72,27 +72,27 @@ describe Coverband::Utils::LinesClassifier do
72
72
  end
73
73
  end
74
74
 
75
- describe ':nocov: blocks' do
76
- it 'determines :nocov: blocks are not-relevant' do
75
+ describe ":nocov: blocks" do
76
+ it "determines :nocov: blocks are not-relevant" do
77
77
  classified_lines = subject.classify [
78
- '# :nocov:',
79
- 'def hi',
80
- 'end',
81
- '# :nocov:'
78
+ "# :nocov:",
79
+ "def hi",
80
+ "end",
81
+ "# :nocov:"
82
82
  ]
83
83
 
84
84
  assert_equal 4, classified_lines.length
85
85
  assert(classified_lines.all? { |line| line == Coverband::Utils::LinesClassifier::NOT_RELEVANT })
86
86
  end
87
87
 
88
- it 'determines all lines after a non-closing :nocov: as not-relevant' do
88
+ it "determines all lines after a non-closing :nocov: as not-relevant" do
89
89
  classified_lines = subject.classify [
90
- '# :nocov:',
90
+ "# :nocov:",
91
91
  "puts 'Not relevant'",
92
- '# :nocov:',
92
+ "# :nocov:",
93
93
  "puts 'Relevant again'",
94
94
  "puts 'Still relevant'",
95
- '# :nocov:',
95
+ "# :nocov:",
96
96
  "puts 'Not relevant till the end'",
97
97
  "puts 'Ditto'"
98
98
  ]