routes_coverage 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35735247efe2eb64d4f3e0a4f99b17a890f88ce8
4
- data.tar.gz: 11aae98ffae7cdf2e19d1762b82f5fb68632ed39
3
+ metadata.gz: 026e5816e111dad871c8ec89b6f19de4ccde34dc
4
+ data.tar.gz: 42e3f410f9a0c1475e9e8e0b4be008787b7b8339
5
5
  SHA512:
6
- metadata.gz: ea5db1529b21dcaf21fb3fc32f44e47bab80fee29b6f724ed33c173b110ce3c21225d08e1ce8203a5a8564dd4e53ff23e6993976d6e1e7d6875fd72002c67208
7
- data.tar.gz: 176202c160ca27a496f817dd075f4a572b0e8275216c127227c32aee2e003d3962c2fb8ed99edf483b07753609683df5daf0aa54980342cdd5c34a454950cc72
6
+ metadata.gz: 602ab554a4a5a164ecaa4b73ae4bcf5a801af5c6f47b05c833b274c5f4819e48f9bb6ed5e58de75725ca78f0a2cd1237c186f578108b41230726c45837bbb9d1
7
+ data.tar.gz: 57ff9b05890686d40b6f759e1663c9c72bd50cc8fa1537a58048879d8bfa87c7b18cd08f35518e26e06bbd70e4283ce064680585e9f84b45de72f351fee21d93
data/README.md CHANGED
@@ -36,6 +36,7 @@ By default html report with no groupping is generated. If you need more funtiona
36
36
  RSpec.configure do |config|
37
37
  config.routes_coverage.perform_report = ENV['ROUTES_COVERAGE'] # only generate report if env var is set
38
38
 
39
+ config.routes_coverage.exclude_put_fallbacks = true # exclude non-hit PUT-requests where a matching PATCH exists
39
40
  config.routes_coverage.exclude_patterns << %r{PATCH /reqs} # excludes all requests matching regex
40
41
  config.routes_coverage.exclude_namespaces << 'somenamespace' # excludes /somenamespace/*
41
42
 
data/Rakefile CHANGED
@@ -10,6 +10,7 @@ Rake::TestTask.new(:spec) do |t|
10
10
  end
11
11
 
12
12
  Rake::TestTask.new(:dummytest) do |t| t.pattern = 'spec/fixtures/dummy_test.rb' end
13
+ Rake::TestTask.new(:dummytest_html) do |t| t.pattern = 'spec/fixtures/dummy_html.rb' end
13
14
  Rake::TestTask.new(:dummytest_full) do |t| t.pattern = 'spec/fixtures/dummy_test_full.rb' end
14
15
  Rake::TestTask.new(:dummytest_filter) do |t| t.pattern = 'spec/fixtures/dummy_test_nsfilters.rb' end
15
16
  Rake::TestTask.new(:dummytest_groups) do |t| t.pattern = 'spec/fixtures/dummy_test_groups.rb' end
