rails_best_practices 1.18.1 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +4 -1
  4. data/Gemfile +3 -3
  5. data/README.md +1 -1
  6. data/Rakefile +1 -4
  7. data/lib/rails_best_practices/analyzer.rb +3 -3
  8. data/lib/rails_best_practices/core/routes.rb +1 -1
  9. data/lib/rails_best_practices/lexicals/remove_tab_check.rb +2 -2
  10. data/lib/rails_best_practices/lexicals/remove_trailing_whitespace_check.rb +2 -2
  11. data/lib/rails_best_practices/prepares/route_prepare.rb +5 -0
  12. data/lib/rails_best_practices/reviews/add_model_virtual_attribute_review.rb +2 -2
  13. data/lib/rails_best_practices/reviews/always_add_db_index_review.rb +2 -2
  14. data/lib/rails_best_practices/reviews/check_save_return_value_review.rb +2 -2
  15. data/lib/rails_best_practices/reviews/default_scope_is_evil_review.rb +2 -2
  16. data/lib/rails_best_practices/reviews/dry_bundler_in_capistrano_review.rb +2 -2
  17. data/lib/rails_best_practices/reviews/isolate_seed_data_review.rb +2 -2
  18. data/lib/rails_best_practices/reviews/keep_finders_on_their_own_model_review.rb +2 -2
  19. data/lib/rails_best_practices/reviews/law_of_demeter_review.rb +2 -2
  20. data/lib/rails_best_practices/reviews/move_code_into_controller_review.rb +2 -2
  21. data/lib/rails_best_practices/reviews/move_code_into_helper_review.rb +2 -2
  22. data/lib/rails_best_practices/reviews/move_code_into_model_review.rb +2 -2
  23. data/lib/rails_best_practices/reviews/move_finder_to_named_scope_review.rb +2 -2
  24. data/lib/rails_best_practices/reviews/move_model_logic_into_model_review.rb +2 -2
  25. data/lib/rails_best_practices/reviews/needless_deep_nesting_review.rb +2 -2
  26. data/lib/rails_best_practices/reviews/not_rescue_exception_review.rb +2 -2
  27. data/lib/rails_best_practices/reviews/not_use_default_route_review.rb +3 -12
  28. data/lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb +2 -2
  29. data/lib/rails_best_practices/reviews/overuse_route_customizations_review.rb +2 -47
  30. data/lib/rails_best_practices/reviews/protect_mass_assignment_review.rb +2 -2
  31. data/lib/rails_best_practices/reviews/remove_empty_helpers_review.rb +2 -2
  32. data/lib/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review.rb +2 -2
  33. data/lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb +2 -2
  34. data/lib/rails_best_practices/reviews/restrict_auto_generated_routes_review.rb +15 -6
  35. data/lib/rails_best_practices/reviews/simplify_render_in_controllers_review.rb +2 -2
  36. data/lib/rails_best_practices/reviews/simplify_render_in_views_review.rb +2 -2
  37. data/lib/rails_best_practices/reviews/use_before_filter_review.rb +2 -2
  38. data/lib/rails_best_practices/reviews/use_model_association_review.rb +2 -2
  39. data/lib/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review.rb +3 -18
  40. data/lib/rails_best_practices/reviews/use_observer_review.rb +2 -13
  41. data/lib/rails_best_practices/reviews/use_query_attribute_review.rb +2 -2
  42. data/lib/rails_best_practices/reviews/use_say_with_time_in_migrations_review.rb +2 -2
  43. data/lib/rails_best_practices/reviews/use_scope_access_review.rb +2 -2
  44. data/lib/rails_best_practices/reviews/use_turbo_sprockets_rails3_review.rb +2 -2
  45. data/lib/rails_best_practices/version.rb +1 -1
  46. data/rails_best_practices.gemspec +2 -2
  47. data/spec/rails_best_practices/analyzer_spec.rb +1 -1
  48. data/spec/rails_best_practices/prepares/route_prepare_spec.rb +338 -586
  49. data/spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb +59 -140
  50. data/spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb +26 -69
  51. data/spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb +44 -153
  52. data/spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb +2 -2
  53. data/spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb +21 -0
  54. data/spec/rails_best_practices/reviews/restrict_auto_generated_routes_review_spec.rb +160 -272
  55. data/spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb +76 -209
  56. data/spec/rails_best_practices/reviews/use_observer_review_spec.rb +43 -110
  57. data/spec/rails_best_practices/reviews/use_turbo_sprockets_rails3_review_spec.rb +4 -4
  58. metadata +5 -23
  59. data/.rubocop.yml +0 -1
  60. data/.rubocop_todo.yml +0 -382
  61. data/install_supported_rubies.sh +0 -10
  62. data/rake_rubies.sh +0 -9
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module RailsBestPractices
3
- VERSION = "1.18.1"
3
+ VERSION = "1.19.0"
4
4
  end
@@ -16,7 +16,8 @@ Gem::Specification.new do |s|
16
16
  s.required_rubygems_version = ">= 1.3.6"
17
17
 
18
18
  s.add_dependency("activesupport")
19
- s.add_dependency("code_analyzer", ">= 0.4.3")
19
+ # TODO: add a dependency for Rails >= 3 ?
20
+ s.add_dependency("code_analyzer", ">= 0.4.8")
20
21
  s.add_dependency("erubis")
21
22
  s.add_dependency("i18n")
22
23
  s.add_dependency("require_all")
@@ -29,7 +30,6 @@ Gem::Specification.new do |s|
29
30
  s.add_development_dependency("slim")
30
31
  s.add_development_dependency("bundler")
31
32
  s.add_development_dependency("awesome_print")
32
- s.add_development_dependency("rubocop", "= 0.30.1")
33
33
 
34
34
  s.files = `git ls-files`.split("\n")
35
35
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -104,7 +104,7 @@ module RailsBestPractices
104
104
  expect(result).to eq([
105
105
  "\e[31mapp/models/user.rb:10 - law of demeter\e[0m",
106
106
  "\e[31mapp/models/post.rb:100 - use query attribute\e[0m",
107
- "\e[32m\nPlease go to http://rails-bestpractices.com to see more useful Rails Best Practices.\e[0m",
107
+ "\e[32m\nPlease go to https://rails-bestpractices.com to see more useful Rails Best Practices.\e[0m",
108
108
  "\e[31m\nFound 2 warnings.\e[0m"].join("\n") + "\n")
