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,13 +1,13 @@
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 ReportsBaseTest < Minitest::Test
6
6
  def setup
7
7
  super
8
8
  end
9
9
 
10
- test '#merge_arrays basic merge preserves order and counts' do
10
+ test "#merge_arrays basic merge preserves order and counts" do
11
11
  first = [0, 0, 1, 0, 1]
12
12
  second = [nil, 0, 1, 0, 0]
13
13
  expects = [0, 0, 2, 0, 1]
@@ -15,7 +15,7 @@ class ReportsBaseTest < Minitest::Test
15
15
  assert_equal expects, Coverband::Reporters::Base.send(:merge_arrays, first, second)
16
16
  end
17
17
 
18
- test '#merge_arrays basic merge preserves order and counts different lengths' do
18
+ test "#merge_arrays basic merge preserves order and counts different lengths" do
19
19
  first = [0, 0, 1, 0, 1]
20
20
  second = [nil, 0, 1, 0, 0, 0, 0, 1]
21
21
  expects = [0, 0, 2, 0, 1, 0, 0, 1]
@@ -23,7 +23,7 @@ class ReportsBaseTest < Minitest::Test
23
23
  assert_equal expects, Coverband::Reporters::Base.send(:merge_arrays, first, second)
24
24
  end
25
25
 
26
- test '#merge_arrays basic merge preserves nils' do
26
+ test "#merge_arrays basic merge preserves nils" do
27
27
  first = [0, 1, 2, nil, nil, nil]
28
28
  second = [0, 1, 2, nil, 0, 1, 2]
29
29
  expects = [0, 2, 4, nil, 0, 1, 2]
@@ -33,16 +33,16 @@ class ReportsBaseTest < Minitest::Test
33
33
 
34
34
  test "#get_current_scov_data_imp doesn't ignore folders with default ignore keys" do
35
35
  Coverband.configure do |config|
36
- config.reporter = 'std_out'
37
- config.root = '/full/remote_app/path'
36
+ config.reporter = "std_out"
37
+ config.root = "/full/remote_app/path"
38
38
  end
39
39
 
40
- key = '/a_path/that_has_erb_in/thepath.rb'
41
- roots = ['/app/', '/full/remote_app/path/']
40
+ key = "/a_path/that_has_erb_in/thepath.rb"
41
+ roots = ["/app/", "/full/remote_app/path/"]
42
42
 
43
43
  lines_hit = [1, 3, 6]
44
44
  store.stubs(:merged_coverage).returns(key => lines_hit)
45
- expected = { key => [1, 3, 6] }
45
+ expected = {key => [1, 3, 6]}
46
46
 
47
47
  assert_equal expected, Coverband::Reporters::Base.send(:get_current_scov_data_imp, store, roots)[:merged]
48
48
  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
  class HTMLReportTest < Minitest::Test
6
6
  REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
@@ -10,17 +10,17 @@ class HTMLReportTest < Minitest::Test
10
10
  @store = Coverband.configuration.store
11
11
  end
12
12
 
13
- test 'report data' do
13
+ test "report data" do
14
14
  Coverband.configure do |config|
15
- config.reporter = 'std_out'
15
+ config.reporter = "std_out"
16
16
  end
17
- Coverband.configuration.logger.stubs('info')
17
+ Coverband.configuration.logger.stubs("info")
18
18
  mock_file_hash
19
- Coverband::Utils::RelativeFileConverter.expects(:convert).with('app_path/dog.rb').returns('./dog.rb')
19
+ Coverband::Utils::RelativeFileConverter.expects(:convert).with("app_path/dog.rb").returns("./dog.rb")
20
20
  @store.send(:save_report, basic_coverage)
21
21
 
22
22
  report = Coverband::Reporters::ConsoleReport.report(@store)[:merged]
23
- expected = { './dog.rb' => [0, 1, 2] }
23
+ expected = {"./dog.rb" => [0, 1, 2]}
24
24
  assert_equal(expected.keys, report.keys)
25
25
  end
26
26
  end
@@ -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