traceroute 0.5.0 → 0.6.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 +5 -5
- data/.travis.yml +10 -0
- data/MIT-LICENSE +21 -0
- data/README.rdoc +17 -3
- data/lib/tasks/traceroute.rake +1 -1
- data/lib/traceroute.rb +59 -4
- data/test/app.rb +0 -2
- data/test/traceroute_test.rb +71 -69
- data/test/traceroute_with_engine_test.rb +91 -0
- data/test/yaml_test.rb +157 -0
- data/traceroute.gemspec +1 -1
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 90fc80962b328c76194cf2766d02a2c2ad0bd462cb96e26686aeb15779c51085
|
4
|
+
data.tar.gz: 4e3ebbe7177df01147fbc9ce985ed2d94b3ac68c5be95dbf31c6c94955acb42d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2feb27fe20d57f5683e396d86393b303fffc7627a5489224c6ca089fa957cb002811f87e5469e2565bea2883b1bf0d025c243429b0a9277733dfa4a20783cad9
|
7
|
+
data.tar.gz: acd2e0940b33e1f0e5c55a9de35251240026bbffbb4fff139690b3ebbd8161d0120562d636500d55d3ddc69e11d9783ef845eb88229dfa271b9177b1972fa59b
|
data/.travis.yml
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Akira Matsuda
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -10,9 +10,9 @@ This Rake task investigates your Rails application's routes definition, then sho
|
|
10
10
|
|
11
11
|
== Supported versions
|
12
12
|
|
13
|
-
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2 (trunk)
|
13
|
+
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 (trunk)
|
14
14
|
|
15
|
-
* Rails 3.0.x, 3.1.x, 3.2.x, 4.0.x, 4.1.x
|
15
|
+
* Rails 3.0.x, 3.1.x, 3.2.x, 4.0.x, 4.1.x, 5.0.x, 5.1.x
|
16
16
|
|
17
17
|
|
18
18
|
== Install
|
@@ -68,6 +68,20 @@ Running the Rake task will print something like this for you:
|
|
68
68
|
|
69
69
|
OMG super helpful, isn't it?
|
70
70
|
|
71
|
+
== How do I tell it to ignore routes?
|
72
|
+
|
73
|
+
Some gems out there that inject routes or actions into our app for testing. Jasmine-Rails does this. They can give you false negatives when running this in development mode. It can be useful to ignore said routes or actions.
|
74
|
+
|
75
|
+
Create a .traceroute.yaml (or .traceroute.yml or .traceroute) file in your root directory.
|
76
|
+
|
77
|
+
# .traceroute.yaml
|
78
|
+
ignore_unreachable_actions:
|
79
|
+
- ^jasmine_rails\/
|
80
|
+
ignore_unused_routes:
|
81
|
+
- ^users#index
|
82
|
+
|
83
|
+
Both yaml headers accept a list of regexes.
|
84
|
+
|
71
85
|
|
72
86
|
== FAQ
|
73
87
|
|
@@ -94,4 +108,4 @@ Feel free to message me on Github (amatsuda) or Twitter (@a_matsuda) ☇3☇3
|
|
94
108
|
|
95
109
|
== Copyright
|
96
110
|
|
97
|
-
Copyright (c) 2011 Akira Matsuda. See LICENSE
|
111
|
+
Copyright (c) 2011 Akira Matsuda. See MIT-LICENSE file for further details.
|
data/lib/tasks/traceroute.rake
CHANGED
@@ -15,7 +15,7 @@ task :traceroute => :environment do
|
|
15
15
|
puts "Unreachable action methods (#{unreachable_action_methods.count}):"
|
16
16
|
unreachable_action_methods.each {|action| puts " #{action}"}
|
17
17
|
|
18
|
-
unless (unused_routes.empty? && unreachable_action_methods.empty?) || ENV['FAIL_ON_ERROR']
|
18
|
+
unless (unused_routes.empty? && unreachable_action_methods.empty?) || ENV['FAIL_ON_ERROR'] != "1"
|
19
19
|
fail "Unused routes or unreachable action methods detected."
|
20
20
|
end
|
21
21
|
end
|
data/lib/traceroute.rb
CHANGED
@@ -8,6 +8,7 @@ class Traceroute
|
|
8
8
|
|
9
9
|
def initialize(app)
|
10
10
|
@app = app
|
11
|
+
load_ignored_regex!
|
11
12
|
end
|
12
13
|
|
13
14
|
def load_everything!
|
@@ -25,7 +26,7 @@ class Traceroute
|
|
25
26
|
controller.action_methods.reject {|a| (a =~ /\A(_conditional)?_callback_/) || (a == '_layout_from_proc')}.map do |action|
|
26
27
|
"#{controller.controller_path}##{action}"
|
27
28
|
end
|
28
|
-
end.flatten.reject {|r|
|
29
|
+
end.flatten.reject {|r| @ignored_unreachable_actions.any? { |m| r.match(m) } }
|
29
30
|
end
|
30
31
|
|
31
32
|
def routed_actions
|
@@ -35,14 +36,68 @@ class Traceroute
|
|
35
36
|
else
|
36
37
|
"#{r.requirements[:controller]}##{r.requirements[:action]}"
|
37
38
|
end
|
38
|
-
end.reject {|r|
|
39
|
+
end.flatten.reject {|r| @ignored_unused_routes.any? { |m| r.match(m) } }
|
39
40
|
end
|
40
41
|
|
41
42
|
private
|
43
|
+
def filenames
|
44
|
+
[".traceroute.yaml", ".traceroute.yml", ".traceroute"].select { |filename|
|
45
|
+
File.exist? filename
|
46
|
+
}.select { |filename|
|
47
|
+
YAML.load_file(filename)
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def at_least_one_file_exists?
|
52
|
+
return !filenames.empty?
|
53
|
+
end
|
54
|
+
|
55
|
+
def ignore_config
|
56
|
+
filenames.each do |filename|
|
57
|
+
return YAML.load_file(filename)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def load_ignored_regex!
|
62
|
+
@ignored_unreachable_actions = [/^rails\//]
|
63
|
+
@ignored_unused_routes = [/^rails\//]
|
64
|
+
|
65
|
+
return unless at_least_one_file_exists?
|
66
|
+
|
67
|
+
if ignore_config.has_key? 'ignore_unreachable_actions'
|
68
|
+
unless ignore_config['ignore_unreachable_actions'].nil?
|
69
|
+
ignore_config['ignore_unreachable_actions'].each do |ignored_action|
|
70
|
+
@ignored_unreachable_actions << Regexp.new(ignored_action)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
if ignore_config.has_key? 'ignore_unused_routes'
|
76
|
+
unless ignore_config['ignore_unused_routes'].nil?
|
77
|
+
ignore_config['ignore_unused_routes'].each do |ignored_action|
|
78
|
+
@ignored_unused_routes << Regexp.new(ignored_action)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
42
84
|
def routes
|
43
|
-
|
85
|
+
collect_routes @app.routes.routes
|
86
|
+
end
|
87
|
+
|
88
|
+
def collect_routes(routes)
|
89
|
+
routes = routes.each_with_object([]) do |r, tmp_routes|
|
90
|
+
next if r.name.nil? && r.requirements.blank?
|
44
91
|
|
45
|
-
|
92
|
+
if r.app.is_a?(ActionDispatch::Routing::Mapper::Constraints) && r.app.app.respond_to?(:routes)
|
93
|
+
engine_routes = r.app.app.routes
|
94
|
+
if engine_routes.is_a?(ActionDispatch::Routing::RouteSet)
|
95
|
+
tmp_routes.concat collect_routes(engine_routes.routes)
|
96
|
+
end
|
97
|
+
else
|
98
|
+
tmp_routes << r
|
99
|
+
end
|
100
|
+
end
|
46
101
|
|
47
102
|
routes.reject! {|r| r.app.is_a?(ActionDispatch::Routing::Redirect)}
|
48
103
|
|
data/test/app.rb
CHANGED
data/test/traceroute_test.rb
CHANGED
@@ -1,100 +1,102 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module TracerouteTest
|
4
|
+
class BasicTest < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@traceroute = Traceroute.new Rails.application
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def test_defined_action_methods
|
10
|
+
assert_equal ['users#index', 'users#show', 'users#index2', 'admin/shops#create', 'admin/shops#index'].sort, @traceroute.defined_action_methods.sort
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
def test_routed_actions
|
14
|
+
assert_empty @traceroute.routed_actions
|
15
|
+
end
|
15
16
|
end
|
16
|
-
end
|
17
17
|
|
18
|
-
class RoutedActionsTest < Minitest::Test
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
class RoutedActionsTest < Minitest::Test
|
19
|
+
def setup
|
20
|
+
DummyApp::Application.routes.draw do
|
21
|
+
resources :users, :only => [:index, :show, :new, :create]
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
namespace :admin do
|
24
|
+
resources :shops, :only => :index
|
25
|
+
end
|
25
26
|
end
|
26
|
-
end
|
27
|
-
@traceroute = Traceroute.new Rails.application
|
28
|
-
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
end
|
28
|
+
@traceroute = Traceroute.new Rails.application
|
29
|
+
end
|
33
30
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
31
|
+
def teardown
|
32
|
+
DummyApp::Application.routes.clear!
|
33
|
+
end
|
38
34
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
load "./lib/tasks/traceroute.rake"
|
35
|
+
def test_routed_actions
|
36
|
+
assert_equal ['admin/shops#index', 'users#index', 'users#show', 'users#new', 'users#create'].sort, @traceroute.routed_actions.sort
|
37
|
+
end
|
43
38
|
end
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
class TracerouteRakeTests < Minitest::Test
|
41
|
+
def setup
|
42
|
+
require 'rake'
|
43
|
+
load "./lib/tasks/traceroute.rake"
|
44
|
+
@fail_on_error_was = ENV['FAIL_ON_ERROR']
|
45
|
+
end
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
def teardown
|
48
|
+
ENV['FAIL_ON_ERROR'] = @fail_on_error_was
|
49
|
+
Rake::Task.clear
|
50
|
+
DummyApp::Application.routes.clear!
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
traceroute.load_everything!
|
53
|
+
def test_dont_fail_when_envvar_is_anything_but_1
|
54
|
+
traceroute = Traceroute.new Rails.application
|
56
55
|
|
57
|
-
|
58
|
-
ENV['FAIL_ON_ERROR']="1"
|
56
|
+
ENV['FAIL_ON_ERROR'] = "DERP"
|
59
57
|
Rake::Task[:traceroute].execute
|
60
|
-
rescue => e
|
61
|
-
assert_includes e.message, "Unused routes or unreachable action methods detected."
|
62
58
|
end
|
63
|
-
end
|
64
59
|
|
65
|
-
|
66
|
-
|
67
|
-
resources :users, :only => [:index, :show, :new, :create] do
|
68
|
-
member do
|
69
|
-
get :index2
|
70
|
-
end
|
71
|
-
end
|
60
|
+
def test_rake_task_fails_when_unreachable_action_method_detected
|
61
|
+
traceroute = Traceroute.new Rails.application
|
72
62
|
|
73
|
-
|
74
|
-
|
63
|
+
begin
|
64
|
+
ENV['FAIL_ON_ERROR']="1"
|
65
|
+
Rake::Task[:traceroute].execute
|
66
|
+
rescue => e
|
67
|
+
assert_includes e.message, "Unused routes or unreachable action methods detected."
|
75
68
|
end
|
69
|
+
end
|
76
70
|
|
77
|
-
|
78
|
-
|
71
|
+
def test_rake_task_fails_when_unused_route_detected
|
72
|
+
DummyApp::Application.routes.draw do
|
73
|
+
resources :users, :only => [:index, :show, :new, :create] do
|
79
74
|
member do
|
80
|
-
get :
|
75
|
+
get :index2
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
namespace :admin do
|
80
|
+
resources :shops, :only => [:index, :create]
|
81
|
+
end
|
82
|
+
|
83
|
+
namespace :rails do
|
84
|
+
resources :mailers, only: ["index"] do
|
85
|
+
member do
|
86
|
+
get :preview
|
87
|
+
end
|
81
88
|
end
|
82
89
|
end
|
83
90
|
end
|
84
|
-
end
|
85
91
|
|
86
|
-
|
92
|
+
traceroute = Traceroute.new Rails.application
|
87
93
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
94
|
+
begin
|
95
|
+
ENV['FAIL_ON_ERROR'] = "1"
|
96
|
+
Rake::Task[:traceroute].execute
|
97
|
+
rescue => e
|
98
|
+
assert_includes e.message, "Unused routes or unreachable action methods detected."
|
99
|
+
end
|
93
100
|
end
|
94
101
|
end
|
95
|
-
|
96
|
-
def teardown
|
97
|
-
Rake::Task.clear
|
98
|
-
DummyApp::Application.routes.clear!
|
99
|
-
end
|
100
102
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
module TestEngine
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace TestEngine
|
6
|
+
end
|
7
|
+
|
8
|
+
class TasksController < ApplicationController; end
|
9
|
+
end
|
10
|
+
|
11
|
+
module EngineTestsCondition
|
12
|
+
def setup
|
13
|
+
TestEngine::TasksController.class_eval { def index() end }
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
super
|
19
|
+
TestEngine::TasksController.send :undef_method, :index
|
20
|
+
TestEngine::TasksController.clear_action_methods!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module TracerouteWithEngineTest
|
25
|
+
class BasicTest < Minitest::Test
|
26
|
+
prepend EngineTestsCondition
|
27
|
+
|
28
|
+
def setup
|
29
|
+
@traceroute = Traceroute.new Rails.application
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_defined_action_methods
|
33
|
+
assert_equal ["admin/shops#create", "admin/shops#index", "test_engine/tasks#index", "users#index", "users#index2", "users#show"].sort, @traceroute.defined_action_methods.sort
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_routed_actions
|
37
|
+
assert_empty @traceroute.routed_actions
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class RoutedActionsTest < Minitest::Test
|
42
|
+
prepend EngineTestsCondition
|
43
|
+
|
44
|
+
def setup
|
45
|
+
DummyApp::Application.routes.draw do
|
46
|
+
resources :posts, :only => [:index, :show, :new, :create]
|
47
|
+
end
|
48
|
+
|
49
|
+
@traceroute = Traceroute.new Rails.application
|
50
|
+
end
|
51
|
+
|
52
|
+
def teardown
|
53
|
+
DummyApp::Application.routes.clear!
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_routed_actions
|
57
|
+
assert_equal ['posts#index', 'posts#show', 'posts#new', 'posts#create'].sort, @traceroute.routed_actions.sort
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class EngineTest < Minitest::Test
|
62
|
+
prepend EngineTestsCondition
|
63
|
+
|
64
|
+
def setup
|
65
|
+
TestEngine::Engine.routes.draw do
|
66
|
+
resources :tasks, only: :index
|
67
|
+
end
|
68
|
+
|
69
|
+
Rails.application.routes_reloader.route_sets << DummyApp::Application.routes
|
70
|
+
DummyApp::Application.routes.draw do
|
71
|
+
resources :posts, only: [:index, :show]
|
72
|
+
|
73
|
+
mount TestEngine::Engine => '/test_engine'
|
74
|
+
end
|
75
|
+
|
76
|
+
@traceroute = Traceroute.new Rails.application
|
77
|
+
end
|
78
|
+
|
79
|
+
def teardown
|
80
|
+
DummyApp::Application.routes.clear!
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_defined_action_methods
|
84
|
+
assert_equal ["admin/shops#create", "admin/shops#index", "test_engine/tasks#index", "users#index", "users#index2", "users#show"].sort, @traceroute.defined_action_methods.sort
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_routed_actions
|
88
|
+
assert_equal ['posts#index', 'posts#show', 'test_engine/tasks#index'].sort, @traceroute.routed_actions.sort
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/test/yaml_test.rb
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
module JasmineRails
|
4
|
+
class SpecRunner < ApplicationController; end
|
5
|
+
end
|
6
|
+
|
7
|
+
module YamlTestsCondition
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
JasmineRails::SpecRunner.class_eval { def index() end }
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
super
|
15
|
+
JasmineRails::SpecRunner.send :undef_method, :index
|
16
|
+
JasmineRails::SpecRunner.clear_action_methods!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class DotFileTest < Minitest::Test
|
21
|
+
prepend YamlTestsCondition
|
22
|
+
|
23
|
+
def setup
|
24
|
+
File.open ".traceroute.yaml", "w" do |file|
|
25
|
+
file.puts 'ignore_unreachable_actions:'
|
26
|
+
file.puts '- ^jasmine_rails\/'
|
27
|
+
file.puts 'ignore_unused_routes:'
|
28
|
+
file.puts '- ^users'
|
29
|
+
end
|
30
|
+
|
31
|
+
DummyApp::Application.routes.draw do
|
32
|
+
resources :users, :only => [:index, :show, :new, :create]
|
33
|
+
|
34
|
+
namespace :admin do
|
35
|
+
resources :shops, :only => :index
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
@traceroute = Traceroute.new Rails.application
|
40
|
+
end
|
41
|
+
|
42
|
+
def teardown
|
43
|
+
DummyApp::Application.routes.clear!
|
44
|
+
|
45
|
+
File.delete ".traceroute.yaml"
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_unreachable_actions_are_ignored
|
49
|
+
refute @traceroute.defined_action_methods.include? 'jasmine_rails/spec_runner#index'
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_used_routes_are_ignored
|
53
|
+
assert_equal ['admin/shops#index'].sort, @traceroute.routed_actions.sort
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class EmptyFileTest < Minitest::Test
|
58
|
+
prepend YamlTestsCondition
|
59
|
+
|
60
|
+
def setup
|
61
|
+
File.open ".traceroute.yaml", "w" do |file|
|
62
|
+
end
|
63
|
+
|
64
|
+
DummyApp::Application.routes.draw do
|
65
|
+
resources :users, :only => [:index, :show, :new, :create]
|
66
|
+
|
67
|
+
namespace :admin do
|
68
|
+
resources :shops, :only => :index
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
@traceroute = Traceroute.new Rails.application
|
73
|
+
end
|
74
|
+
|
75
|
+
def teardown
|
76
|
+
DummyApp::Application.routes.clear!
|
77
|
+
|
78
|
+
File.delete ".traceroute.yaml"
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_empty_yaml_file_is_handled_the_same_as_no_file
|
82
|
+
assert_equal ['users#index', 'users#show', 'users#index2', 'admin/shops#create', 'admin/shops#index', 'jasmine_rails/spec_runner#index'].sort, @traceroute.defined_action_methods.sort
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_property_with_no_key
|
86
|
+
assert_equal ['admin/shops#index', 'users#index', 'users#show', 'users#new', 'users#create'].sort, @traceroute.routed_actions.sort
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class InvalidFileTest < Minitest::Test
|
91
|
+
prepend YamlTestsCondition
|
92
|
+
|
93
|
+
def setup
|
94
|
+
File.open ".traceroute.yml", "w" do |file|
|
95
|
+
file.puts 'ignore_unreachable_actions:'
|
96
|
+
file.puts 'ignore_unused_routes:'
|
97
|
+
end
|
98
|
+
|
99
|
+
DummyApp::Application.routes.draw do
|
100
|
+
resources :users, :only => [:index, :show, :new, :create]
|
101
|
+
|
102
|
+
namespace :admin do
|
103
|
+
resources :shops, :only => :index
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
@traceroute = Traceroute.new Rails.application
|
108
|
+
end
|
109
|
+
|
110
|
+
def teardown
|
111
|
+
DummyApp::Application.routes.clear!
|
112
|
+
|
113
|
+
File.delete ".traceroute.yml"
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_empty_yaml_file_is_handled_the_same_as_no_file
|
117
|
+
assert_equal ['users#index', 'users#show', 'users#index2', 'admin/shops#create', 'admin/shops#index', 'jasmine_rails/spec_runner#index'].sort, @traceroute.defined_action_methods.sort
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_property_with_no_key
|
121
|
+
assert_equal ['admin/shops#index', 'users#index', 'users#show', 'users#new', 'users#create'].sort, @traceroute.routed_actions.sort
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class FilenameSupportTest < Minitest::Test
|
126
|
+
prepend YamlTestsCondition
|
127
|
+
|
128
|
+
def test_yml_supported
|
129
|
+
File.open ".traceroute.yml", "w" do |file|
|
130
|
+
file.puts 'ignore_unreachable_actions:'
|
131
|
+
file.puts '- ^jasmine_rails\/'
|
132
|
+
file.puts 'ignore_unused_routes:'
|
133
|
+
file.puts '- ^users'
|
134
|
+
end
|
135
|
+
|
136
|
+
@traceroute = Traceroute.new Rails.application
|
137
|
+
|
138
|
+
refute @traceroute.defined_action_methods.include? 'jasmine_rails/spec_runner#index'
|
139
|
+
|
140
|
+
File.delete ".traceroute.yml"
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_no_extension_supported
|
144
|
+
File.open ".traceroute", "w" do |file|
|
145
|
+
file.puts 'ignore_unreachable_actions:'
|
146
|
+
file.puts '- ^jasmine_rails\/'
|
147
|
+
file.puts 'ignore_unused_routes:'
|
148
|
+
file.puts '- ^users'
|
149
|
+
end
|
150
|
+
|
151
|
+
@traceroute = Traceroute.new Rails.application
|
152
|
+
|
153
|
+
refute @traceroute.defined_action_methods.include? 'jasmine_rails/spec_runner#index'
|
154
|
+
|
155
|
+
File.delete ".traceroute"
|
156
|
+
end
|
157
|
+
end
|
data/traceroute.gemspec
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traceroute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.0.0
|
27
27
|
description: This Rake task investigates the application's routes definition, then
|
@@ -33,8 +33,10 @@ extensions: []
|
|
33
33
|
extra_rdoc_files:
|
34
34
|
- README.rdoc
|
35
35
|
files:
|
36
|
-
- .gitignore
|
36
|
+
- ".gitignore"
|
37
|
+
- ".travis.yml"
|
37
38
|
- Gemfile
|
39
|
+
- MIT-LICENSE
|
38
40
|
- README.rdoc
|
39
41
|
- Rakefile
|
40
42
|
- lib/tasks/traceroute.rake
|
@@ -42,6 +44,8 @@ files:
|
|
42
44
|
- test/app.rb
|
43
45
|
- test/test_helper.rb
|
44
46
|
- test/traceroute_test.rb
|
47
|
+
- test/traceroute_with_engine_test.rb
|
48
|
+
- test/yaml_test.rb
|
45
49
|
- traceroute.gemspec
|
46
50
|
homepage: https://github.com/amatsuda/traceroute
|
47
51
|
licenses:
|
@@ -53,17 +57,17 @@ require_paths:
|
|
53
57
|
- lib
|
54
58
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
59
|
requirements:
|
56
|
-
- -
|
60
|
+
- - ">="
|
57
61
|
- !ruby/object:Gem::Version
|
58
62
|
version: '0'
|
59
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
64
|
requirements:
|
61
|
-
- -
|
65
|
+
- - ">="
|
62
66
|
- !ruby/object:Gem::Version
|
63
67
|
version: '0'
|
64
68
|
requirements: []
|
65
69
|
rubyforge_project: traceroute
|
66
|
-
rubygems_version: 2.4
|
70
|
+
rubygems_version: 2.7.4
|
67
71
|
signing_key:
|
68
72
|
specification_version: 4
|
69
73
|
summary: A Rake task that helps you find the dead routes and actions for your Rails
|
@@ -72,3 +76,5 @@ test_files:
|
|
72
76
|
- test/app.rb
|
73
77
|
- test/test_helper.rb
|
74
78
|
- test/traceroute_test.rb
|
79
|
+
- test/traceroute_with_engine_test.rb
|
80
|
+
- test/yaml_test.rb
|