109
109
  end
110
110
  end
@@ -5,669 +5,205 @@ module RailsBestPractices
5
5
  describe RoutePrepare do
6
6
  let(:runner) { Core::Runner.new(prepares: RoutePrepare.new) }
7
7
 
8
- context "rails2" do
9
- context "resources" do
10
- it "should add resources route" do
11
- content =<<-EOF
12
- ActionController::Routing::Routes.draw do |map|
13
- map.resources :posts
14
- end
15
- EOF
16
- runner.prepare('config/routes.rb', content)
17
- routes = Prepares.routes
18
- expect(routes.size).to eq(7)
19
- expect(routes.map(&:to_s)).to eq(["PostsController#index", "PostsController#show", "PostsController#new", "PostsController#create", "PostsController#edit", "PostsController#update", "PostsController#destroy"])
20
- end
21
-
22
- it "should add multiple resources route" do
23
- content =<<-EOF
24
- ActionController::Routing::Routes.draw do |map|
25
- map.resources :posts, :users
26
- end
27
- EOF
28
- runner.prepare('config/routes.rb', content)
29
- routes = Prepares.routes
30
- expect(routes.size).to eq(14)
31
- end
32
-
33
- it "should add resources route with explict controller" do
34
- content =<<-EOF
35
- ActionController::Routing::Routes.draw do |map|
36
- map.resources :posts, controller: :blog_posts
37
- end
38
- EOF
39
- runner.prepare('config/routes.rb', content)
40
- routes = Prepares.routes
41
- expect(routes.size).to eq(7)
42
- expect(routes.map(&:to_s)).to eq(["BlogPostsController#index", "BlogPostsController#show", "BlogPostsController#new", "BlogPostsController#create", "BlogPostsController#edit", "BlogPostsController#update", "BlogPostsController#destroy"])
43
- end
44
-
45
- it "should add resources route with only option" do
46
- content =<<-EOF
47
- ActionController::Routing::Routes.draw do |map|
48
- map.resources :posts, only: [:index, :show, :new, :create]
49
- end
50
- EOF
51
- runner.prepare('config/routes.rb', content)
52
- routes = Prepares.routes
53
- expect(routes.size).to eq(4)
54
- expect(routes.map(&:to_s)).to eq(["PostsController#index", "PostsController#show", "PostsController#new", "PostsController#create"])
55
- end
56
-
57
- it "should add resources route with except option" do
58
- content =<<-EOF
59
- ActionController::Routing::Routes.draw do |map|
60
- map.resources :posts, except: [:edit, :update, :destroy]
61
- end
62
- EOF
63
- runner.prepare('config/routes.rb', content)
64
- routes = Prepares.routes
65
- expect(routes.size).to eq(4)
66
- expect(routes.map(&:to_s)).to eq(["PostsController#index", "PostsController#show", "PostsController#new", "PostsController#create"])
67
- end
68
-
69
- it "should not add resources routes with only: :none" do
70
- content =<<-EOF
71
- ActionController::Routing::Routes.draw do |map|
72
- map.resources :posts, only: :none
73
- end
74
- EOF
75
- runner.prepare('config/routes.rb', content)
76
- routes = Prepares.routes
77
- expect(routes.size).to eq(0)
78
- end
79
-
80
- it "should not add resources routes with except: :all" do
81
- content =<<-EOF
82
- ActionController::Routing::Routes.draw do |map|
83
- map.resources :posts, except: :all
84
- end
85
- EOF
86
- runner.prepare('config/routes.rb', content)
87
- routes = Prepares.routes
88
- expect(routes.size).to eq(0)
89
- end
90
-
91
- it "should add resource routes with hash collection/member routes" do
92
- content =<<-EOF
93
- ActionController::Routing::Routes.draw do |map|
94
- map.resources :posts, only: [:show], collection: { list: :get }, member: { create: :post, update: :put, destroy: :delete }
95
- end
96
- EOF
97
- runner.prepare('config/routes.rb', content)
98
- routes = Prepares.routes
99
- expect(routes.size).to eq(5)
100
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#create", "PostsController#update", "PostsController#destroy", "PostsController#list"])
101
- end
102
-
103
- it "should add resource routes with array collection/member routes" do
104
- content =<<-EOF
105
- ActionController::Routing::Routes.draw do |map|
106
- map.resources :posts, only: [:show], collection: [:list], member: [:create, :update, :destroy]
107
- end
108
- EOF
109
- runner.prepare('config/routes.rb', content)
110
- routes = Prepares.routes
111
- expect(routes.size).to eq(5)
112
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#create", "PostsController#update", "PostsController#destroy", "PostsController#list"])
113
- end
114
-
115
- it "should add route with nested routes" do
116
- content =<<-EOF
117
- ActionController::Routing::Routes.draw do |map|
118
- map.resources :posts do |post|
119
- post.resources :comments
120
- end
121
- end
122
- EOF
123
- runner.prepare('config/routes.rb', content)
124
- routes = Prepares.routes
125
- expect(routes.size).to eq(14)
126
- end
127
-
128
- it "should add route with namespace" do
129
- content =<<-EOF
130
- ActionController::Routing::Routes.draw do |map|
131
- map.namespace :admin do |admin|
132
- admin.namespace :test do |test|
133
- test.resources :posts, only: [:index]
134
- end
135
- end
136
- end
137
- EOF
138
- runner.prepare('config/routes.rb', content)
139
- routes = Prepares.routes
140
- expect(routes.map(&:to_s)).to eq(["Admin::Test::PostsController#index"])
141
- end
142
- end
143
-
144
- context "resource" do
145
- it "should add resource route" do
146
- content =<<-EOF
147
- ActionController::Routing::Routes.draw do |map|
148
- map.resource :posts
149
- end
150
- EOF
151
- runner.prepare('config/routes.rb', content)
152
- routes = Prepares.routes
153
- expect(routes.size).to eq(6)
154
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#new", "PostsController#create", "PostsController#edit", "PostsController#update", "PostsController#destroy"])
155
- end
156
-
157
- it "should add multiple resource route" do
158
- content =<<-EOF
159
- ActionController::Routing::Routes.draw do |map|
160
- map.resource :posts, :users
161
- end
162
- EOF
163
- runner.prepare('config/routes.rb', content)
164
- routes = Prepares.routes
165
- expect(routes.size).to eq(12)
166
- end
167
-
168
- it "should add resource route with only option" do
169
- content =<<-EOF
170
- ActionController::Routing::Routes.draw do |map|
171
- map.resource :posts, only: [:show, :new, :create]
172
- end
173
- EOF
174
- runner.prepare('config/routes.rb', content)
175
- routes = Prepares.routes
176
- expect(routes.size).to eq(3)
177
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#new", "PostsController#create"])
178
- end
179
-
180
- it "should add resource route with except option" do
181
- content =<<-EOF
182
- ActionController::Routing::Routes.draw do |map|
183
- map.resource :posts, except: [:edit, :update, :destroy]
184
- end
185
- EOF
186
- runner.prepare('config/routes.rb', content)
187
- routes = Prepares.routes
188
- expect(routes.size).to eq(3)
189
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#new", "PostsController#create"])
190
- end
191
-
192
- it "should not add resource routes with only: :none" do
193
- content =<<-EOF
194
- ActionController::Routing::Routes.draw do |map|
195
- map.resource :posts, only: :none
196
- end
197
- EOF
198
- runner.prepare('config/routes.rb', content)
199
- routes = Prepares.routes
200
- expect(routes.size).to eq(0)
201
- end
202
-
203
- it "should not add resource routes with except: :all" do
204
- content =<<-EOF
205
- ActionController::Routing::Routes.draw do |map|
206
- map.resource :posts, except: :all
207
- end
208
- EOF
209
- runner.prepare('config/routes.rb', content)
210
- routes = Prepares.routes
211
- expect(routes.size).to eq(0)
8
+ context "resources" do
9
+ it "should add resources route" do
10
+ content =<<-EOF
11
+ RailsBestPracticesCom::Application.routes.draw do
12
+ resources :posts
212
13
  end