@@ -280,6 +280,12 @@ abbr.timeago {
280
280
 
281
281
  .route_list {
282
282
  margin-bottom: 18px; }
283
+ .route_list tr td {
284
+ font-weight: bold; }
285
+ .route_list tr.cov td.verb, .route_list tr.cov td.path, .route_list tr.cov td.cont, .route_list tr.cov td.hits {
286
+ color: #090 !important; }
287
+ .route_list tr.uncov td.verb, .route_list tr.uncov td.path, .route_list tr.uncov td.cont, .route_list tr.uncov td.hits {
288
+ color: #900 !important; }
283
289
 
284
290
  tr, td {
285
291
  margin: 0;
@@ -294,8 +300,6 @@ th {
294
300
 
295
301
  td {
296
302
  padding: 4px 8px; }
297
- td.strong {
298
- font-weight: bold; }
299
303
 
300
304
  tr.even td {
301
305
  background: #efefef; }
@@ -492,7 +492,6 @@ $(document).ready(function() {
492
492
  null, //verb
493
493
  null, //path
494
494
  null, //action
495
- null, //covered yes/no
496
495
  null, //hits count
497
496
  ]
498
497
  });
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routes_coverage (0.2.2)
4
+ routes_coverage (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routes_coverage (0.2.2)
4
+ routes_coverage (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routes_coverage (0.2.2)
4
+ routes_coverage (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routes_coverage (0.2.2)
4
+ routes_coverage (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routes_coverage (0.2.2)
4
+ routes_coverage (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routes_coverage (0.2.2)
4
+ routes_coverage (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -84,7 +84,7 @@ module RoutesCoverage
84
84
  end
85
85
 
86
86
  def hits_css_class hits
87
- hits > 0 ? 'green' : 'red'
87
+ hits > 0 ? 'cov' : 'uncov'
88
88
  end
89
89
 
90
90
  def timeago(time)
@@ -26,24 +26,22 @@
26
26
  <th>Verb</th>
27
27
  <th>Path</th>
28
28
  <th>Controller</th>
29
- <th>Covered</th>
30
29
  <th>Hits</th>
31
30
  </tr>
32
31
  </thead>
33
32
  <tbody>
34
33
  <% result.all_routes_with_hits.each do |route| %>
35
- <tr>
36
- <td class="strong"><%= route[:name] %></td>
37
- <td class="strong"><%= route[:verb] %></td>
38
- <td class="strong"><%= route[:path] %></td>
39
- <td class="strong">
34
+ <tr class="<%= hits_css_class route[:hits] %>">
35
+ <td class="name"><%= route[:name] %></td>
36
+ <td class="verb"><%= route[:verb] %></td>
37
+ <td class="path"><%= route[:path] %></td>
38
+ <td class="cont">
40
39
  <% if route[:engine_name] %>
41
40
  engine <%= route[:engine_name] %>
42
41
  <% end %>
43
42
  <%= route[:reqs] %>
44
43
  </td>
45
- <td class="strong <%= hits_css_class route[:hits] %>"><%= route[:hits] > 0 ? 'Yes' : 'No' %></td>
46
- <td class="<%= hits_css_class route[:hits] %> strong"><%= route[:hits] %></td>
44
+ <td class="hits"><%= route[:hits] %></td>
47
45
  </tr>
48
46
  <% end %>
49
47
  </tbody>
@@ -62,7 +62,7 @@ module RoutesCoverage
62
62
  end
63
63
 
64
64
  def coverage
65
- return 'n/a' unless expected_routes.any?
65
+ return 0 unless expected_routes.any?
66
66
  (hit_routes_count * 100.0 / expected_routes_count).round(@settings.round_precision)
67
67
  end
68
68
 
@@ -1,3 +1,3 @@
1
1
  module RoutesCoverage
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -21,6 +21,7 @@ module RoutesCoverage
21
21
  class Settings
22
22
  attr_reader :exclude_patterns
23
23
  attr_reader :exclude_namespaces
24
+ attr_accessor :exclude_put_fallbacks
24
25
 
25
26
  attr_accessor :perform_report
26
27
  attr_accessor :minimum_coverage
@@ -33,6 +34,7 @@ module RoutesCoverage
33
34
  def initialize
34
35
  @exclude_patterns = []
35
36
  @exclude_namespaces = []
37
+ @exclude_put_fallbacks = false
36
38
  @minimum_coverage = 1
37
39
  @round_precision = 1
38
40
  @format = :html
@@ -84,6 +86,26 @@ module RoutesCoverage
84
86
  all_routes.reject!{|r| r.app.is_a?(::Sprockets::Environment) }
85
87
  end
86
88
 
89
+ if settings.exclude_put_fallbacks
90
+ all_routes.reject!{|put_route|
91
+ (
92
+ put_route.verb == /^PUT$/ ||
93
+ put_route.verb == "PUT" # rails 5
94
+ ) &&
95
+ put_route.name.nil? &&
96
+ @@route_hit_count[put_route] == 0 &&
97
+ all_routes.any?{|patch_route|
98
+ (
99
+ patch_route.verb == /^PATCH$/ ||
100
+ patch_route.verb == "PATCH" # rails5
101
+ ) &&
102
+ patch_route.defaults == put_route.defaults &&
103
+ patch_route.ip == put_route.ip &&
104
+ patch_route.path.spec.to_s == put_route.path.spec.to_s
105
+ }
106
+ }
107
+ end
108
+
87
109
  all_result = Result.new(
88
110
  all_routes,
89
111
  @@route_hit_count,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routes_coverage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Fedoseyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-15 00:00:00.000000000 Z
11
+ date: 2017-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler