coverband 4.2.7 → 5.0.0.rc.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) 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 +8 -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/coverband.rb +68 -44
  13. data/lib/coverband/adapters/base.rb +17 -18
  14. data/lib/coverband/adapters/file_store.rb +38 -6
  15. data/lib/coverband/adapters/hash_redis_store.rb +24 -21
  16. data/lib/coverband/adapters/redis_store.rb +12 -12
  17. data/lib/coverband/adapters/stdout_store.rb +41 -0
  18. data/lib/coverband/adapters/web_service_store.rb +155 -0
  19. data/lib/coverband/at_exit.rb +1 -1
  20. data/lib/coverband/collectors/coverage.rb +15 -27
  21. data/lib/coverband/collectors/delta.rb +29 -9
  22. data/lib/coverband/collectors/view_tracker.rb +10 -10
  23. data/lib/coverband/collectors/view_tracker_service.rb +59 -0
  24. data/lib/coverband/configuration.rb +149 -112
  25. data/lib/coverband/integrations/background.rb +6 -6
  26. data/lib/coverband/integrations/rack_server_check.rb +3 -3
  27. data/lib/coverband/reporters/base.rb +11 -12
  28. data/lib/coverband/reporters/console_report.rb +1 -1
  29. data/lib/coverband/reporters/html_report.rb +10 -30
  30. data/lib/coverband/reporters/web.rb +55 -50
  31. data/lib/coverband/utils/absolute_file_converter.rb +6 -6
  32. data/lib/coverband/utils/html_formatter.rb +32 -61
  33. data/lib/coverband/utils/railtie.rb +23 -6
  34. data/lib/coverband/utils/relative_file_converter.rb +2 -2
  35. data/lib/coverband/utils/result.rb +6 -11
  36. data/lib/coverband/utils/results.rb +0 -10
  37. data/lib/coverband/utils/source_file.rb +21 -30
  38. data/lib/coverband/utils/tasks.rb +8 -11
  39. data/lib/coverband/version.rb +1 -1
  40. data/public/application.js +0 -30
  41. data/test/benchmarks/benchmark.rake +97 -92
  42. data/test/benchmarks/dog.rb +1 -1
  43. data/test/benchmarks/init_rails.rake +4 -4
  44. data/test/coverband/adapters/base_test.rb +29 -30
  45. data/test/coverband/adapters/file_store_test.rb +19 -20
  46. data/test/coverband/adapters/hash_redis_store_test.rb +57 -57
  47. data/test/coverband/adapters/redis_store_test.rb +26 -26
  48. data/test/coverband/adapters/web_service_store_test.rb +56 -0
  49. data/test/coverband/at_exit_test.rb +2 -2
  50. data/test/coverband/collectors/coverage_test.rb +33 -47
  51. data/test/coverband/collectors/delta_test.rb +52 -23
  52. data/test/coverband/collectors/view_tracker_test.rb +35 -35
  53. data/test/coverband/configuration_test.rb +49 -36
  54. data/test/coverband/coverband_test.rb +11 -11
  55. data/test/coverband/integrations/background_middleware_test.rb +10 -10
  56. data/test/coverband/integrations/background_test.rb +17 -5
  57. data/test/coverband/integrations/rack_server_check_test.rb +7 -7
  58. data/test/coverband/integrations/report_middleware_test.rb +9 -9
  59. data/test/coverband/integrations/resque_worker_test.rb +9 -9
  60. data/test/coverband/integrations/test_resque_job.rb +1 -1
  61. data/test/coverband/reporters/base_test.rb +9 -9
  62. data/test/coverband/reporters/console_test.rb +6 -6
  63. data/test/coverband/reporters/html_test.rb +36 -48
  64. data/test/coverband/reporters/web_test.rb +16 -18
  65. data/test/coverband/utils/absolute_file_converter_test.rb +22 -22
  66. data/test/coverband/utils/file_hasher_test.rb +6 -12
  67. data/test/coverband/utils/file_list_test.rb +13 -13
  68. data/test/coverband/utils/html_formatter_test.rb +9 -23
  69. data/test/coverband/utils/lines_classifier_test.rb +29 -29
  70. data/test/coverband/utils/relative_file_converter_test.rb +13 -13
  71. data/test/coverband/utils/result_test.rb +18 -18
  72. data/test/coverband/utils/results_test.rb +17 -17
  73. data/test/coverband/utils/source_file_line_test.rb +46 -46
  74. data/test/coverband/utils/source_file_test.rb +38 -88
  75. data/test/dog.rb +1 -1
  76. data/test/fake_app/basic_rack.rb +2 -2
  77. data/test/fixtures/app/controllers/sample_controller.rb +1 -1
  78. data/test/fixtures/app/models/user.rb +1 -1
  79. data/test/fixtures/sample.rb +1 -1
  80. data/test/fixtures/utf-8.rb +0 -2
  81. data/test/forked/rails_full_stack_test.rb +24 -27
  82. data/test/forked/rails_rake_full_stack_test.rb +7 -26
  83. data/test/integration/full_stack_test.rb +11 -22
  84. data/test/jruby_check.rb +2 -3
  85. data/test/rails4_dummy/Rakefile +1 -1
  86. data/test/rails4_dummy/config.ru +1 -1
  87. data/test/rails4_dummy/config/application.rb +4 -4
  88. data/test/rails4_dummy/config/boot.rb +2 -2
  89. data/test/rails4_dummy/config/coverband.rb +1 -1
  90. data/test/rails4_dummy/config/coverband_missing_redis.rb +1 -1
  91. data/test/rails4_dummy/config/environment.rb +1 -1
  92. data/test/rails4_dummy/config/routes.rb +2 -2
  93. data/test/rails5_dummy/Rakefile +1 -1
  94. data/test/rails5_dummy/config.ru +1 -1
  95. data/test/rails5_dummy/config/application.rb +3 -3
  96. data/test/rails5_dummy/config/coverband.rb +8 -8
  97. data/test/rails5_dummy/config/coverband_missing_redis.rb +8 -8
  98. data/test/rails5_dummy/config/environment.rb +1 -1
  99. data/test/rails5_dummy/config/routes.rb +2 -2
  100. data/test/rails6_dummy/Rakefile +1 -1
  101. data/test/rails6_dummy/config.ru +1 -1
  102. data/test/rails6_dummy/config/application.rb +4 -4
  103. data/test/rails6_dummy/config/boot.rb +2 -2
  104. data/test/rails6_dummy/config/coverband.rb +1 -1
  105. data/test/rails6_dummy/config/coverband_missing_redis.rb +1 -1
  106. data/test/rails6_dummy/config/environment.rb +1 -1
  107. data/test/rails6_dummy/config/routes.rb +2 -2
  108. data/test/rails_test_helper.rb +11 -11
  109. data/test/test_helper.rb +44 -34
  110. data/test/unique_files.rb +10 -10
  111. data/views/layout.erb +2 -12
  112. metadata +28 -34
  113. data/.rubocop.yml +0 -86
  114. data/lib/coverband/integrations/bundler.rb +0 -8
  115. data/lib/coverband/utils/file_groups.rb +0 -53
  116. data/lib/coverband/utils/gem_list.rb +0 -31
  117. data/lib/coverband/utils/s3_report.rb +0 -105
  118. data/test/coverband/utils/file_groups_test.rb +0 -61
  119. data/test/coverband/utils/gem_list_test.rb +0 -48
  120. data/test/coverband/utils/s3_report_test.rb +0 -44
  121. data/views/gem_list.erb +0 -63