14
+ EOF
15
+ runner.prepare('config/routes.rb', content)
16
+ routes = Prepares.routes
17
+ expect(routes.size).to eq(7)
18
+ expect(routes.map(&:to_s)).to eq(["PostsController#index", "PostsController#show", "PostsController#new", "PostsController#create", "PostsController#edit", "PostsController#update", "PostsController#destroy"])
213
19
  end
214
20
 
215
- it "should add connect route" do
21
+ it "should add multiple resources route" do
216
22
  content =<<-EOF
217
- ActionController::Routing::Routes.draw do |map|
218
- map.connect 'vote', controller: "votes", action: "create", method: :post
23
+ RailsBestPracticesCom::Application.routes.draw do
24
+ resources :posts, :users
219
25
  end
220
26
  EOF
221
27
  runner.prepare('config/routes.rb', content)
222
28
  routes = Prepares.routes
223
- expect(routes.map(&:to_s)).to eq(["VotesController#create"])
29
+ expect(routes.size).to eq(14)
224
30
  end
225
31
 
226
- it "should add connect route with all actions" do
32
+ it "should add resources route with explict controller" do
227
33
  content =<<-EOF
228
- ActionController::Routing::Routes.draw do |map|
229
- map.connect 'internal/:action/*whatever', controller: "internal"
34
+ RailsBestPracticesCom::Application.routes.draw do
35
+ resources :posts, controller: :blog_posts
230
36
  end
231
37
  EOF
232
38
  runner.prepare('config/routes.rb', content)
233
39
  routes = Prepares.routes
234
- expect(routes.map(&:to_s)).to eq(["InternalController#*"])
40
+ expect(routes.size).to eq(7)
41
+ expect(routes.map(&:to_s)).to eq(["BlogPostsController#index", "BlogPostsController#show", "BlogPostsController#new", "BlogPostsController#create", "BlogPostsController#edit", "BlogPostsController#update", "BlogPostsController#destroy"])
235
42
  end
236
43
 
237
- it "should add named route" do
44
+ it "should add resources route with only option" do
238
45
  content =<<-EOF
239
- ActionController::Routing::Routes.draw do |map|
240
- map.login '/player/login', controller: 'sessions', action: 'new', conditions: { method: :get }
46
+ RailsBestPracticesCom::Application.routes.draw do
47
+ resources :posts, only: [:index, :show, :new, :create]
241
48
  end
242
49
  EOF
243
50
  runner.prepare('config/routes.rb', content)
244
51
  routes = Prepares.routes
245
- expect(routes.map(&:to_s)).to eq(["SessionsController#new"])
52
+ expect(routes.size).to eq(4)
53
+ expect(routes.map(&:to_s)).to eq(["PostsController#index", "PostsController#show", "PostsController#new", "PostsController#create"])
246
54
  end
247
55
 
248
- it "should add named route with with_options" do
56
+ it "should add resources route with except option" do
249
57
  content =<<-EOF
250
- ActionController::Routing::Routes.draw do |map|
251
- map.with_options(controller: "admin_session") do |session|
252
- session.login '/login', action: 'new', method: :get
253
- end
58
+ RailsBestPracticesCom::Application.routes.draw do
59
+ resources :posts, except: [:edit, :update, :destroy]
254
60
  end
255
61
  EOF
256
62
  runner.prepare('config/routes.rb', content)
257
63
  routes = Prepares.routes
258
- expect(routes.map(&:to_s)).to eq(["AdminSessionController#new"])
64
+ expect(routes.size).to eq(4)
65
+ expect(routes.map(&:to_s)).to eq(["PostsController#index", "PostsController#show", "PostsController#new", "PostsController#create"])
259
66
  end
260
67
 
261
- it "should not take former resources for direct get/post" do
68
+ it "should not add resources routes with only: :none" do
262
69
  content =<<-EOF
