coverband 5.2.5.rc.1 → 5.2.5.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +6 -1
  3. data/Gemfile +2 -10
  4. data/{Gemfile.rails4 → Gemfile.rails7} +2 -1
  5. data/changes.md +8 -0
  6. data/coverband.gemspec +3 -3
  7. data/diagram.svg +1 -1
  8. data/lib/coverband/adapters/hash_redis_store.rb +1 -1
  9. data/lib/coverband/adapters/redis_store.rb +0 -2
  10. data/lib/coverband/collectors/route_tracker.rb +175 -0
  11. data/lib/coverband/configuration.rb +4 -1
  12. data/lib/coverband/integrations/background.rb +1 -0
  13. data/lib/coverband/reporters/web.rb +41 -4
  14. data/lib/coverband/utils/html_formatter.rb +8 -0
  15. data/lib/coverband/utils/rails6_ext.rb +58 -0
  16. data/lib/coverband/utils/railtie.rb +20 -0
  17. data/lib/coverband/version.rb +1 -1
  18. data/lib/coverband.rb +1 -0
  19. data/test/benchmarks/benchmark.rake +0 -1
  20. data/test/coverband/collectors/route_tracker_test.rb +125 -0
  21. data/test/coverband/collectors/view_tracker_test.rb +1 -1
  22. data/test/coverband/reporters/web_test.rb +1 -1
  23. data/test/forked/rails_full_stack_views_test.rb +5 -0
  24. data/test/forked/rails_route_tracker_stack_test.rb +45 -0
  25. data/test/forked/rails_view_tracker_stack_test.rb +1 -1
  26. data/test/rails5_dummy/config/coverband.rb +1 -2
  27. data/test/rails7_dummy/Rakefile +6 -0
  28. data/test/rails7_dummy/app/controllers/dummy_controller.rb +5 -0
  29. data/test/rails7_dummy/app/controllers/dummy_view_controller.rb +16 -0
  30. data/test/rails7_dummy/app/views/dummy_view/show.html.erb +5 -0
  31. data/test/rails7_dummy/app/views/dummy_view/show_haml.html.haml +4 -0
  32. data/test/rails7_dummy/app/views/dummy_view/show_slim.html.slim +4 -0
  33. data/test/rails7_dummy/config/application.rb +15 -0
  34. data/test/rails7_dummy/config/boot.rb +3 -0
  35. data/test/rails7_dummy/config/coverband.rb +3 -0
  36. data/test/rails7_dummy/config/coverband_missing_redis.rb +3 -0
  37. data/test/rails7_dummy/config/environment.rb +5 -0
  38. data/test/rails7_dummy/config/routes.rb +7 -0
  39. data/test/rails7_dummy/config/secrets.yml +3 -0
  40. data/test/rails7_dummy/config.ru +4 -0
  41. data/test/rails7_dummy/tmp/.keep +0 -0
  42. data/test/test_helper.rb +2 -4
  43. data/views/nav.erb +7 -2
  44. data/views/route_tracker.erb +49 -0
  45. data/views/view_tracker.erb +1 -1
  46. metadata +41 -5
  47. data/Gemfile.rails6 +0 -9
@@ -10,8 +10,7 @@ Coverband.configure do |config|
10
10
  config.logger = Rails.logger
11
11
  config.verbose = true
12
12
  config.background_reporting_enabled = true
13
- config.track_gems = true
14
- config.gem_details = true
13
+ config.track_routes = true
15
14
  config.use_oneshot_lines_coverage = true if ENV["ONESHOT"]
16
15
  config.simulate_oneshot_lines_coverage = true if ENV["SIMULATE_ONESHOT"]