@@ -1,18 +1,18 @@
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 BaseTest < Minitest::Test
6
6
  def setup
7
+ Coverband.configuration.reset
7
8
  super
8
9
  Coverband.configuration.reset
9
10
  Coverband.configure do |config|
10
- config.root = Dir.pwd
11
- config.s3_bucket = nil
12
- config.root_paths = ['/app_path/']
13
- config.ignore = ['config/envionments']
14
- config.reporter = 'std_out'
15
- config.store = Coverband::Adapters::RedisStore.new(Coverband::Test.redis, redis_namespace: 'coverband_test')
11
+ config.root = Dir.pwd
12
+ config.root_paths = ["/app_path/"]
13
+ config.ignore = ["config/envionments"]
14
+ config.reporter = "std_out"
15
+ config.store = Coverband::Adapters::RedisStore.new(Coverband::Test.redis, redis_namespace: "coverband_test")
16
16
  end
17
17
  end
18
18
 
@@ -22,9 +22,9 @@ class BaseTest < Minitest::Test
22
22
  assert_equal expected, Coverband.configuration.ignore
23
23
  end
24
24
 
25
- test 'ignore works with plus equal' do
25
+ test "ignore works with plus equal" do
26
26
  Coverband.configure do |config|
27
- config.ignore += ['config/initializers']
27
+ config.ignore += ["config/initializers"]
28
28
  end
29
29
  Coverband::Collectors::Coverage.instance.reset_instance
30
30
  expected = ["vendor/",
@@ -38,23 +38,12 @@ class BaseTest < Minitest::Test
38
38
  assert_equal expected, Coverband.configuration.ignore
39
39
  end
40
40
 
41
- test 'ignore' do
42
- Coverband::Collectors::Coverage.instance.reset_instance
43
- assert !Coverband.configuration.gem_paths.first.nil?
44
- end
45
-
46
- test 'gem_paths' do
47
- Coverband::Collectors::Coverage.instance.reset_instance
48
- assert !Coverband.configuration.gem_paths.first.nil?
49
- end
50
-
51
- test 'groups' do
41
+ test "ignore" do
52
42
  Coverband::Collectors::Coverage.instance.reset_instance
53
- Coverband.configuration.track_gems = true
54
- assert_equal %w[App Gems], Coverband.configuration.groups.keys
43
+ assert !Coverband.configuration.ignore.first.nil?
55
44
  end
56
45
 
57
- test 'all_root_paths' do
46
+ test "all_root_paths" do
58
47
  Coverband::Collectors::Coverage.instance.reset_instance
59
48
  current_paths = Coverband.configuration.root_paths.dup
60
49
  # verify previous bug fix
@@ -64,30 +53,54 @@ class BaseTest < Minitest::Test
64
53
  assert_equal current_paths, Coverband.configuration.root_paths
65
54
  end
66
55
 
67
- test 's3 options' do
56
+ test "store raises when not set to supported adapter" do
57
+ Coverband::Collectors::Coverage.instance.reset_instance
58
+ assert_raises RuntimeError do
59
+ Coverband.configure do |config|
60
+ config.store = "fake"
61
+ end
62
+ end
63
+ end
64
+
65
+ test "store defaults to redis store" do
68
66
  Coverband::Collectors::Coverage.instance.reset_instance
67
+ assert_equal Coverband.configuration.store.class, Coverband::Adapters::RedisStore
68
+ end
69
+
70
+ test "store is a service store when api_key is set" do
71
+ Coverband::Collectors::Coverage.instance.reset_instance
72
+ Coverband.configuration.reset
69
73
  Coverband.configure do |config|
70
- config.s3_bucket = 'bucket'
71
- config.s3_region = 'region'
72
- config.s3_access_key_id = 'key_id'
73
- config.s3_secret_access_key = 'secret'
74
+ config.redis_url = nil
75
+ config.api_key = "test-key"
74
76
  end
75
- assert_equal 'bucket', Coverband.configuration.s3_bucket
76
- assert_equal 'region', Coverband.configuration.s3_region
77
- assert_equal 'key_id', Coverband.configuration.s3_access_key_id
78
- assert_equal 'secret', Coverband.configuration.s3_secret_access_key
77
+ assert_equal Coverband.configuration.store.class.to_s, "Coverband::Adapters::WebServiceStore"
79
78
  end
80
79
 
81
- test 'store raises issues' do
80
+ test "store raises when api key set but not set to service" do
82
81
  Coverband::Collectors::Coverage.instance.reset_instance
82
+ Coverband.configuration.reset
83
+ assert_raises RuntimeError do
84
+ Coverband.configure do |config|
85
+ config.api_key = "test-key"
86
+ config.redis_url = "redis://localhost:3333"
87
+ config.store = Coverband::Adapters::RedisStore.new(Coverband::Test.redis, redis_namespace: "coverband_test")
88
+ end
89
+ end
90
+ end
91
+
92
+ test "store raises when api key and redis_url" do
93
+ Coverband::Collectors::Coverage.instance.reset_instance
94
+ Coverband.configuration.reset
83
95
  assert_raises RuntimeError do
84
96
  Coverband.configure do |config|
85
- config.store = 'fake'
97
+ config.api_key = "test-key"
98
+ config.redis_url = "redis://localhost:3333"
86
99
  end
87
100
  end
88
101
  end
89
102
 
90
- test 'use_oneshot_lines_coverage' do
103
+ test "use_oneshot_lines_coverage" do
91
104
  refute Coverband.configuration.use_oneshot_lines_coverage
92
105
 
93
106
  Coverband.configuration.stubs(:one_shot_coverage_implemented_in_ruby_version?).returns(true)
@@ -101,7 +114,7 @@ class BaseTest < Minitest::Test
101
114
  exception = assert_raises Exception do
102
115
  Coverband.configuration.use_oneshot_lines_coverage = true
103
116
  end
104
- assert_equal 'One shot line coverage is only available in ruby >= 2.6', exception.message
117
+ assert_equal "One shot line coverage is only available in ruby >= 2.6", exception.message
105
118
  refute Coverband.configuration.use_oneshot_lines_coverage
106
119
  end
107
120
  end
@@ -1,42 +1,42 @@
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 CoverbandTest < Minitest::Test
6
- test 'Coverband#start kicks off background reporting if enabled and not in rack server' do
7
- Coverband.configuration.stubs(:background_reporting_enabled).returns(:true)
6
+ test "Coverband#start kicks off background reporting if enabled and not in rack server" do
7
+ Coverband.configuration.stubs(:background_reporting_enabled).returns(true)
8
8
  Coverband::RackServerCheck.expects(:running?).returns(false)
9
9
  Coverband::Background.expects(:start)
10
10
  Coverband.start
11
11
  end
12
12
 
13
- test 'Coverband#start delays background reporting if enabled and running in a rack server' do
13
+ test "Coverband#start delays background reporting if enabled and running in a rack server" do
14
14
  Coverband.configuration.stubs(:background_reporting_enabled).returns(true)
15
15
  Coverband::RackServerCheck.expects(:running?).returns(true)
16
16
  Coverband::Background.expects(:start).never
17
17
  Coverband.start
18
18
  end
19
19
 
20
- test 'Coverband#start does not kick off background reporting if not enabled' do
20
+ test "Coverband#start does not kick off background reporting if not enabled" do
21
21
  Coverband.configuration.stubs(:background_reporting_enabled).returns(false)
22
22
  Coverband::Background.expects(:start).never
23
23
  ::Coverband.start
24
24
  end
25
25
 
26
- test 'Coverband#configured? works' do
26
+ test "Coverband#configured? works" do
27
27
  Coverband.configure
28
28
  assert Coverband.configured?
29
29
  end
30
30
 
31
- test 'Eager load coverage block' do
32
- Coverband.eager_loading_coverage {
33
- #some code
31
+ test "Eager load coverage block" do
32
+ Coverband.eager_loading_coverage do
33
+ # some code
34
34
  1 + 1
35
- }
35
+ end
36
36
  assert_equal :runtime, Coverband.configuration.store.type
37
37
  end
38
38
 
39
- test 'Eager load coverage' do
39
+ test "Eager load coverage" do
40
40
  Coverband.eager_loading_coverage!
41
41
  assert_equal :eager_loading, Coverband.configuration.store.type
42
42
  Coverband.runtime_coverage!
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
- require 'rack'
3
+ require File.expand_path("../../test_helper", File.dirname(__FILE__))
4
+ require "rack"
5
5
 
6
6
  class BackgroundMiddlewareTest < Minitest::Test
7
7
  def setup
@@ -11,23 +11,23 @@ class BackgroundMiddlewareTest < Minitest::Test
11
11
  end
12
12
  end
13
13
 
14
- test 'call app' do
15
- request = Rack::MockRequest.env_for('/anything.json')
14
+ test "call app" do
15
+ request = Rack::MockRequest.env_for("/anything.json")
16
16
  Coverband::Collectors::Coverage.instance.reset_instance
17
17
  middleware = Coverband::BackgroundMiddleware.new(fake_app)
18
18
  results = middleware.call(request)
19
- assert_equal '/anything.json', results.last
19
+ assert_equal "/anything.json", results.last
20
20
  end
21
21
 
22
- test 'pass all rack lint checks' do
22
+ test "pass all rack lint checks" do
23
23
  Coverband::Collectors::Coverage.instance.reset_instance
24
24
  app = Rack::Lint.new(Coverband::BackgroundMiddleware.new(fake_app))
25
- env = Rack::MockRequest.env_for('/hello')
25
+ env = Rack::MockRequest.env_for("/hello")
26
26
  app.call(env)
27
27
  end
28
28
 
29
- test 'starts background reporter when configured' do
30
- request = Rack::MockRequest.env_for('/anything.json')
29
+ test "starts background reporter when configured" do
30
+ request = Rack::MockRequest.env_for("/anything.json")
31
31
  Coverband.configuration.stubs(:background_reporting_enabled).returns(true)
32
32
  Coverband::Background.expects(:start)
33
33
  middleware = Coverband::BackgroundMiddleware.new(fake_app)
@@ -38,7 +38,7 @@ class BackgroundMiddlewareTest < Minitest::Test
38
38
 
39
39
  def fake_app
40
40
  @fake_app ||= lambda do |env|
41
- [200, { 'Content-Type' => 'text/plain' }, env['PATH_INFO']]
41
+ [200, {"Content-Type" => "text/plain"}, env["PATH_INFO"]]
42
42
  end
43
43
  end
44
44
  end
@@ -1,28 +1,40 @@
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 BackgroundTest < Minitest::Test
6
6
  class ThreadDouble < Struct.new(:alive)
7
- def exit; end
7
+ def exit
8
+ end
8
9
 
9
10
  def alive?
10
11
  alive
11
12
  end
12
13
  end
13
14
 
15
+ def setup
16
+ Coverband.configuration.reset
17
+ super
18
+ Coverband.configure do |config|
19
+ config.background_reporting_sleep_seconds = 60
20
+ Coverband.configuration.reporting_wiggle = 0
21
+ end
22
+ end
23
+
14
24
  def test_start
25
+ sleep_seconds = Coverband.configuration.background_reporting_sleep_seconds.to_i
15
26
  Thread.expects(:new).yields.returns(ThreadDouble.new(true))
16
27
  Coverband::Background.expects(:loop).yields
17
- Coverband::Background.expects(:sleep).with(30)
28
+ Coverband::Background.expects(:sleep).with(sleep_seconds)
18
29
  Coverband::Collectors::Coverage.instance.expects(:report_coverage).once
19
30
  2.times { Coverband::Background.start }
20
31
  end
21
32
 
22
33
  def test_start_with_wiggle
34
+ sleep_seconds = Coverband.configuration.background_reporting_sleep_seconds.to_i
23
35
  Thread.expects(:new).yields.returns(ThreadDouble.new(true))
24
36
  Coverband::Background.expects(:loop).yields
25
- Coverband::Background.expects(:sleep).with(35)
37
+ Coverband::Background.expects(:sleep).with(sleep_seconds + 5)
26
38
  Coverband::Background.expects(:rand).with(10).returns(5)
27
39
  Coverband.configuration.reporting_wiggle = 10
28
40
  Coverband::Collectors::Coverage.instance.expects(:report_coverage).once
@@ -32,7 +44,7 @@ class BackgroundTest < Minitest::Test
32
44
  def test_start_dead_thread
33
45
  Thread.expects(:new).yields.returns(ThreadDouble.new(false)).twice
34
46
  Coverband::Background.expects(:loop).yields.twice
35
- Coverband::Background.expects(:sleep).with(30).twice
47
+ Coverband::Background.expects(:sleep).with(60).twice
36
48
  Coverband::Collectors::Coverage.instance.expects(:report_coverage).twice
37
49
  2.times { Coverband::Background.start }
38
50
  end
@@ -1,22 +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
  class RackServerCheckTest < Minitest::Test
6
- test 'returns true when running in rack server' do
7
- caller_locations = ['blah/lib/rack/server.rb'].map { |path| OpenStruct.new(path: path, label: 'foo') }
6
+ test "returns true when running in rack server" do
7
+ caller_locations = ["blah/lib/rack/server.rb"].map { |path| OpenStruct.new(path: path, label: "foo") }
8
8
  Kernel.expects(:caller_locations).returns(caller_locations)
9
9
  assert(Coverband::RackServerCheck.running?)
10
10
  end
11
11
 
12
- test 'returns false when not running in rack server' do
13
- caller_locations = ['blah/lib/sidekiq/worker.rb'].map { |path| OpenStruct.new(path: path, label: 'foo') }
12
+ test "returns false when not running in rack server" do
13
+ caller_locations = ["blah/lib/sidekiq/worker.rb"].map { |path| OpenStruct.new(path: path, label: "foo") }
14
14
  Kernel.expects(:caller_locations).returns(caller_locations)
15
15
  refute(Coverband::RackServerCheck.running?)
16
16
  end
17
17
 
18
- test 'returns true if running within a rails server' do
19
- caller_locations = [OpenStruct.new(path: '/lib/rails/commands/commands_tasks.rb', label: 'server')]
18
+ test "returns true if running within a rails server" do
19
+ caller_locations = [OpenStruct.new(path: "/lib/rails/commands/commands_tasks.rb", label: "server")]
20
20
  Kernel.expects(:caller_locations).returns(caller_locations)
21
21
  assert(Coverband::RackServerCheck.running?)
22
22
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
- require 'coverband/integrations/report_middleware'
3
+ require File.expand_path("../../test_helper", File.dirname(__FILE__))
4
+ require "coverband/integrations/report_middleware"
5
5
 
6
6
  class ReportMiddlewareTest < Minitest::Test
7
7
  def setup
@@ -11,21 +11,21 @@ class ReportMiddlewareTest < Minitest::Test
11
11
  end
12
12
  end
13
13
 
14
- test 'reports coverage' do
15
- request = Rack::MockRequest.env_for('/anything.json')
14
+ test "reports coverage" do
15
+ request = Rack::MockRequest.env_for("/anything.json")
16
16
  Coverband::Collectors::Coverage.instance.expects(:report_coverage)
17
17
  middleware = Coverband::ReportMiddleware.new(fake_app)
18
18
  middleware.call(request)
19
19
  end
20
20
 
21
- test 'reports coverage when an error is raised' do
22
- request = Rack::MockRequest.env_for('/anything.json')
21
+ test "reports coverage when an error is raised" do
22
+ request = Rack::MockRequest.env_for("/anything.json")
23
23
  Coverband::Collectors::Coverage.instance.reset_instance
24
24
  Coverband::Collectors::Coverage.instance.expects(:report_coverage).once
25
25
  middleware = Coverband::ReportMiddleware.new(fake_app_raise_error)
26
26
  begin
27
27
  middleware.call(request)
28
- rescue StandardError
28
+ rescue
29
29
  nil
30
30
  end
31
31
  end
@@ -34,11 +34,11 @@ class ReportMiddlewareTest < Minitest::Test
34
34
 
35
35
  def fake_app
36
36
  @fake_app ||= lambda do |env|
37
- [200, { 'Content-Type' => 'text/plain' }, env['PATH_INFO']]
37
+ [200, {"Content-Type" => "text/plain"}, env["PATH_INFO"]]
38
38
  end
39
39
  end
40
40
 
41
41
  def fake_app_raise_error
42
- @fake_app_raise_error ||= -> { raise 'hell' }
42
+ @fake_app_raise_error ||= -> { raise "hell" }
43
43
  end
44
44
  end
@@ -1,11 +1,11 @@
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 ResqueWorkerTest < Minitest::Test
6
6
  def enqueue_and_run_job
7
7
  Resque.enqueue(TestResqueJob)
8
- queue = ENV['QUEUE'] = 'resque_coverband'
8
+ ENV["QUEUE"] = "resque_coverband"
9
9
  worker = Resque::Worker.new
10
10
  worker.startup
11
11
  worker.work_one_job
@@ -21,9 +21,9 @@ class ResqueWorkerTest < Minitest::Test
21
21
  Resque.redis = redis
22
22
  end
23
23
 
24
- test 'resque job coverage' do
25
- relative_job_file = './test/coverband/integrations/test_resque_job.rb'
26
- resque_job_file = File.expand_path('./test_resque_job.rb', File.dirname(__FILE__))
24
+ test "resque job coverage" do
25
+ relative_job_file = "./test/coverband/integrations/test_resque_job.rb"
26
+ resque_job_file = File.expand_path("./test_resque_job.rb", File.dirname(__FILE__))
27
27
  require resque_job_file
28
28
 
29
29
  enqueue_and_run_job
@@ -35,13 +35,13 @@ class ResqueWorkerTest < Minitest::Test
35
35
  Coverband.runtime_coverage!
36
36
  report = Coverband.configuration.store.get_coverage_report
37
37
 
38
- if RUBY_PLATFORM == 'java'
38
+ if RUBY_PLATFORM == "java"
39
39
  # NOTE: the todo test only issue seems to be slightly different in JRuby
40
40
  # were nothing is showing up as runtime Coverage... This appears to be a test only issue
41
- assert_equal 1, report[Coverband::EAGER_TYPE][relative_job_file]['data'][6]
41
+ assert_equal 1, report[Coverband::EAGER_TYPE][relative_job_file]["data"][6]
42
42
  else
43
- assert_equal 0, report[Coverband::EAGER_TYPE][relative_job_file]['data'][6]
44
- assert_equal 1, report[Coverband::RUNTIME_TYPE][relative_job_file]['data'][6]
43
+ assert_equal 0, report[Coverband::EAGER_TYPE][relative_job_file]["data"][6]
44
+ assert_equal 1, report[Coverband::RUNTIME_TYPE][relative_job_file]["data"][6]
45
45
  end
46
46
  end
47
47
  end
@@ -4,6 +4,6 @@ class TestResqueJob
4
4
  @queue = :resque_coverband
5
5
 
6
6
  def self.perform
7
- 'resque job perform'
7
+ "resque job perform"
8
8
  end
9
9
  end
@@ -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