263
- ActionController::Routing::Routes.draw do |map|
264
- map.resources :posts
265
- map.stop 'sprints/stop', controller: 'sprints', action: 'stop'
70
+ RailsBestPracticesCom::Application.routes.draw do
71
+ resources :posts, only: :none
266
72
  end
267
73
  EOF
268
74
  runner.prepare('config/routes.rb', content)
269
75
  routes = Prepares.routes
270
- expect(routes.last.to_s).to eq("SprintsController#stop")
76
+ expect(routes.size).to eq(0)
271
77
  end
272
- end
273
-
274
- context "rails3" do
275
- context "resources" do
276
- it "should add resources route" do
277
- content =<<-EOF
278
- RailsBestPracticesCom::Application.routes.draw do
279
- resources :posts
280
- end
281
- EOF
282
- runner.prepare('config/routes.rb', content)
283
- routes = Prepares.routes
284
- expect(routes.size).to eq(7)
285
- expect(routes.map(&:to_s)).to eq(["PostsController#index", "PostsController#show", "PostsController#new", "PostsController#create", "PostsController#edit", "PostsController#update", "PostsController#destroy"])
286
- end
287
-
288
- it "should add multiple resources route" do
289
- content =<<-EOF
290
- RailsBestPracticesCom::Application.routes.draw do
291
- resources :posts, :users
292
- end
293
- EOF
294
- runner.prepare('config/routes.rb', content)
295
- routes = Prepares.routes
296
- expect(routes.size).to eq(14)
297
- end
298
78
 
299
- it "should add resources route with explict controller" do
300
- content =<<-EOF
301
- RailsBestPracticesCom::Application.routes.draw do
302
- resources :posts, controller: :blog_posts
303
- end
304
- EOF
305
- runner.prepare('config/routes.rb', content)
306
- routes = Prepares.routes
307
- expect(routes.size).to eq(7)
308
- expect(routes.map(&:to_s)).to eq(["BlogPostsController#index", "BlogPostsController#show", "BlogPostsController#new", "BlogPostsController#create", "BlogPostsController#edit", "BlogPostsController#update", "BlogPostsController#destroy"])
309
- end
310
-
311
- it "should add resources route with only option" do
312
- content =<<-EOF
313
- RailsBestPracticesCom::Application.routes.draw do
314
- resources :posts, only: [:index, :show, :new, :create]
315
- end
316
- EOF
317
- runner.prepare('config/routes.rb', content)
318
- routes = Prepares.routes
319
- expect(routes.size).to eq(4)
320
- expect(routes.map(&:to_s)).to eq(["PostsController#index", "PostsController#show", "PostsController#new", "PostsController#create"])
321
- end
322
-
323
- it "should add resources route with except option" do
324
- content =<<-EOF
325
- RailsBestPracticesCom::Application.routes.draw do
326
- resources :posts, except: [:edit, :update, :destroy]
327
- end
328
- EOF
329
- runner.prepare('config/routes.rb', content)
330
- routes = Prepares.routes
331
- expect(routes.size).to eq(4)
332
- expect(routes.map(&:to_s)).to eq(["PostsController#index", "PostsController#show", "PostsController#new", "PostsController#create"])
333
- end
334
-
335
- it "should not add resources routes with only: :none" do
336
- content =<<-EOF
337
- RailsBestPracticesCom::Application.routes.draw do
338
- resources :posts, only: :none
339
- end
340
- EOF
341
- runner.prepare('config/routes.rb', content)
342
- routes = Prepares.routes
343
- expect(routes.size).to eq(0)
344
- end
345
-
346
- it "should not add resources routes with except: :all" do
347
- content =<<-EOF
348
- RailsBestPracticesCom::Application.routes.draw do
349
- resources :posts, except: :all
350
- end
351
- EOF
352
- runner.prepare('config/routes.rb', content)
353
- routes = Prepares.routes
354
- expect(routes.size).to eq(0)
355
- end
356
-
357
- it "should add resources routes with members" do
358
- content =<<-EOF
359
- RailsBestPracticesCom::Application.routes.draw do
360
- namespace :admin do
361
- resources :posts, :only => [:edit, :update] do
362
- member do
363
- post 'link_to/:other_id' => 'posts#link_to_post'
364
- post 'extra_update' => 'posts#extra_update'
365
- end
366
- end
367
- end
368
- end
369
- EOF
370
- runner.prepare('config/routes.rb', content)
371
- routes = Prepares.routes
372
- expect(routes.map(&:to_s)).to eq([
373
- "Admin::PostsController#edit",
374
- "Admin::PostsController#update",
375
- "Admin::PostsController#link_to_post",
376
- "Admin::PostsController#extra_update"])
377
- end
378
-
379
- it "should add connect route" do
380
- content =<<-EOF
381
- ActionController::Routing::Routes.draw do |map|
382
- map.connect 'vote', controller: "votes", action: "create", method: :post
383
- end
384
- EOF
385
- runner.prepare('config/routes.rb', content)
386
- routes = Prepares.routes
387
- expect(routes.map(&:to_s)).to eq(["VotesController#create"])
388
- end
389
-
390
- it "should add named route" do
391
- content =<<-EOF
392
- ActionController::Routing::Routes.draw do |map|
393
- map.login '/player/login', controller: 'sessions', action: 'new', conditions: { method: :get }
394
- end
395
- EOF
396
- runner.prepare('config/routes.rb', content)
397
- routes = Prepares.routes
398
- expect(routes.map(&:to_s)).to eq(["SessionsController#new"])
79
+ it "should not add resources routes with except: :all" do
80
+ content =<<-EOF
81
+ RailsBestPracticesCom::Application.routes.draw do
82
+ resources :posts, except: :all
399
83
  end
84
+ EOF
85
+ runner.prepare('config/routes.rb', content)
86
+ routes = Prepares.routes
87
+ expect(routes.size).to eq(0)
400
88
  end
401
89
 
