route_mechanic 0.1.2 → 0.2.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
  SHA256:
3
- metadata.gz: edfa9dd2a475e94ffb5131cfb367f430a838ecc12d001e45414955b1f0d84ec5
4
- data.tar.gz: '039c3bbbc1f86d16336db76fb1e6b0879ee3e2d2b8bc8f64731988c64301c48c'
3
+ metadata.gz: 21e6f6fc80509ba7ce1b98ea9e5cc7f3868b83fde1d287d5d35867802bf73b1d
4
+ data.tar.gz: '094b2771b33125d34fe4eaa06bf77bc4ba0d6d250fe094b2b68c2794e2a0274c'
5
5
  SHA512:
6
- metadata.gz: ae134daadd7209a3d67e5e3c9b7e2615b168693f034d3abd34915568de2333b5ef0955f0b7f57a76734c0e06d56145cc8bf861f156567f9437ed5bd02199e1fd
7
- data.tar.gz: 97d0c73f8d437837742470795f4f9414c73af178f911d27e49eb5c5edbba5ebf51a9f7e0b0d1155e66f1f348a1aaf8ba1333513d48de6c41fe36afe8c0ac0e7f
6
+ metadata.gz: 51fc1082c4c0857485b6d518f40c1cf8539f8509c38c9311bf62b54b0b5875e62358fc990d10aa4c26b8e0b9b9309f71e330d8236c99f4e478b002019184968b
7
+ data.tar.gz: 13f6e7e2bd77520b1be677d39609c56a68fe5d87ce7eacb70faaca58a310cceeb669f09cf64d3eea071b36dcbf5f42c6886c08b06f4cc30adb148c8ecde47dcf
@@ -23,7 +23,6 @@ jobs:
23
23
  fail-fast: false
24
24
  matrix:
25
25
  ruby:
26
- - ruby:2.3
27
26
  - ruby:2.4
28
27
  - ruby:2.5
29
28
  - ruby:2.6
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  /fixtures/fake_app/log/
11
11
  /fixtures/fake_app/tmp/
12
12
  /.rspec_status
13
+ /.byebug_history
data/Gemfile CHANGED
@@ -7,3 +7,4 @@ gem "rake", "~> 12.0"
7
7
  gem "minitest", "~> 5.0"
8
8
  gem "rspec", "~> 3.0"
9
9
  gem "rails"