17
16
  end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative "config/application"
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,5 @@
1
+ class DummyController < ActionController::Base
2
+ def show
3
+ render plain: "I am no dummy"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ class DummyViewController < ActionController::Base
2
+ def show
3
+ @text = "I am no dummy view tracker text"
4
+ render layout: false
5
+ end
6
+
7
+ def show_haml
8
+ @text = "I am haml text"
9
+ render layout: false
10
+ end
11
+
12
+ def show_slim
13
+ @text = "I am slim text"
14
+ render layout: false
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ rendered view
2
+
3
+ <div>
4
+ <%= @text %>
5
+ </div>
@@ -0,0 +1,4 @@
1
+ rendered haml view
2
+
3
+ #foo
4
+ = @text
@@ -0,0 +1,4 @@
1
+ rendered slim view
2
+
3
+ #content
4
+ = @text
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("boot", __dir__)
4
+
5
+ require "rails"
6
+ require "action_controller/railtie"
7
+ require "coverband"
8
+ Bundler.require(*Rails.groups)
9
+
10
+ module Rails6Dummy
11
+ class Application < Rails::Application
12
+ config.eager_load = true
13
+ config.consider_all_requests_local = true
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../rails5_dummy/config/coverband"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../rails5_dummy/config/coverband_missing_redis"
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path("../application", __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,7 @@
1
+ Rails.application.routes.draw do
2
+ get "dummy/show"
3
+ get "dummy_view/show", to: "dummy_view#show"
4
+ get "dummy_view/show_haml", to: "dummy_view#show_haml"
5
+ get "dummy_view/show_slim", to: "dummy_view#show_slim"
6
+ mount Coverband::Reporters::Web.new, at: "/coverage"
7
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ secret_key_base: 8080f2894307a3dcf72127c0a279a729c58c7c10c11a15de761c8e16017e0e478647d1a7ac11bf143730cac7b6901fa000428c6b4873d9298250f8ca4657b5c6
3
+
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path("../config/environment", __FILE__)
4
+ run Rails.application
File without changes
data/test/test_helper.rb CHANGED
@@ -1,16 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bigdecimal'
3
+ require "bigdecimal"
4
4
 
5
5
  original_verbosity = $VERBOSE
6
6
  $VERBOSE = nil
7
7
 
8
- if ENV['SKIP_SIMPLECOV'] || BigDecimal(RUBY_VERSION[0, 3]) >= BigDecimal('3.1')
8
+ if ENV["SKIP_SIMPLECOV"] || BigDecimal(RUBY_VERSION[0, 3]) >= BigDecimal("3.1")
9
9
  $SKIP_SIMPLECOV = true
10
10
  end
11
11
 
12
12
  require "rubygems"
13
- require "pry-byebug" unless ENV["CI"]
14
13
 
15
14
  unless $SKIP_SIMPLECOV
16
15
  require "simplecov"
@@ -36,7 +35,6 @@ require "coverband/utils/results"
36
35
  require "coverband/reporters/html_report"
37
36
  require "webmock/minitest"
38
37
 
39
- # require 'pry-byebug' unless ENV['CI'] # Ruby 2.3 on CI crashes on pry & JRuby doesn't support it
40
38
  require_relative "unique_files"
41
39
  $VERBOSE = original_verbosity
42
40
 
data/views/nav.erb CHANGED
@@ -25,12 +25,17 @@
25
25
  </ul>
26
26
 
27
27
  <ul class="extra_tabs">
28
- <% if nav_options[:show_coverage_link] %>
28
+ <% if nav_options[:active_link] %>
29
29
  <li><a href='<%= base_path %>'>Coverage</a></li>
30
30
  <% end %>
31
31
  <% if Coverband.configuration.track_views %>
32
- <li class='<%= nav_options[:show_coverage_link] ? 'active' : '' %>'>
32
+ <li class='<%= nav_options[:active_link] == 'view_tracker' ? 'active' : '' %>'>
33
33
  <a href='<%= base_path %>view_tracker'>Views Tracker</a>
34
34
  </li>
35
35
  <% end %>
36
+ <% if Coverband.configuration.track_routes %>
37
+ <li class='<%= nav_options[:active_link] == 'route_tracker' ? 'active' : '' %>'>
38
+ <a href='<%= base_path %>route_tracker'>Route Tracker</a>
39
+ </li>
40
+ <% end %>
36
41
  </ul>
@@ -0,0 +1,49 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>Coverband Info: <%= Coverband::VERSION %></title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <script src='<%= assets_path('dependencies.js') %>' type='text/javascript'></script>
7
+ <script src='<%= assets_path('application.js') %>' type='text/javascript'></script>
8
+ <link href='<%= assets_path('application.css') %>' media='screen, projection, print' rel='stylesheet' type='text/css'>
9
+ <link rel="icon" type="image/png" href="<%= assets_path('favicon.png') %>" />
10
+ </head>
11
+
12
+ <body>
13
+ <div id="wrapper" style="">
14
+ <%= display_nav(active_link: 'route_tracker') %>
15
+ <div id="content">
16
+ <% tracker = Coverband::Collectors::RouteTracker.new(store: Coverband.configuration.store) %>
17
+ <h4>
18
+ <% if Coverband.configuration.web_enable_clear %>
19
+ <%= button("#{base_path}clear_route_tracking", 'reset route tracker', delete: true) %>
20
+ <% end %>
21
+ </h4>
22
+ <h2>Unused Routes: (<%= tracker.unused_routes.length %>)</h2>
23
+ <p>These routes have not been rendered since recording started at <%= tracker.tracking_since %></p>
24
+ <ul>
25
+ <% tracker.unused_routes.each do |route| %>
26
+ <li class="unused-routes"><%= route %></li>
27
+ <% end %>
28
+ </ul>
29
+
30
+ <h2>Used Routes: (<%= tracker.used_routes.length %>)</h2>
31
+ <p>These routes have been rendered at least once</p>
32
+ <ul>
33
+ <% tracker.used_routes.each_pair do |route, time_at| %>
34
+ <li class="used-routes">
35
+ <%= route %>
36
+ <span class="last_seen_at">last activity recorded <%= Time.at(time_at.to_i)%></span>
37
+ <% if Coverband.configuration.web_enable_clear %>
38
+ <%= button("#{base_path}clear_route_tracking_route?route=#{route}", 'reset tracked route', delete: true) %>
39
+ <% end %>
40
+ </li>
41
+ <% end %>
42
+ </ul>
43
+ </div>
44
+ <div id="footer">
45
+ Generated by <a href="http://github.com/danmayer/coverband">Coverband</a> v<%= Coverband::VERSION %>
46
+ </div>
47
+ </div>
48
+ </body>
49
+ </html>
@@ -11,7 +11,7 @@
11
11
 
12
12
  <body>
13
13
  <div id="wrapper" style="">
14
- <%= display_nav(show_coverage_link: true) %>
14
+ <%= display_nav(active_link: 'view_tracker') %>
15
15
  <div id="content">
16
16
  <% tracker = Coverband::Collectors::ViewTracker.new(store: Coverband.configuration.store) %>
17
17
  <h4>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coverband
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.5.rc.1
4
+ version: 5.2.5.rc.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-08-20 00:00:00.000000000 Z
12
+ date: 2022-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: benchmark-ips
@@ -280,8 +280,7 @@ files:
280
280
  - CODE_OF_CONDUCT.md
281
281
  - CONTRIBUTING.md
282
282
  - Gemfile
283
- - Gemfile.rails4
284
- - Gemfile.rails6
283
+ - Gemfile.rails7
285
284
  - LICENSE
286
285
  - LICENSE.txt
287
286
  - README.md
@@ -302,6 +301,7 @@ files:
302
301
  - lib/coverband/at_exit.rb
303
302
  - lib/coverband/collectors/coverage.rb
304
303
  - lib/coverband/collectors/delta.rb
304
+ - lib/coverband/collectors/route_tracker.rb
305
305
  - lib/coverband/collectors/view_tracker.rb
306
306
  - lib/coverband/collectors/view_tracker_service.rb
307
307
  - lib/coverband/configuration.rb
@@ -323,6 +323,7 @@ files:
323
323
  - lib/coverband/utils/jruby_ext.rb
324
324
  - lib/coverband/utils/lines_classifier.rb
325
325
  - lib/coverband/utils/method_definition_scanner.rb
326
+ - lib/coverband/utils/rails6_ext.rb
326
327
  - lib/coverband/utils/railtie.rb
327
328
  - lib/coverband/utils/relative_file_converter.rb
328
329
  - lib/coverband/utils/result.rb
@@ -379,6 +380,7 @@ files:
379
380
  - test/coverband/at_exit_test.rb
380
381
  - test/coverband/collectors/coverage_test.rb
381
382
  - test/coverband/collectors/delta_test.rb
383
+ - test/coverband/collectors/route_tracker_test.rb
382
384
  - test/coverband/collectors/view_tracker_test.rb
383
385
  - test/coverband/configuration_test.rb
384
386
  - test/coverband/coverband_test.rb
@@ -418,6 +420,7 @@ files:
418
420
  - test/forked/rails_full_stack_test.rb
419
421
  - test/forked/rails_full_stack_views_test.rb
420
422
  - test/forked/rails_rake_full_stack_test.rb
423
+ - test/forked/rails_route_tracker_stack_test.rb
421
424
  - test/forked/rails_view_tracker_stack_test.rb
422
425
  - test/integration/full_stack_deferred_eager_test.rb
423
426
  - test/integration/full_stack_test.rb
@@ -465,6 +468,21 @@ files:
465
468
  - test/rails6_dummy/config/routes.rb
466
469
  - test/rails6_dummy/config/secrets.yml
467
470
  - test/rails6_dummy/tmp/.keep
471
+ - test/rails7_dummy/Rakefile
472
+ - test/rails7_dummy/app/controllers/dummy_controller.rb
473
+ - test/rails7_dummy/app/controllers/dummy_view_controller.rb
474
+ - test/rails7_dummy/app/views/dummy_view/show.html.erb
475
+ - test/rails7_dummy/app/views/dummy_view/show_haml.html.haml
476
+ - test/rails7_dummy/app/views/dummy_view/show_slim.html.slim
477
+ - test/rails7_dummy/config.ru
478
+ - test/rails7_dummy/config/application.rb
479
+ - test/rails7_dummy/config/boot.rb
480
+ - test/rails7_dummy/config/coverband.rb
481
+ - test/rails7_dummy/config/coverband_missing_redis.rb
482
+ - test/rails7_dummy/config/environment.rb
483
+ - test/rails7_dummy/config/routes.rb
484
+ - test/rails7_dummy/config/secrets.yml
485
+ - test/rails7_dummy/tmp/.keep
468
486
  - test/rails_test_helper.rb
469
487
  - test/test_helper.rb
470
488
  - test/unique_files.rb
@@ -472,6 +490,7 @@ files:
472
490
  - views/file_list.erb
473
491
  - views/layout.erb
474
492
  - views/nav.erb
493
+ - views/route_tracker.erb
475
494
  - views/settings.erb
476
495
  - views/source_file.erb
477
496
  - views/source_file_loader.erb
@@ -500,7 +519,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
500
519
  - !ruby/object:Gem::Version
501
520
  version: 1.3.1
502
521
  requirements: []
503
- rubygems_version: 3.3.7
522
+ rubygems_version: 3.2.32
504
523
  signing_key:
505
524
  specification_version: 4
506
525
  summary: Rack middleware to measure production code usage (LOC runtime usage)
@@ -521,6 +540,7 @@ test_files:
521
540
  - test/coverband/at_exit_test.rb
522
541
  - test/coverband/collectors/coverage_test.rb
523
542
  - test/coverband/collectors/delta_test.rb
543
+ - test/coverband/collectors/route_tracker_test.rb
524
544
  - test/coverband/collectors/view_tracker_test.rb
525
545
  - test/coverband/configuration_test.rb
526
546
  - test/coverband/coverband_test.rb
@@ -560,6 +580,7 @@ test_files:
560
580
  - test/forked/rails_full_stack_test.rb
561
581
  - test/forked/rails_full_stack_views_test.rb
562
582
  - test/forked/rails_rake_full_stack_test.rb
583
+ - test/forked/rails_route_tracker_stack_test.rb
563
584
  - test/forked/rails_view_tracker_stack_test.rb
564
585
  - test/integration/full_stack_deferred_eager_test.rb
565
586
  - test/integration/full_stack_test.rb
@@ -607,6 +628,21 @@ test_files:
607
628
  - test/rails6_dummy/config/routes.rb
608
629
  - test/rails6_dummy/config/secrets.yml
609
630
  - test/rails6_dummy/tmp/.keep
631
+ - test/rails7_dummy/Rakefile
632
+ - test/rails7_dummy/app/controllers/dummy_controller.rb
633
+ - test/rails7_dummy/app/controllers/dummy_view_controller.rb
634
+ - test/rails7_dummy/app/views/dummy_view/show.html.erb
635
+ - test/rails7_dummy/app/views/dummy_view/show_haml.html.haml
636
+ - test/rails7_dummy/app/views/dummy_view/show_slim.html.slim
637
+ - test/rails7_dummy/config.ru
638
+ - test/rails7_dummy/config/application.rb
639
+ - test/rails7_dummy/config/boot.rb
640
+ - test/rails7_dummy/config/coverband.rb
641
+ - test/rails7_dummy/config/coverband_missing_redis.rb
642
+ - test/rails7_dummy/config/environment.rb
643
+ - test/rails7_dummy/config/routes.rb
644
+ - test/rails7_dummy/config/secrets.yml
645
+ - test/rails7_dummy/tmp/.keep
610
646
  - test/rails_test_helper.rb
611
647
  - test/test_helper.rb
612
648
  - test/unique_files.rb
data/Gemfile.rails6 DELETED
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in coverband.gemspec
6
- gemspec
7
- gem 'rails', '~>6'
8
- gem "haml"
9
- gem "slim"