402
- context "resource" do
403
- it "should add resource route" do
404
- content =<<-EOF
405
- RailsBestPracticesCom::Application.routes.draw do
406
- resource :posts
407
- end
408
- EOF
409
- runner.prepare('config/routes.rb', content)
410
- routes = Prepares.routes
411
- expect(routes.size).to eq(6)
412
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#new", "PostsController#create", "PostsController#edit", "PostsController#update", "PostsController#destroy"])
413
- end
414
-
415
- it "should add multiple resource route" do
416
- content =<<-EOF
417
- RailsBestPracticesCom::Application.routes.draw do
418
- resource :posts, :users
419
- end
420
- EOF
421
- runner.prepare('config/routes.rb', content)
422
- routes = Prepares.routes
423
- expect(routes.size).to eq(12)
424
- end
425
-
426
- it "should add resource route with only option" do
427
- content =<<-EOF
428
- RailsBestPracticesCom::Application.routes.draw do
429
- resource :posts, only: [:show, :new, :create]
430
- end
431
- EOF
432
- runner.prepare('config/routes.rb', content)
433
- routes = Prepares.routes
434
- expect(routes.size).to eq(3)
435
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#new", "PostsController#create"])
436
- end
437
-
438
- it "should add resource route with except option" do
439
- content =<<-EOF
440
- RailsBestPracticesCom::Application.routes.draw do
441
- resource :posts, except: [:edit, :update, :destroy]
442
- end
443
- EOF
444
- runner.prepare('config/routes.rb', content)
445
- routes = Prepares.routes
446
- expect(routes.size).to eq(3)
447
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#new", "PostsController#create"])
448
- end
449
-
450
- it "should not add resource routes with only: :none" do
451
- content =<<-EOF
452
- RailsBestPracticesCom::Application.routes.draw do
453
- resource :posts, only: :none
454
- end
455
- EOF
456
- runner.prepare('config/routes.rb', content)
457
- routes = Prepares.routes
458
- expect(routes.size).to eq(0)
459
- end
460
-
461
- it "should not add resource routes with except: :all" do
462
- content =<<-EOF
463
- RailsBestPracticesCom::Application.routes.draw do
464
- resource :posts, except: :all
465
- end
466
- EOF
467
- runner.prepare('config/routes.rb', content)
468
- routes = Prepares.routes
469
- expect(routes.size).to eq(0)
470
- end
471
-
472
- it "should add resource routes with get/post/put/patch/delete routes" do
473
- content =<<-EOF
474
- RailsBestPracticesCom::Application.routes.draw do
475
- resources :posts, only: [:show] do
476
- get :list, on: :collection
477
- collection do
478
- get :search
479
- match :available
480
- end
481
- post :create, on: :member
90
+ it "should add resources routes with members" do
91
+ content =<<-EOF
92
+ RailsBestPracticesCom::Application.routes.draw do
93
+ namespace :admin do
94
+ resources :posts, :only => [:edit, :update] do
482
95
  member do
483
- put :update
484
- patch :update
485
- end
486
- end
487
- end
488
- EOF
489
- runner.prepare('config/routes.rb', content)
490
- routes = Prepares.routes
491
- expect(routes.size).to eq(7)
492
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#list", "PostsController#search", "PostsController#available", "PostsController#create", "PostsController#update", "PostsController#update"])
493
- end
494
-
495
- it "should add custom resources routes with {}" do
496
- content =<<-EOF
497
- RailsBestPracticesCom::Application.routes.draw do
498
- resources :posts, only: [:show] { get :inactive, on: :collection }
499
- end
500
- EOF
501
- runner.prepare('config/routes.rb', content)
502
- routes = Prepares.routes
503
- expect(routes.size).to eq(2)
504
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#inactive"])
505
- end
506
-
507
- it "should add resources routes with get %w() routes" do
508
- content =<<-EOF
509
- RailsBestPracticesCom::Application.routes.draw do
510
- resources :posts, only: [:show] do
511
- collection do
512
- get *%w(latest popular)
96
+ post 'link_to/:other_id' => 'posts#link_to_post'
97
+ post 'extra_update' => 'posts#extra_update'
513
98
  end
514
99
  end
515
100
  end
516
- EOF
517
- runner.prepare('config/routes.rb', content)
518
- routes = Prepares.routes
519
- expect(routes.size).to eq(3)
520
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#latest", "PostsController#popular"])
521
- end
522
-
523
- it "should add route with nested routes" do
524
- content =<<-EOF
525
- RailsBestPracticesCom::Application.routes.draw do
526
- resources :posts
527
- resources :comments
528
- end
529
- end
530
- EOF
531
- runner.prepare('config/routes.rb', content)
532
- routes = Prepares.routes
533
- expect(routes.size).to eq(14)
534
- end
535
-
536
- it "should add route with namespace" do
537
- content =<<-EOF
538
- RailsBestPracticesCom::Application.routes.draw do
539
- namespace :admin do
540
- namespace :test do
541
- resources :posts, only: [:index]
542
- end
543
- end
544
- end
545
- EOF
546
- runner.prepare('config/routes.rb', content)
547
- routes = Prepares.routes
548
- expect(routes.map(&:to_s)).to eq(["Admin::Test::PostsController#index"])
549
101
  end
102
+ EOF
103
+ runner.prepare('config/routes.rb', content)
104
+ routes = Prepares.routes
105
+ expect(routes.map(&:to_s)).to eq([
106
+ "Admin::PostsController#edit",
107
+ "Admin::PostsController#update",
108
+ "Admin::PostsController#link_to_post",
109
+ "Admin::PostsController#extra_update"])
110
+ end
550
111
 
551
- it "should add route with namespace, but without resources" do
552
- content =<<-EOF
553
- RailsBestPracticesCom::Appllication.routes.draw do
554
- namespace :something do
555
- get *%w(route_one route_two)
556
- get :route_three, action: "custom_action"
112
+ it "should add resources routes with members inline" do
113
+ content =<<-EOF
114
+ RailsBestPracticesCom::Application.routes.draw do
115
+ namespace :admin do
116
+ resources :posts, :only => [:edit, :update] do
117
+ post :link_to_post, :extra_update, :retrieve, on: :member
557
118
  end
558
119
  end