10
+ gem "byebug"
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/route_mechanic.svg)](https://badge.fury.io/rb/route_mechanic)
3
3
  [![Build Status](https://github.com/ohbarye/route_mechanic/workflows/test/badge.svg?branch=master)](https://github.com/ohbarye/route_mechanic/actions?query=workflow%3Atest)
4
4
 
5
- No need to maintain Rails' routing tests manually. RouteMechanic automatically detects broken routes and missing action methods in controller once you've finished installation.
5
+ No need to maintain Rails' routing tests manually. RouteMechanic automatically detects broken routes and missing action methods in controllers once you've finished installation.
6
6
 
7
7
  ## Installation
8
8
 
@@ -24,23 +24,42 @@ $ bundle install
24
24
 
25
25
  RouteMechanic is available for both RSpec and MiniTest.
26
26
 
27
- All you have to do is to add just one test case that keeps your application's routes not broken.
27
+ All you have to do is to add just one test case that keeps your application's routes not broken. Then, RouteMechanic will get to report 2 types of broken routes.
28
+
29
+ 1. Unused actions
30
+ - Your application has the controller and the action method but `config/routes.rb` doesn't have corresponding settings.
31
+ 2. Unused routes
32
+ - Your application's `config/routes.rb` has a routing declaration but no controller has a corresponding action method.
28
33
 
29
34
  ### RSpec
30
35
 
31
- Just add a test file which has only one test case using `have_valid_routes` matcher.
36
+ Just add one test file that has only one test case using `have_valid_routes` matcher.
32
37
 
33
38
  ```ruby
34
39
  RSpec.describe 'Rails.application', type: :routing do
35
40
  it "fails if application does not have valid routes" do
36
- expect(Rails.application).to have_valid_routes
41
+ expect(Rails.application).to have_valid_routes
42
+ end
43
+ end
44
+ ```
45
+
46
+ If you'd like to test unused actions and unused routes separately or test only one of them, there're matchers to do so.
47
+
48
+ ```ruby
49
+ RSpec.describe 'Rails.application', type: :routing do
50
+ it "fails if application has unused actions" do
51
+ expect(Rails.application).to have_no_unused_actions
52
+ end
53
+
54
+ it "fails if application has unused routes" do
55
+ expect(Rails.application).to have_no_unused_routes
37
56
  end
38
57
  end
39
58
  ```
40
59
 
41
60
  ### MiniTest
42
61
 
43
- Just add a test file like below.
62
+ Just add one test file like below.
44
63
 
45
64
  ```ruby
46
65
  class RoutingTest < Minitest::Test
@@ -52,6 +71,22 @@ class RoutingTest < Minitest::Test
52
71
  end
53
72
  ```
54
73
 
74
+ If you'd like to test unused actions and unused routes separately or test only one of them, there're assertions to do so.
75
+
76
+ ```ruby
77
+ class RoutingTest < Minitest::Test
78
+ include ::RouteMechanic::Testing::Methods
79
+
80
+ def test_that_application_has_no_unused_actions
81
+ assert_no_unused_actions
82
+ end
83
+
84
+ def test_that_application_has_no_unused_routes
85
+ assert_no_unused_routes
86
+ end
87
+ end
88
+ ```
89
+
55
90
  ### What if RouteMechanic detects broken routes?
56
91
 
57
92
  It tells you broken routes as follows.
@@ -72,31 +107,23 @@ It tells you broken routes as follows.
72
107
  1 examples, 1 failure, 0 passed
73
108
  ```
74
109
 
75
- RouteMechanic reports 2 types of broken routes.
76
-
77
- 1. Missing routes
78
- - Your application has the controller and the action method but `config/routes.rb` doesn't have corresponds settings.
79
- 2. Missing action methods
80
- - Your application's `config/routes.rb` has routing declaration but no controller has a correspond action method.
81
-
82
110
  ## Motivation
83
111
 
84
- I believe most Rails developers write request specs instead of routing specs, and you might wonder what's worth to automate routing spec. Having said that, I can come up with some use-cases of this gem.
112
+ I believe most Rails developers write request specs instead of routing specs, and you might wonder what's worth to automate routing specs. Having said that, I can come up with some use-cases of this gem.
85
113
 
86
114
  1. When your project is kinda aged and none knows which route is alive and which one is dead.
87
115
  - => You can detect dead code by using this gem.
88
116
  2. When your application doesn't have enough request specs (even controller specs).
89
117
  - => This gem could be a good start point to increase tests to ensure routing is valid.
90
- 3. When you try to make big refactor of `config/routes.rb`.
91
- - => It's burden to run all request specs during refactoring. This could save your time.
118
+ 3. When you try to make a big refactor of `config/routes.rb`.
119
+ - => It's a burden to run all request specs during refactoring. This could save your time.
92
120
  4. When you're compelled to write routing specs by any pressure. ;-)
93
121
  - => Set you free from tedious work!
94
122
 
95
-
96
123
  ## License
97
124
 
98
125
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
99
126
 
100
127
  ## Code of Conduct
101
128
 
102
- Everyone interacting in the RouteMechanic project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/route_mechanic/blob/master/CODE_OF_CONDUCT.md).
129
+ Everyone interacting in the RouteMechanic project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/route_mechanic/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,5 @@
1
+ module FakeEngine
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace FakeEngine
4
+ end
5
+ end
@@ -1,6 +1,8 @@
1
1
  require 'rails/application'
2
2
  require "action_controller/railtie"
3
3
 
4
+ require_relative './lib/engine'
5
+
4
6
  FakeApp = Class.new(Rails::Application)
5
7
  FakeApp.config.eager_load = false
6
8
  FakeApp.config.hosts << 'www.example.com' if FakeApp.config.respond_to?(:hosts)
@@ -8,7 +10,20 @@ FakeApp.config.root = File.dirname(__FILE__)
8
10
  FakeApp.initialize!
9
11
 
10
12
  FakeApp.routes.draw do
13
+ constraints subdomain: /\A[0-9a-z-]+\z/ do
14
+ get '/constraints_test' => 'users#index'
15
+ end
16
+
17
+ scope ':locale', locale: /en|ja/ do
18
+ get '/locale_test', to: 'photos#index'
19
+ get '/photos/:id', to: 'photos#show', constraints: { id: /[A-Z]\d{5}/ }
20
+ end
21
+
22
+ get 'organizations/:id', to: 'organizations#show', id: /[A-Z]\d{5}/
23
+
11
24
  resources :users do
12
25
  get 'friends', to: :friends
26
+ mount FakeEngine::Engine, at: "/fake_engine", fake_default_param: 'FAKE'
27
+ post 'create_as_another_name', to: 'users#create'
13
28
  end
14
29
  end
@@ -1,49 +1,20 @@
1
- require 'route_mechanic/testing/methods'
2
- require 'rspec/matchers/composable'
1
+ require 'route_mechanic/rspec/matchers/have_valid_routes'
2
+ require 'route_mechanic/rspec/matchers/have_no_unused_actions'
3
+ require 'route_mechanic/rspec/matchers/have_no_unused_routes'
3
4
 
4
5
  module RouteMechanic
5
6
  module RSpec
6
7
  module Matchers
7
- class HaveValidRoutes
8
- include ::RSpec::Matchers::Composable
9
- include RouteMechanic::Testing::Methods
10
-
11
- # @param [Rails::Application] expected
12
- def initialize(expected)
13
- @expected = expected
14
- end
15
-
16
- def matches?(_actual)
17
- # assert_recognizes does not consider ActionController::RoutingError an
18
- # assertion failure, so we have to capture that and Assertion here.
19
- match_unless_raises Minitest::Assertion, ActiveSupport::TestCase::Assertion, ActionController::RoutingError do
20
- assert_all_routes(@expected)
21
- end
22
- end
23
-
24
- def failure_message
25
- @rescued_exception.message
26
- end
27
-
28
- def description
29
- "have valid routes"
30
- end
31
-
32
- private
8
+ def have_valid_routes(application=Rails.application)
9
+ HaveValidRoutes.new(application)
10
+ end
33
11
 
34
- def match_unless_raises(*exceptions)
35
- exceptions.unshift Exception if exceptions.empty?
36
- begin
37
- yield
38
- true
39
- rescue *exceptions => @rescued_exception
40
- false
41
- end
42
- end
12
+ def have_no_unused_actions(application=Rails.application)
13
+ HaveNoUnusedActions.new(application)
43
14
  end
44
15
 
45
- def have_valid_routes(application=Rails.application)
46
- HaveValidRoutes.new(application)
16
+ def have_no_unused_routes(application=Rails.application)
17
+ HaveNoUnusedRoutes.new(application)
47
18
  end
48
19
  end
49
20
  end
@@ -0,0 +1,42 @@
1
+ require 'route_mechanic/testing/methods'
2
+ require 'rspec/matchers/composable'
3
+
4
+ module RouteMechanic
5
+ module RSpec
6
+ module Matchers
7
+ class BaseMatcher
8
+ include ::RSpec::Matchers::Composable
9
+ include RouteMechanic::Testing::Methods
10
+
11
+ # @param [Rails::Application] expected
12
+ def initialize(expected)
13
+ @expected = expected
14
+ end
15
+
16
+ def matches?(_actual)
17
+ raise NotImplementedError
18
+ end
19
+
20
+ def failure_message
21
+ @rescued_exception.message
22
+ end
23
+
24
+ def description
25
+ raise NotImplementedError
26
+ end
27
+
28
+ private
29
+
30
+ def match_unless_raises(*exceptions)
31
+ exceptions.unshift Exception if exceptions.empty?
32
+ begin
33
+ yield
34
+ true
35
+ rescue *exceptions => @rescued_exception
36
+ false
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,21 @@
1
+ require 'route_mechanic/rspec/matchers/base_matcher'
2
+
3
+ module RouteMechanic
4
+ module RSpec
5
+ module Matchers
6
+ class HaveNoUnusedActions < BaseMatcher
7
+ def matches?(_actual)
8
+ # assert_recognizes does not consider ActionController::RoutingError an
9
+ # assertion failure, so we have to capture that and Assertion here.
10
+ match_unless_raises Minitest::Assertion, ActiveSupport::TestCase::Assertion, ActionController::RoutingError do
11
+ assert_no_unused_actions(@expected)
12
+ end
13
+ end
14
+
15
+ def description
16
+ "have no unused actions"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'route_mechanic/rspec/matchers/base_matcher'
2
+
3
+ module RouteMechanic
4
+ module RSpec
5
+ module Matchers
6
+ class HaveNoUnusedRoutes < BaseMatcher
7
+ def matches?(_actual)
8
+ # assert_recognizes does not consider ActionController::RoutingError an
9
+ # assertion failure, so we have to capture that and Assertion here.
10
+ match_unless_raises Minitest::Assertion, ActiveSupport::TestCase::Assertion, ActionController::RoutingError do
11
+ assert_no_unused_routes(@expected)
12
+ end
13
+ end
14
+
15
+ def description
16
+ "have no unused routes"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'route_mechanic/rspec/matchers/base_matcher'
2
+
3
+ module RouteMechanic
4
+ module RSpec
5
+ module Matchers
6
+ class HaveValidRoutes < BaseMatcher
7
+ def matches?(_actual)
8
+ # assert_recognizes does not consider ActionController::RoutingError an
9
+ # assertion failure, so we have to capture that and Assertion here.
10
+ match_unless_raises Minitest::Assertion, ActiveSupport::TestCase::Assertion, ActionController::RoutingError do
11
+ assert_all_routes(@expected)
12
+ end
13
+ end
14
+
15
+ def description
16
+ "have valid routes"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -3,7 +3,7 @@ require "route_mechanic/testing/error_inspector"
3
3
  module RouteMechanic
4
4
  module Testing
5
5
  class ErrorAggregator
6
- attr_reader :controller_routes_errors, :config_routes_errors
6
+ attr_reader :unused_actions_errors, :unused_routes_errors
7
7
 
8
8
  # @param [Array<ActionDispatch::Journey::Route>] routes
9
9
  # @param [Array<Controller>] controllers
@@ -12,49 +12,54 @@ module RouteMechanic
12
12
  @controllers = controllers
13
13
  @config_routes = []
14
14
  @controller_routes = []
15
- @config_routes_errors = []
16
- @controller_routes_errors = []
15
+ @unused_routes_errors = []
16
+ @unused_actions_errors = []
17
17
  end
18
18
 
19
- def aggregate
20
- collect_controller_routes_errors
21
- collect_config_routes_errors
19
+ # @param [Boolean] unused_actions
20
+ # @param [Boolean] unused_routes
21
+ def aggregate(unused_actions: true, unused_routes: true)
22
+ collect_unused_actions_errors(unused_actions)
23
+ collect_unused_routes_errors(unused_routes)
22
24
  self
23
25
  end
24
26
 
27
+ # @return [Array<ActionDispatch::Journey::Route>]
25
28
  def all_routes
26
29
  @config_routes + @controller_routes
27
30
  end
28
31
 
32
+ # @return [Boolean]
29
33
  def no_error?
30
- [@config_routes_errors, @controller_routes_errors].all?(&:empty?)
34
+ [@unused_routes_errors, @unused_actions_errors].all?(&:empty?)
31
35
  end
32
36
 
37
+ # @return [String]
33
38
  def error_message
34
39
  ErrorInspector.new(self).message
35
40
  end
36
41
 
37
42
  private
38
43
 
39
- def collect_controller_routes_errors
44
+ def collect_unused_actions_errors(report_error)
40
45
  @controllers.each do |controller|
41
46
  controller_path = controller.controller_path
42
47
  controller.action_methods.each do |action_method|
43
- journey_route = @routes.detect do |route|
48
+ journey_routes = @routes.select do |route|
44
49
  route.defaults[:controller].to_sym == controller_path.to_sym && route.defaults[:action].to_sym == action_method.to_sym
45
50
  end
46
51
 
47
- if journey_route
48
- wrapper = RouteWrapper.new journey_route
49
- @controller_routes << wrapper
52
+ if journey_routes.empty?
53
+ @unused_actions_errors << { controller: controller, action: action_method } if report_error
50
54
  else
51
- @controller_routes_errors << { controller: controller, action: action_method }
55
+ wrappers = journey_routes.map { |r| RouteWrapper.new(r) }
56
+ @controller_routes.concat(wrappers)
52
57
  end
53
58
  end
54
59
  end
55
60
  end
56
61
 
57
- def collect_config_routes_errors
62
+ def collect_unused_routes_errors(report_error)
58
63
  @routes.each do |journey_route|
59
64
  wrapper = RouteWrapper.new journey_route
60
65
  @config_routes << wrapper
@@ -63,7 +68,7 @@ module RouteMechanic
63
68
  wrapper.controller == w.controller && wrapper.action == w.action && wrapper.path == w.path
64
69
  end
65
70
 
66
- @config_routes_errors << wrapper unless matched_controller_exist
71
+ @unused_routes_errors << wrapper if !matched_controller_exist && report_error
67
72
  end
68
73
  end
69
74
  end
@@ -4,7 +4,7 @@ module RouteMechanic
4
4
  module Testing
5
5
  class ErrorInspector
6
6
  extend Forwardable
7
- def_delegators :@aggregator, :controller_routes_errors, :config_routes_errors
7
+ def_delegators :@aggregator, :unused_actions_errors, :unused_routes_errors
8
8
 
9
9
  # @param [RouteMechanic::Testing::ErrorAggregator] aggregator
10
10
  def initialize(aggregator)
@@ -15,27 +15,26 @@ module RouteMechanic
15
15
  def message
16
16
  buffer = []
17
17
 
18
- if controller_routes_errors.present?
18
+ if unused_actions_errors.present?
19
19
  buffer << " No route matches to the controllers and action methods below"
20
- buffer << controller_routes_errors.map {|r| " #{r[:controller]}##{r[:action]}" }
20
+ buffer << unused_actions_errors.map {|r| " #{r[:controller]}##{r[:action]}" }
21
21
  end
22
22
 
23
- if config_routes_errors.present?
23
+ if unused_routes_errors.present?
24
24
  verb_width, path_width = widths
25
25
  buffer << " No controller and action matches to the routes below"
26
- buffer << config_routes_errors.map { |w| " #{w.verb.ljust(verb_width)} #{w.path.ljust(path_width)} #{w.reqs}" }
27
- buffer << "\n"
26
+ buffer << unused_routes_errors.map { |w| " #{w.verb.ljust(verb_width)} #{w.path.ljust(path_width)} #{w.reqs}" }
28
27
  end
29
28
 
30
- ["[Route Mechanic]", buffer].join("\n")
29
+ ["[Route Mechanic]", buffer].join("\n") + "\n"
31
30
  end
32
31
 
33
32
  private
34
33
 
35
34
  def widths
36
35
  [
37
- config_routes_errors.map { |w| w.verb.length }.max || 0,
38
- config_routes_errors.map { |w| w.path.length }.max || 0
36
+ unused_routes_errors.map { |w| w.verb.length }.max || 0,
37
+ unused_routes_errors.map { |w| w.path.length }.max || 0
39
38
  ]
40
39
  end
41
40
  end
@@ -3,6 +3,7 @@ require "route_mechanic/testing/error_aggregator"
3
3
  require "route_mechanic/testing/minitest_assertion_adopter"
4
4
  require "action_controller"
5
5
  require "action_controller/test_case"
6
+ require "regexp-examples"
6
7
 
7
8
  module RouteMechanic
8
9
  module Testing
@@ -13,20 +14,41 @@ module RouteMechanic
13
14
  # @param [Rails::Application] application
14
15
  # @raise [Minitest::Assertion]
15
16
  def assert_all_routes(application=Rails.application)
17
+ assert_targets(application, unused_actions: true, unused_routes: true)
18
+ end
19
+
20
+ # @param [Rails::Application] application
21
+ # @raise [Minitest::Assertion]
22
+ def assert_no_unused_actions(application=Rails.application)
23
+ assert_targets(application, unused_actions: true, unused_routes: false)
24
+ end
25
+
26
+ # @param [Rails::Application] application
27
+ # @raise [Minitest::Assertion]
28
+ def assert_no_unused_routes(application=Rails.application)
29
+ assert_targets(application, unused_actions: false, unused_routes: true)
30
+ end
31
+
32
+ private
33
+
34
+ # @param [Rails::Application] application
35
+ # @param [Boolean] unused_actions
36
+ # @param [Boolean] unused_routes
37
+ # @raise [Minitest::Assertion]
38
+ def assert_targets(application, unused_actions:, unused_routes:)
16
39
  @application = application
17
40
 
18
41
  # Instead of including ActionController::TestCase::Behavior, set up
19
42
  # https://github.com/rails/rails/blob/5b6aa8c20a3abfd6274c83f196abf73cacb3400b/actionpack/lib/action_controller/test_case.rb#L519-L520
20
43
  @controller = nil unless defined? @controller
21
44
 
22
- aggregator = ErrorAggregator.new(target_routes, controllers).aggregate
45
+ aggregator = ErrorAggregator.new(target_routes, controllers).aggregate(
46
+ unused_actions: unused_actions, unused_routes: unused_routes)
23
47
  aggregator.all_routes.each { |wrapper| assert_routes(wrapper) }
24
48
 
25
49
  assert(aggregator.no_error?, ->{ aggregator.error_message })
26
50
  end
27
51
 
28
- private
29
-
30
52
  def routes
31
53
  # assert_routing expect @routes to exists as like this class inherits ActionController::TestCase.
32
54
  # If user already defines @routes, do not override
@@ -45,7 +67,12 @@ module RouteMechanic
45
67
  # @raise [Minitest::Assertion]
46
68
  def assert_routes(wrapper)
47
69
  required_parts = wrapper.required_parts.reduce({}) do |memo, required_part|
48
- memo.merge({ required_part => '1' }) # '1' is pseudo id
70
+ dummy = if wrapper.requirements[required_part].is_a?(Regexp)
71
+ wrapper.requirements[required_part].examples.last
72
+ else
73
+ '1'
74
+ end
75
+ memo.merge({ required_part => dummy }) # Set pseudo params to meets requirements
49
76
  end
50
77
 
51
78
  base_option = { controller: wrapper.controller, action: wrapper.action }
@@ -53,7 +80,12 @@ module RouteMechanic
53
80
  base_option.merge({ only_path: true }).merge(required_parts))
54
81
  expected_options = base_option.merge(required_parts)
55
82
 
56
- assert_routing({ path: url, method: wrapper.verb }, expected_options)
83
+ assert_generates(url, expected_options)
84
+ # Q. Why not using `assert_routing` or `assert_recognize`?
85
+ # A. They strictly checks `constraints` in routes.rb and
86
+ # this gem can't generate a request that meets whole constraints just in time.
87
+ # https://github.com/ohbarye/route_mechanic/issues/7#issuecomment-695957142
88
+ # https://guides.rubyonrails.org/routing.html#specifying-constraints
57
89
  end
58
90
 
59
91
  # @return [Array<Controller>]
@@ -78,7 +110,7 @@ module RouteMechanic
78
110
  # Skip internals, endpoints that Rails adds by default
79
111
  # Also Engines should be skipped since Engine's tests should be done in Engine
80
112
  wrapper = RouteWrapper.new(journey_route)
81
- wrapper.internal? || wrapper.required_defaults.empty? || wrapper.path.start_with?('/rails/')
113
+ wrapper.internal? || !wrapper.defaults[:controller] || !wrapper.defaults[:action] || wrapper.path.start_with?('/rails/')
82
114
  end
83
115
  end
84
116
  end
@@ -1,3 +1,3 @@
1
1
  module RouteMechanic
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = %q{No need to maintain Rails' routing tests manually. RouteMechanic automatically detects broken routes and missing action methods in controller once you've finished installation.}
11
11
  spec.homepage = "https://github.com/ohbarye/route_mechanic"
12
12
  spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
14
14
 
15
15
  spec.metadata["homepage_uri"] = spec.homepage
16
16
  spec.metadata["source_code_uri"] = "https://github.com/ohbarye/route_mechanic"
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
 
27
27
  spec.add_runtime_dependency "actionpack", ">= 4.2", "< 6.1"
28
+ spec.add_runtime_dependency "regexp-examples", ">= 1.5", "< 2"
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: route_mechanic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ohbarye
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-19 00:00:00.000000000 Z
11
+ date: 2020-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -30,6 +30,26 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '6.1'
33
+ - !ruby/object:Gem::Dependency
34
+ name: regexp-examples
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '1.5'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '2'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '1.5'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '2'
33
53
  description: No need to maintain Rails' routing tests manually. RouteMechanic automatically
34
54
  detects broken routes and missing action methods in controller once you've finished
35
55
  installation.
@@ -51,9 +71,14 @@ files:
51
71
  - bin/setup
52
72
  - fixtures/fake_app/app/controllers/application_controller.rb
53
73
  - fixtures/fake_app/app/controllers/users_controller.rb
74
+ - fixtures/fake_app/lib/engine.rb
54
75
  - fixtures/fake_app/rails_app.rb
55
76
  - lib/route_mechanic.rb
56
77
  - lib/route_mechanic/rspec/matchers.rb
78
+ - lib/route_mechanic/rspec/matchers/base_matcher.rb
79
+ - lib/route_mechanic/rspec/matchers/have_no_unused_actions.rb
80
+ - lib/route_mechanic/rspec/matchers/have_no_unused_routes.rb
81
+ - lib/route_mechanic/rspec/matchers/have_valid_routes.rb
57
82
  - lib/route_mechanic/testing/error_aggregator.rb
58
83
  - lib/route_mechanic/testing/error_inspector.rb
59
84
  - lib/route_mechanic/testing/methods.rb
@@ -75,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
100
  requirements:
76
101
  - - ">="
77
102
  - !ruby/object:Gem::Version
78
- version: 2.3.0
103
+ version: 2.4.0
79
104
  required_rubygems_version: !ruby/object:Gem::Requirement
80
105
  requirements:
81
106
  - - ">="