559
- EOF
560
- runner.prepare('config/routes.rb', content)
561
- routes = Prepares.routes
562
- expect(routes.map(&:to_s)).to eq(["SomethingController#route_one", "SomethingController#route_two", "SomethingController#custom_action"])
563
- end
564
-
565
- it "should add route with scope" do
566
- content =<<-EOF
567
- RailsBestPracticesCom::Application.routes.draw do
568
- scope module: "admin" do
569
- resources :posts, only: [:index]
570
- end
571
- resources :discussions, only: [:index], module: "admin"
572
- scope "/admin" do
573
- resources :comments, only: [:index]
574
- end
575
- scope "/:username", controller: :users do
576
- get '/' => :show
577
- scope 'topic' do
578
- get 'preview', as: 'preview_user', action: 'preview'
579
- end
580
- end
581
- end
582
- EOF
583
- runner.prepare('config/routes.rb', content)
584
- routes = Prepares.routes
585
- expect(routes.map(&:to_s)).to eq([
586
- "Admin::PostsController#index",
587
- "Admin::DiscussionsController#index",
588
- "CommentsController#index",
589
- "UsersController#show",
590
- "UsersController#preview"
591
- ])
592
120
  end
121
+ EOF
122
+ runner.prepare('config/routes.rb', content)
123
+ routes = Prepares.routes
124
+ expect(routes.map(&:to_s)).to eq([
125
+ "Admin::PostsController#edit",
126
+ "Admin::PostsController#update",
127
+ "Admin::PostsController#link_to_post",
128
+ "Admin::PostsController#extra_update",
129
+ "Admin::PostsController#retrieve"])
593
130
  end
594
131
 
595
- it "should add route for direct get/post" do
132
+ it "should add connect route" do
596
133
  content =<<-EOF
597
- RailsBestPracticesCom::Application.routes.draw do
598
- get 'posts/show'
599
- post '/posts' => 'posts#create'
600
- put '/posts/:id' => 'posts#update'
601
- delete '/post/:id' => 'posts#destroy'
602
- get '/agb' => 'high_voltage/pages#show', id: 'agb'
134
+ ActionController::Routing::Routes.draw do |map|
135
+ map.connect 'vote', controller: "votes", action: "create", method: :post
603
136
  end
604
137
  EOF
605
138
  runner.prepare('config/routes.rb', content)
606
139
  routes = Prepares.routes
607
- expect(routes.size).to eq(5)
608
- expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#create", "PostsController#update", "PostsController#destroy", "HighVoltage::PagesController#show"])
140
+ expect(routes.map(&:to_s)).to eq(["VotesController#create"])
609
141
  end
610
142
 
611
- it "should add routes for another get/post" do
143
+ it "should add named route" do
612
144
  content =<<-EOF
613
- RailsBestPracticesCom::Application.routes.draw
614
- get "/login", to: 'sessions#new', as: :login
145
+ ActionController::Routing::Routes.draw do |map|
146
+ map.login '/player/login', controller: 'sessions', action: 'new', conditions: { method: :get }
615
147
  end
616
148
  EOF
617
149
  runner.prepare('config/routes.rb', content)
618
150
  routes = Prepares.routes
619
- expect(routes.size).to eq(1)
620
- expect(routes.first.to_s).to eq("SessionsController#new")
151
+ expect(routes.map(&:to_s)).to eq(["SessionsController#new"])
621
152
  end
153
+ end
622
154
 
623
- it "should add match route" do
155
+ context "resource" do
156
+ it "should add resource route" do
624
157
  content =<<-EOF
625
158
  RailsBestPracticesCom::Application.routes.draw do
626
- match '/auth/:provider/callback' => 'authentications#create'
159
+ resource :posts
627
160
  end
628
161
  EOF
629
162
  runner.prepare('config/routes.rb', content)
630
163
  routes = Prepares.routes
631
- expect(routes.map(&:to_s)).to eq(["AuthenticationsController#create"])
164
+ expect(routes.size).to eq(6)
165
+ expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#new", "PostsController#create", "PostsController#edit", "PostsController#update", "PostsController#destroy"])
632
166
  end
633
167
 
634
- it "should add match route with all actions" do
168
+ it "should add multiple resource route" do
635
169
  content =<<-EOF
636
170
  RailsBestPracticesCom::Application.routes.draw do
637
- match 'internal/:action/*whatever', controller: "internal"
171
+ resource :posts, :users
638
172
  end
639
173
  EOF
640
174
  runner.prepare('config/routes.rb', content)
641
175
  routes = Prepares.routes
642
- expect(routes.map(&:to_s)).to eq(["InternalController#*"])
176
+ expect(routes.size).to eq(12)
643
177
  end
644
178
 
645
- it "should add root route" do
179
+ it "should add resource route with only option" do
646
180
  content =<<-EOF
647
181
  RailsBestPracticesCom::Application.routes.draw do
648
- root to: 'home#index'
182
+ resource :posts, only: [:show, :new, :create]
649
183
  end
650
184
  EOF
651
185
  runner.prepare('config/routes.rb', content)
652
186
  routes = Prepares.routes
653
- expect(routes.map(&:to_s)).to eq(["HomeController#index"])
187
+ expect(routes.size).to eq(3)
188
+ expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#new", "PostsController#create"])
654
189
  end
655
190
 
656
- it "should add root shortcut route" do
191
+ it "should add resource route with except option" do
657
192
  content =<<-EOF
658
193
  RailsBestPracticesCom::Application.routes.draw do
659
- root 'home#index'
194
+ resource :posts, except: [:edit, :update, :destroy]
660
195
  end
661
196
  EOF
662
197
  runner.prepare('config/routes.rb', content)
663
198
  routes = Prepares.routes
664
- expect(routes.map(&:to_s)).to eq(["HomeController#index"])
199
+ expect(routes.size).to eq(3)
200
+ expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#new", "PostsController#create"])
665
201
  end
666
202
 
667
- it "should do nothing for default route" do
203
+ it "should not add resource routes with only: :none" do
668
204
  content =<<-EOF
669
205
  RailsBestPracticesCom::Application.routes.draw do
670
- match ':controller(/:action(/:id(.:format)))'
206
+ resource :posts, only: :none
671
207
  end
672
208
  EOF
673
209
  runner.prepare('config/routes.rb', content)
@@ -675,11 +211,10 @@ module RailsBestPractices
675
211
  expect(routes.size).to eq(0)
676
212
  end
677
213
 
678
- it "should do nothing for redirect" do
214
+ it "should not add resource routes with except: :all" do
679
215
  content =<<-EOF
680
216
  RailsBestPracticesCom::Application.routes.draw do
681
- match "/stories/:name" => redirect("/posts/%{name}")
682
- match "/stories" => redirect {|p, req| "/posts/\#{req.subdomain}" }
217
+ resource :posts, except: :all
683
218
  end
684
219
  EOF
685
220
  runner.prepare('config/routes.rb', content)
@@ -687,68 +222,285 @@ module RailsBestPractices
687
222
  expect(routes.size).to eq(0)
688
223
  end
689
224
 
690
- it "should parse customize route in nested resources" do
225
+ it "should add resource routes with get/post/put/patch/delete routes" do
691
226
  content =<<-EOF
692
227
  RailsBestPracticesCom::Application.routes.draw do
693
- resources :posts do
694
- resources :comments
695
- post :stop
228
+ resources :posts, only: [:show] do
229
+ get :list, on: :collection
230
+ collection do
231
+ get :search
232
+ match :available
233
+ end
234
+ post :create, on: :member
235
+ member do
236
+ put :update
237
+ patch :update
238
+ end
696
239
  end
697
240
  end
698
241
  EOF
699
242
  runner.prepare('config/routes.rb', content)
700
243
  routes = Prepares.routes
701
- expect(routes.last.to_s).to eq("PostsController#stop")
244
+ expect(routes.size).to eq(7)
245
+ expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#list", "PostsController#search", "PostsController#available", "PostsController#create", "PostsController#update", "PostsController#update"])
702
246
  end
703
247
 
704
- it "should parse custom route for resource with explicit to and different action name" do
248
+ it "should add custom resources routes with {}" do
705
249
  content =<<-EOF
706
250
  RailsBestPracticesCom::Application.routes.draw do
707
- resources :posts do
708
- get :halt, to: 'posts#stop'
709
- end
251
+ resources :posts, only: [:show] { get :inactive, on: :collection }
710
252
  end
711
253
  EOF
712
254
  runner.prepare('config/routes.rb', content)
713
255
  routes = Prepares.routes
714
- expect(routes.last.to_s).to eq("PostsController#stop")
256
+ expect(routes.size).to eq(2)
257
+ expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#inactive"])
715
258
  end
716
259
 
717
- it "should parse custom route for resource with symbol action name" do
260
+ it "should add resources routes with get %w() routes" do
718
261
  content =<<-EOF
719
262
  RailsBestPracticesCom::Application.routes.draw do
720
- resources :posts do
721
- get :halt, to: :stop
263
+ resources :posts, only: [:show] do
264
+ collection do
265
+ get *%w(latest popular)
266
+ end
722
267
  end
723
268
  end
724
269
  EOF
725
270
  runner.prepare('config/routes.rb', content)
726
271
  routes = Prepares.routes
727
- expect(routes.last.to_s).to eq("PostsController#stop")
272
+ expect(routes.size).to eq(3)
273
+ expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#latest", "PostsController#popular"])
728
274
  end
729
275
 
730
- it "should not take former resources for direct get/post" do
276
+ it "should add route with nested routes" do
731
277
  content =<<-EOF
732
278
  RailsBestPracticesCom::Application.routes.draw do
733
279
  resources :posts
734
- post "sprints/stop"
280
+ resources :comments
281
+ end
735
282
  end
736
283
  EOF
737
284
  runner.prepare('config/routes.rb', content)
738
285
  routes = Prepares.routes
739
- expect(routes.last.to_s).to eq("SprintsController#stop")
286
+ expect(routes.size).to eq(14)
740
287
  end
741
288
 
742
- it "should not parse wrong route" do
289
+ it "should add route with namespace" do
743
290
  content =<<-EOF
744
291
  RailsBestPracticesCom::Application.routes.draw do
745
- match ':controller/:action' => '#index', as: :auto_complete
292
+ namespace :admin do
293
+ namespace :test do
294
+ resources :posts, only: [:index]
295
+ end
296
+ end
746
297
  end
747
298
  EOF
748
299
  runner.prepare('config/routes.rb', content)
749
300
  routes = Prepares.routes
750
- expect(routes.size).to eq(0)
301
+ expect(routes.map(&:to_s)).to eq(["Admin::Test::PostsController#index"])
302
+ end
303
+
304
+ it "should add route with namespace, but without resources" do
305
+ content =<<-EOF
306
+ RailsBestPracticesCom::Appllication.routes.draw do
307
+ namespace :something do
308
+ get *%w(route_one route_two)
309
+ get :route_three, action: "custom_action"
310
+ end
311
+ end
312
+ EOF
313
+ runner.prepare('config/routes.rb', content)
314
+ routes = Prepares.routes
315
+ expect(routes.map(&:to_s)).to eq(["SomethingController#route_one", "SomethingController#route_two", "SomethingController#custom_action"])
316
+ end
317
+
318
+ it "should add route with scope" do
319
+ content =<<-EOF
320
+ RailsBestPracticesCom::Application.routes.draw do
321
+ scope module: "admin" do
322
+ resources :posts, only: [:index]
323
+ end
324
+ resources :discussions, only: [:index], module: "admin"
325
+ scope "/admin" do
326
+ resources :comments, only: [:index]
327
+ end
328
+ scope "/:username", controller: :users do
329
+ get '/' => :show
330
+ scope 'topic' do
331
+ get 'preview', as: 'preview_user', action: 'preview'
332
+ end
333
+ end
334
+ end
335
+ EOF
336
+ runner.prepare('config/routes.rb', content)
337
+ routes = Prepares.routes
338
+ expect(routes.map(&:to_s)).to eq([
339
+ "Admin::PostsController#index",
340
+ "Admin::DiscussionsController#index",
341
+ "CommentsController#index",
342
+ "UsersController#show",
343
+ "UsersController#preview"
344
+ ])
345
+ end
346
+ end
347
+
348
+ it "should add route for direct get/post" do
349
+ content =<<-EOF
350
+ RailsBestPracticesCom::Application.routes.draw do
351
+ get 'posts/show'
352
+ post '/posts' => 'posts#create'
353
+ put '/posts/:id' => 'posts#update'
354
+ delete '/post/:id' => 'posts#destroy'
355
+ get '/agb' => 'high_voltage/pages#show', id: 'agb'
356
+ end
357
+ EOF
358
+ runner.prepare('config/routes.rb', content)
359
+ routes = Prepares.routes
360
+ expect(routes.size).to eq(5)
361
+ expect(routes.map(&:to_s)).to eq(["PostsController#show", "PostsController#create", "PostsController#update", "PostsController#destroy", "HighVoltage::PagesController#show"])
362
+ end
363
+
364
+ it "should add routes for another get/post" do
365
+ content =<<-EOF
366
+ RailsBestPracticesCom::Application.routes.draw
367
+ get "/login", to: 'sessions#new', as: :login
368
+ end
369
+ EOF
370
+ runner.prepare('config/routes.rb', content)
371
+ routes = Prepares.routes
372
+ expect(routes.size).to eq(1)
373
+ expect(routes.first.to_s).to eq("SessionsController#new")
374
+ end
375
+
376
+ it "should add match route" do
377
+ content =<<-EOF
378
+ RailsBestPracticesCom::Application.routes.draw do
379
+ match '/auth/:provider/callback' => 'authentications#create'
380
+ end
381
+ EOF
382
+ runner.prepare('config/routes.rb', content)
383
+ routes = Prepares.routes
384
+ expect(routes.map(&:to_s)).to eq(["AuthenticationsController#create"])
385
+ end
386
+
387
+ it "should add match route with all actions" do
388
+ content =<<-EOF
389
+ RailsBestPracticesCom::Application.routes.draw do
390
+ match 'internal/:action/*whatever', controller: "internal"
391
+ end
392
+ EOF
393
+ runner.prepare('config/routes.rb', content)
394
+ routes = Prepares.routes
395
+ expect(routes.map(&:to_s)).to eq(["InternalController#*"])
396
+ end
397
+
398
+ it "should add root route" do
399
+ content =<<-EOF
400
+ RailsBestPracticesCom::Application.routes.draw do
401
+ root to: 'home#index'
402
+ end
403
+ EOF
404
+ runner.prepare('config/routes.rb', content)
405
+ routes = Prepares.routes
406
+ expect(routes.map(&:to_s)).to eq(["HomeController#index"])
407
+ end
408
+
409
+ it "should add root shortcut route" do
410
+ content =<<-EOF
411
+ RailsBestPracticesCom::Application.routes.draw do
412
+ root 'home#index'
413
+ end
414
+ EOF
415
+ runner.prepare('config/routes.rb', content)
416
+ routes = Prepares.routes
417
+ expect(routes.map(&:to_s)).to eq(["HomeController#index"])
418
+ end
419
+
420
+ it "should do nothing for default route" do
421
+ content =<<-EOF
422
+ RailsBestPracticesCom::Application.routes.draw do
423
+ match ':controller(/:action(/:id(.:format)))'
424
+ end
425
+ EOF
426
+ runner.prepare('config/routes.rb', content)
427
+ routes = Prepares.routes
428
+ expect(routes.size).to eq(0)
429
+ end
430
+
431
+ it "should do nothing for redirect" do
432
+ content =<<-EOF
433
+ RailsBestPracticesCom::Application.routes.draw do
434
+ match "/stories/:name" => redirect("/posts/%{name}")
435
+ match "/stories" => redirect {|p, req| "/posts/\#{req.subdomain}" }
436
+ end
437
+ EOF
438
+ runner.prepare('config/routes.rb', content)
439
+ routes = Prepares.routes
440
+ expect(routes.size).to eq(0)
441
+ end
442
+
443
+ it "should parse customize route in nested resources" do
444
+ content =<<-EOF
445
+ RailsBestPracticesCom::Application.routes.draw do
446
+ resources :posts do
447
+ resources :comments
448
+ post :stop
449
+ end
450
+ end
451
+ EOF
452
+ runner.prepare('config/routes.rb', content)
453
+ routes = Prepares.routes
454
+ expect(routes.last.to_s).to eq("PostsController#stop")
455
+ end
456
+
457
+ it "should parse custom route for resource with explicit to and different action name" do
458
+ content =<<-EOF
459
+ RailsBestPracticesCom::Application.routes.draw do
460
+ resources :posts do
461
+ get :halt, to: 'posts#stop'
462
+ end
463
+ end
464
+ EOF
465
+ runner.prepare('config/routes.rb', content)
466
+ routes = Prepares.routes
467
+ expect(routes.last.to_s).to eq("PostsController#stop")
468
+ end
469
+
470
+ it "should parse custom route for resource with symbol action name" do
471
+ content =<<-EOF
472
+ RailsBestPracticesCom::Application.routes.draw do
473
+ resources :posts do
474
+ get :halt, to: :stop
475
+ end
476
+ end
477
+ EOF
478
+ runner.prepare('config/routes.rb', content)
479
+ routes = Prepares.routes
480
+ expect(routes.last.to_s).to eq("PostsController#stop")
481
+ end
482
+
483
+ it "should not take former resources for direct get/post" do
484
+ content =<<-EOF
485
+ RailsBestPracticesCom::Application.routes.draw do
486
+ resources :posts
487
+ post "sprints/stop"
488
+ end
489
+ EOF
490
+ runner.prepare('config/routes.rb', content)
491
+ routes = Prepares.routes
492
+ expect(routes.last.to_s).to eq("SprintsController#stop")
493
+ end
494
+
495
+ it "should not parse wrong route" do
496
+ content =<<-EOF
497
+ RailsBestPracticesCom::Application.routes.draw do
498
+ match ':controller/:action' => '#index', as: :auto_complete
751
499
  end
500
+ EOF
501
+ runner.prepare('config/routes.rb', content)
502
+ routes = Prepares.routes
503
+ expect(routes.size).to eq(0)
752
504
  end
753
505
  end
754
506
  end