rails_best_practices 1.19.2 → 1.20.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -1
  3. data/.travis.yml +2 -3
  4. data/CHANGELOG.md +7 -7
  5. data/Gemfile +3 -5
  6. data/Gemfile.lock +125 -0
  7. data/Guardfile +2 -0
  8. data/README.md +6 -6
  9. data/Rakefile +2 -17
  10. data/assets/result.html.erb +2 -0
  11. data/lib/rails_best_practices.rb +3 -2
  12. data/lib/rails_best_practices/analyzer.rb +61 -49
  13. data/lib/rails_best_practices/cli.rb +22 -0
  14. data/lib/rails_best_practices/command.rb +1 -131
  15. data/lib/rails_best_practices/core/check.rb +64 -56
  16. data/lib/rails_best_practices/core/checks_loader.rb +24 -23
  17. data/lib/rails_best_practices/core/configs.rb +1 -2
  18. data/lib/rails_best_practices/core/controllers.rb +1 -2
  19. data/lib/rails_best_practices/core/error.rb +1 -1
  20. data/lib/rails_best_practices/core/helpers.rb +1 -2
  21. data/lib/rails_best_practices/core/mailers.rb +1 -2
  22. data/lib/rails_best_practices/core/methods.rb +27 -21
  23. data/lib/rails_best_practices/core/model_associations.rb +10 -5
  24. data/lib/rails_best_practices/core/models.rb +1 -2
  25. data/lib/rails_best_practices/core/modules.rb +1 -1
  26. data/lib/rails_best_practices/core/routes.rb +2 -2
  27. data/lib/rails_best_practices/core/runner.rb +67 -73
  28. data/lib/rails_best_practices/lexicals/long_line_check.rb +7 -3
  29. data/lib/rails_best_practices/option_parser.rb +156 -0
  30. data/lib/rails_best_practices/prepares.rb +1 -1
  31. data/lib/rails_best_practices/prepares/controller_prepare.rb +24 -17
  32. data/lib/rails_best_practices/prepares/gemfile_prepare.rb +2 -2
  33. data/lib/rails_best_practices/prepares/helper_prepare.rb +6 -1
  34. data/lib/rails_best_practices/prepares/initializer_prepare.rb +3 -3
  35. data/lib/rails_best_practices/prepares/mailer_prepare.rb +2 -1
  36. data/lib/rails_best_practices/prepares/model_prepare.rb +63 -23
  37. data/lib/rails_best_practices/prepares/route_prepare.rb +28 -21
  38. data/lib/rails_best_practices/prepares/schema_prepare.rb +1 -1
  39. data/lib/rails_best_practices/reviews/add_model_virtual_attribute_review.rb +38 -34
  40. data/lib/rails_best_practices/reviews/always_add_db_index_review.rb +94 -89
  41. data/lib/rails_best_practices/reviews/check_destroy_return_value_review.rb +15 -5
  42. data/lib/rails_best_practices/reviews/check_save_return_value_review.rb +20 -8
  43. data/lib/rails_best_practices/reviews/default_scope_is_evil_review.rb +1 -1
  44. data/lib/rails_best_practices/reviews/dry_bundler_in_capistrano_review.rb +1 -1
  45. data/lib/rails_best_practices/reviews/hash_syntax_review.rb +16 -16
  46. data/lib/rails_best_practices/reviews/isolate_seed_data_review.rb +12 -12
  47. data/lib/rails_best_practices/reviews/keep_finders_on_their_own_model_review.rb +10 -11
  48. data/lib/rails_best_practices/reviews/law_of_demeter_review.rb +25 -24
  49. data/lib/rails_best_practices/reviews/move_code_into_controller_review.rb +4 -4
  50. data/lib/rails_best_practices/reviews/move_code_into_helper_review.rb +9 -10
  51. data/lib/rails_best_practices/reviews/move_finder_to_named_scope_review.rb +10 -11
  52. data/lib/rails_best_practices/reviews/needless_deep_nesting_review.rb +24 -22
  53. data/lib/rails_best_practices/reviews/not_rescue_exception_review.rb +1 -1
  54. data/lib/rails_best_practices/reviews/not_use_default_route_review.rb +1 -2
  55. data/lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb +1 -1
  56. data/lib/rails_best_practices/reviews/overuse_route_customizations_review.rb +8 -8
  57. data/lib/rails_best_practices/reviews/protect_mass_assignment_review.rb +35 -32
  58. data/lib/rails_best_practices/reviews/remove_empty_helpers_review.rb +4 -4
  59. data/lib/rails_best_practices/reviews/remove_unused_methods_in_controllers_review.rb +26 -19
  60. data/lib/rails_best_practices/reviews/remove_unused_methods_in_helpers_review.rb +12 -10
  61. data/lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb +38 -18
  62. data/lib/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review.rb +11 -11
  63. data/lib/rails_best_practices/reviews/restrict_auto_generated_routes_review.rb +77 -74
  64. data/lib/rails_best_practices/reviews/review.rb +2 -1
  65. data/lib/rails_best_practices/reviews/simplify_render_in_controllers_review.rb +2 -3
  66. data/lib/rails_best_practices/reviews/simplify_render_in_views_review.rb +12 -12
  67. data/lib/rails_best_practices/reviews/use_before_filter_review.rb +18 -15
  68. data/lib/rails_best_practices/reviews/use_model_association_review.rb +15 -15
  69. data/lib/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review.rb +24 -22
  70. data/lib/rails_best_practices/reviews/use_observer_review.rb +28 -28
  71. data/lib/rails_best_practices/reviews/use_parentheses_in_method_def_review.rb +6 -6
  72. data/lib/rails_best_practices/reviews/use_query_attribute_review.rb +68 -66
  73. data/lib/rails_best_practices/reviews/use_say_with_time_in_migrations_review.rb +9 -8
  74. data/lib/rails_best_practices/reviews/use_scope_access_review.rb +16 -14
  75. data/lib/rails_best_practices/reviews/use_turbo_sprockets_rails3_review.rb +2 -1
  76. data/lib/rails_best_practices/version.rb +1 -1
  77. data/rails_best_practices.gemspec +38 -43
  78. data/spec/fixtures/lib/rails_best_practices/plugins/reviews/not_use_rails_root_review.rb +1 -2
  79. data/spec/rails_best_practices/analyzer_spec.rb +73 -42
  80. data/spec/rails_best_practices/core/check_spec.rb +5 -5
  81. data/spec/rails_best_practices/core/checks_loader_spec.rb +3 -3
  82. data/spec/rails_best_practices/core/configs_spec.rb +1 -1
  83. data/spec/rails_best_practices/core/controllers_spec.rb +1 -1
  84. data/spec/rails_best_practices/core/error_spec.rb +21 -18
  85. data/spec/rails_best_practices/core/except_methods_spec.rb +7 -7
  86. data/spec/rails_best_practices/core/gems_spec.rb +4 -4
  87. data/spec/rails_best_practices/core/helpers_spec.rb +1 -1
  88. data/spec/rails_best_practices/core/klasses_spec.rb +3 -3
  89. data/spec/rails_best_practices/core/mailers_spec.rb +1 -1
  90. data/spec/rails_best_practices/core/methods_spec.rb +6 -6
  91. data/spec/rails_best_practices/core/model_associations_spec.rb +10 -6
  92. data/spec/rails_best_practices/core/model_attributes_spec.rb +4 -4
  93. data/spec/rails_best_practices/core/models_spec.rb +1 -1
  94. data/spec/rails_best_practices/core/modules_spec.rb +5 -5
  95. data/spec/rails_best_practices/core/routes_spec.rb +5 -5
  96. data/spec/rails_best_practices/core/runner_spec.rb +9 -7
  97. data/spec/rails_best_practices/core_ext/erubis_spec.rb +10 -10
  98. data/spec/rails_best_practices/lexicals/long_line_check_spec.rb +32 -31
  99. data/spec/rails_best_practices/lexicals/remove_tab_check_spec.rb +6 -6
  100. data/spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb +6 -6
  101. data/spec/rails_best_practices/prepares/config_prepare_spec.rb +2 -2
  102. data/spec/rails_best_practices/prepares/controller_prepare_spec.rb +18 -10
  103. data/spec/rails_best_practices/prepares/gemfile_prepare_spec.rb +17 -17
  104. data/spec/rails_best_practices/prepares/helper_prepare_spec.rb +3 -3
  105. data/spec/rails_best_practices/prepares/initializer_prepare_spec.rb +3 -3
  106. data/spec/rails_best_practices/prepares/mailer_prepare_spec.rb +2 -2
  107. data/spec/rails_best_practices/prepares/model_prepare_spec.rb +79 -43
  108. data/spec/rails_best_practices/prepares/route_prepare_spec.rb +141 -76
  109. data/spec/rails_best_practices/prepares/schema_prepare_spec.rb +2 -2
  110. data/spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb +18 -12
  111. data/spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb +28 -22
  112. data/spec/rails_best_practices/reviews/check_destroy_return_value_review_spec.rb +15 -13
  113. data/spec/rails_best_practices/reviews/check_save_return_value_review_spec.rb +31 -21
  114. data/spec/rails_best_practices/reviews/default_scope_is_evil_review_spec.rb +6 -6
  115. data/spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb +5 -5
  116. data/spec/rails_best_practices/reviews/hash_syntax_review_spec.rb +13 -13
  117. data/spec/rails_best_practices/reviews/isolate_seed_data_review_spec.rb +7 -7
  118. data/spec/rails_best_practices/reviews/keep_finders_on_their_own_model_review_spec.rb +9 -9
  119. data/spec/rails_best_practices/reviews/law_of_demeter_review_spec.rb +29 -22
  120. data/spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb +6 -6
  121. data/spec/rails_best_practices/reviews/move_code_into_helper_review_spec.rb +11 -6
  122. data/spec/rails_best_practices/reviews/move_code_into_model_review_spec.rb +32 -22
  123. data/spec/rails_best_practices/reviews/move_finder_to_named_scope_review_spec.rb +7 -7
  124. data/spec/rails_best_practices/reviews/move_model_logic_into_model_review_spec.rb +9 -7
  125. data/spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb +9 -9
  126. data/spec/rails_best_practices/reviews/not_rescue_exception_review_spec.rb +9 -9
  127. data/spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb +5 -5
  128. data/spec/rails_best_practices/reviews/not_use_time_ago_in_words_review_spec.rb +7 -7
  129. data/spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb +7 -7
  130. data/spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb +24 -17
  131. data/spec/rails_best_practices/reviews/remove_empty_helpers_review_spec.rb +6 -6
  132. data/spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb +64 -31
  133. data/spec/rails_best_practices/reviews/remove_unused_methods_in_helpers_review_spec.rb +21 -14
  134. data/spec/rails_best_practices/reviews/remove_unused_methods_in_models_review_spec.rb +57 -53
  135. data/spec/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review_spec.rb +10 -8
  136. data/spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb +20 -14
  137. data/spec/rails_best_practices/reviews/restrict_auto_generated_routes_review_spec.rb +54 -31
  138. data/spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb +9 -9
  139. data/spec/rails_best_practices/reviews/simplify_render_in_views_review_spec.rb +13 -13
  140. data/spec/rails_best_practices/reviews/use_before_filter_review_spec.rb +11 -9
  141. data/spec/rails_best_practices/reviews/use_model_association_review_spec.rb +7 -7
  142. data/spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb +35 -31
  143. data/spec/rails_best_practices/reviews/use_observer_review_spec.rb +6 -6
  144. data/spec/rails_best_practices/reviews/use_parentheses_in_method_def_review_spec.rb +10 -8
  145. data/spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb +31 -24
  146. data/spec/rails_best_practices/reviews/use_say_with_time_in_migrations_review_spec.rb +15 -11
  147. data/spec/rails_best_practices/reviews/use_scope_access_review_spec.rb +14 -14
  148. data/spec/rails_best_practices/reviews/use_turbo_sprockets_rails3_review_spec.rb +61 -59
  149. metadata +16 -18
@@ -5,9 +5,9 @@ require 'spec_helper'
5
5
  module RailsBestPractices
6
6
  module Reviews
7
7
  describe MoveCodeIntoModelReview do
8
- let(:runner) { Core::Runner.new(reviews: MoveCodeIntoModelReview.new) }
8
+ let(:runner) { Core::Runner.new(reviews: described_class.new) }
9
9
 
10
- it 'should move code into model' do
10
+ it 'moves code into model' do
11
11
  content = <<-EOF
12
12
  <% if current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user)) %>
13
13
  <%= link_to 'Edit this post', edit_post_url(@post) %>
@@ -15,48 +15,58 @@ module RailsBestPractices
15
15
  EOF
16
16
  runner.review('app/views/posts/show.html.erb', content)
17
17
  expect(runner.errors.size).to eq(1)
18
- expect(runner.errors[0].to_s).to eq('app/views/posts/show.html.erb:1 - move code into model (@post use_count > 2)')
18
+ expect(runner.errors[0].to_s).to eq(
19
+ 'app/views/posts/show.html.erb:1 - move code into model (@post use_count > 2)'
20
+ )
19
21
  end
20
22
 
21
- it 'should move code into model with haml' do
22
- content = <<-EOF
23
- - if current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user))
24
- = link_to 'Edit this post', edit_post_url(@post)
23
+ it 'moves code into model with haml' do
24
+ content = <<~EOF
25
+ - if current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user))
26
+ = link_to 'Edit this post', edit_post_url(@post)
25
27
  EOF
26
28
  runner.review('app/views/posts/show.html.haml', content)
27
29
  expect(runner.errors.size).to eq(1)
28
- expect(runner.errors[0].to_s).to eq('app/views/posts/show.html.haml:1 - move code into model (@post use_count > 2)')
30
+ expect(runner.errors[0].to_s).to eq(
31
+ 'app/views/posts/show.html.haml:1 - move code into model (@post use_count > 2)'
32
+ )
29
33
  end
30
34
 
31
- it 'should move code into model with slim' do
32
- content = <<-EOF
33
- - if current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user))
34
- = link_to 'Edit this post', edit_post_url(@post)
35
+ it 'moves code into model with slim' do
36
+ content = <<~EOF
37
+ - if current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user))
38
+ = link_to 'Edit this post', edit_post_url(@post)
35
39
  EOF
36
40
  runner.review('app/views/posts/show.html.slim', content)
37
41
  expect(runner.errors.size).to eq(1)
38
- expect(runner.errors[0].to_s).to eq('app/views/posts/show.html.slim:1 - move code into model (@post use_count > 2)')
42
+ expect(runner.errors[0].to_s).to eq(
43
+ 'app/views/posts/show.html.slim:1 - move code into model (@post use_count > 2)'
44
+ )
39
45
  end
40
46
 
41
- it 'should move code into model with if in one line' do
47
+ it 'moves code into model with if in one line' do
42
48
  content = <<-EOF
43
49
  <%= link_to 'Edit this post', edit_post_url(@post) if current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user)) %>
44
50
  EOF
45
51
  runner.review('app/views/posts/show.html.erb', content)
46
52
  expect(runner.errors.size).to eq(1)
47
- expect(runner.errors[0].to_s).to eq('app/views/posts/show.html.erb:1 - move code into model (@post use_count > 2)')
53
+ expect(runner.errors[0].to_s).to eq(
54
+ 'app/views/posts/show.html.erb:1 - move code into model (@post use_count > 2)'
55
+ )
48
56
  end
49
57
 
50
- it "should move code into model with '? :'" do
58
+ it "moves code into model with '? :'" do
51
59
  content = <<-EOF
52
60
  <%= current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user)) ? link_to('Edit this post', edit_post_url(@post)) : '' %>
53
61
  EOF
54
62
  runner.review('app/views/posts/show.html.erb', content)
55
63
  expect(runner.errors.size).to eq(1)
56
- expect(runner.errors[0].to_s).to eq('app/views/posts/show.html.erb:1 - move code into model (@post use_count > 2)')
64
+ expect(runner.errors[0].to_s).to eq(
65
+ 'app/views/posts/show.html.erb:1 - move code into model (@post use_count > 2)'
66
+ )
57
67
  end
58
68
 
59
- it 'should move code into model only review for current if conditional statement' do
69
+ it 'moves code into model only review for current if conditional statement' do
60
70
  content = <<-EOF
61
71
  <% if @post.title %>
62
72
  <% if @post.user %>
@@ -69,7 +79,7 @@ module RailsBestPractices
69
79
  expect(runner.errors.size).to eq(0)
70
80
  end
71
81
 
72
- it 'should not move code into model' do
82
+ it 'does not move code into model' do
73
83
  content = <<-EOF
74
84
  <% if @post.editable_by?(current_user) %>
75
85
  <%= link_to 'Edit this post', edit_post_url(@post) %>
@@ -79,7 +89,7 @@ module RailsBestPractices
79
89
  expect(runner.errors.size).to eq(0)
80
90
  end
81
91
 
82
- it 'should not move code into model for multiple calls on same variable node' do
92
+ it 'does not move code into model for multiple calls on same variable node' do
83
93
  content = <<-EOF
84
94
  <% if !job.company.blank? && job.company.title? %>
85
95
  <% end %>
@@ -88,8 +98,8 @@ module RailsBestPractices
88
98
  expect(runner.errors.size).to eq(0)
89
99
  end
90
100
 
91
- it 'should not check ignored files' do
92
- runner = Core::Runner.new(reviews: MoveCodeIntoModelReview.new(ignored_files: /app\/views\/post/))
101
+ it 'does not check ignored files' do
102
+ runner = Core::Runner.new(reviews: described_class.new(ignored_files: %r{app/views/post}))
93
103
  content = <<-EOF
94
104
  <% if current_user && @post.user && (current_user == @post.user || @post.editors.include?(current_user)) %>
95
105
  <%= link_to 'Edit this post', edit_post_url(@post) %>
@@ -5,9 +5,9 @@ require 'spec_helper'
5
5
  module RailsBestPractices
6
6
  module Reviews
7
7
  describe MoveFinderToNamedScopeReview do
8
- let(:runner) { Core::Runner.new(reviews: MoveFinderToNamedScopeReview.new) }
8
+ let(:runner) { Core::Runner.new(reviews: described_class.new) }
9
9
 
10
- it 'should move finder to named_scope' do
10
+ it 'moves finder to named_scope' do
11
11
  content = <<-EOF
12
12
  class PostsController < ActionController::Base
13
13
  def index
@@ -27,7 +27,7 @@ module RailsBestPractices
27
27
  expect(runner.errors[1].to_s).to eq('app/controllers/posts_controller.rb:7 - move finder to named_scope')
28
28
  end
29
29
 
30
- it 'should not move simple finder' do
30
+ it 'does not move simple finder' do
31
31
  content = <<-EOF
32
32
  class PostsController < ActionController::Base
33
33
  def index
@@ -44,7 +44,7 @@ module RailsBestPractices
44
44
  expect(runner.errors.size).to eq(0)
45
45
  end
46
46
 
47
- it 'should not move namd_scope' do
47
+ it 'does not move namd_scope' do
48
48
  content = <<-EOF
49
49
  class PostsController < ActionController::Base
50
50
  def index
@@ -57,7 +57,7 @@ module RailsBestPractices
57
57
  expect(runner.errors.size).to eq(0)
58
58
  end
59
59
 
60
- it 'should not review model file' do
60
+ it 'does not review model file' do
61
61
  content = <<-EOF
62
62
  class Post < ActiveRecord::Base
63
63
  def published
@@ -75,8 +75,8 @@ module RailsBestPractices
75
75
  expect(runner.errors.size).to eq(0)
76
76
  end
77
77
 
78
- it 'should not check ignored files' do
79
- runner = Core::Runner.new(reviews: MoveFinderToNamedScopeReview.new(ignored_files: /app\/controllers\/posts/))
78
+ it 'does not check ignored files' do
79
+ runner = Core::Runner.new(reviews: described_class.new(ignored_files: %r{app/controllers/posts}))
80
80
  content = <<-EOF
81
81
  class PostsController < ActionController::Base
82
82
  def index
@@ -5,9 +5,9 @@ require 'spec_helper'
5
5
  module RailsBestPractices
6
6
  module Reviews
7
7
  describe MoveModelLogicIntoModelReview do
8
- let(:runner) { Core::Runner.new(reviews: MoveModelLogicIntoModelReview.new) }
8
+ let(:runner) { Core::Runner.new(reviews: described_class.new) }
9
9
 
10
- it 'should move model logic into model' do
10
+ it 'moves model logic into model' do
11
11
  content = <<-EOF
12
12
  class PostsController < ApplicationController
13
13
  def publish
@@ -26,10 +26,12 @@ module RailsBestPractices
26
26
  EOF
27
27
  runner.review('app/controllers/posts_controller.rb', content)
28
28
  expect(runner.errors.size).to eq(1)
29
- expect(runner.errors[0].to_s).to eq('app/controllers/posts_controller.rb:2 - move model logic into model (@post use_count > 4)')
29
+ expect(runner.errors[0].to_s).to eq(
30
+ 'app/controllers/posts_controller.rb:2 - move model logic into model (@post use_count > 4)'
31
+ )
30
32
  end
31
33
 
32
- it 'should not move model logic into model with simple model calling' do
34
+ it 'does not move model logic into model with simple model calling' do
33
35
  content = <<-EOF
34
36
  class PostsController < ApplicationController
35
37
  def publish
@@ -45,7 +47,7 @@ module RailsBestPractices
45
47
  expect(runner.errors.size).to eq(0)
46
48
  end
47
49
 
48
- it 'should not move model logic into model with self calling' do
50
+ it 'does not move model logic into model with self calling' do
49
51
  content = <<-EOF
50
52
  class PostsController < ApplicationController
51
53
  def publish
@@ -61,8 +63,8 @@ module RailsBestPractices
61
63
  expect(runner.errors.size).to eq(0)
62
64
  end
63
65
 
64
- it 'should not check ignored files' do
65
- runner = Core::Runner.new(reviews: MoveModelLogicIntoModelReview.new(ignored_files: /app\/controllers\/posts/))
66
+ it 'does not check ignored files' do
67
+ runner = Core::Runner.new(reviews: described_class.new(ignored_files: %r{app/controllers/posts}))
66
68
  content = <<-EOF
67
69
  class PostsController < ApplicationController
68
70
  def publish
@@ -5,9 +5,9 @@ require 'spec_helper'
5
5
  module RailsBestPractices
6
6
  module Reviews
7
7
  describe NeedlessDeepNestingReview do
8
- let(:runner) { Core::Runner.new(reviews: NeedlessDeepNestingReview.new) }
8
+ let(:runner) { Core::Runner.new(reviews: described_class.new) }
9
9
 
10
- it 'should needless deep nesting' do
10
+ it 'needlesses deep nesting' do
11
11
  content = <<-EOF
12
12
  resources :posts do
13
13
  resources :comments do
@@ -20,7 +20,7 @@ module RailsBestPractices
20
20
  expect(runner.errors[0].to_s).to eq('config/routes.rb:3 - needless deep nesting (nested_count > 2)')
21
21
  end
22
22
 
23
- it 'should not needless deep nesting for shallow' do
23
+ it 'does not needless deep nesting for shallow' do
24
24
  content = <<-EOF
25
25
  resources :posts, shallow: true do
26
26
  resources :comments do
@@ -32,7 +32,7 @@ module RailsBestPractices
32
32
  expect(runner.errors.size).to eq(0)
33
33
  end
34
34
 
35
- it 'should not needless deep nesting for shallow 4 levels' do
35
+ it 'does not needless deep nesting for shallow 4 levels' do
36
36
  content = <<-EOF
37
37
  resources :applications, shallow: true, only: [:index, :show, :create] do
38
38
  resources :events, only: [:index, :show, :create, :subscribe, :push] do
@@ -46,7 +46,7 @@ module RailsBestPractices
46
46
  expect(runner.errors.size).to eq(0)
47
47
  end
48
48
 
49
- it 'should needless deep nesting with resource' do
49
+ it 'needlesses deep nesting with resource' do
50
50
  content = <<-EOF
51
51
  resources :posts do
52
52
  resources :comments do
@@ -59,7 +59,7 @@ module RailsBestPractices
59
59
  expect(runner.errors[0].to_s).to eq('config/routes.rb:3 - needless deep nesting (nested_count > 2)')
60
60
  end
61
61
 
62
- it 'should needless deep nesting with block node' do
62
+ it 'needlesses deep nesting with block node' do
63
63
  content = <<-EOF
64
64
  resources :posts do
65
65
  resources :comments do
@@ -73,7 +73,7 @@ module RailsBestPractices
73
73
  expect(runner.errors[0].to_s).to eq('config/routes.rb:3 - needless deep nesting (nested_count > 2)')
74
74
  end
75
75
 
76
- it 'should no needless deep nesting' do
76
+ it 'noes needless deep nesting' do
77
77
  content = <<-EOF
78
78
  resources :posts do
79
79
  resources :comments
@@ -88,8 +88,8 @@ module RailsBestPractices
88
88
  expect(runner.errors.size).to eq(0)
89
89
  end
90
90
 
91
- it 'should not check ignored files' do
92
- runner = Core::Runner.new(reviews: NeedlessDeepNestingReview.new(ignored_files: /config\/routes/))
91
+ it 'does not check ignored files' do
92
+ runner = Core::Runner.new(reviews: described_class.new(ignored_files: %r{config/routes}))
93
93
  content = <<-EOF
94
94
  map.resources :posts do |post|
95
95
  post.resources :comments do |comment|
@@ -5,10 +5,10 @@ require 'spec_helper'
5
5
  module RailsBestPractices
6
6
  module Reviews
7
7
  describe NotRescueExceptionReview do
8
- let(:runner) { Core::Runner.new(reviews: NotRescueExceptionReview.new) }
8
+ let(:runner) { Core::Runner.new(reviews: described_class.new) }
9
9
 
10
10
  describe 'not_rescue_exception' do
11
- it 'should not rescue exception in method rescue with named var' do
11
+ it 'does not rescue exception in method rescue with named var' do
12
12
  content = <<-EOF
13
13
  def my_method
14
14
  do_something
@@ -21,7 +21,7 @@ module RailsBestPractices
21
21
  expect(runner.errors[0].to_s).to eq("app/helpers/posts_helper.rb:3 - Don't rescue Exception")
22
22
  end
23
23
 
24
- it 'should not rescue exception in method rescue without named var' do
24
+ it 'does not rescue exception in method rescue without named var' do
25
25
  content = <<-EOF
26
26
  def my_method
27
27
  do_something
@@ -34,7 +34,7 @@ module RailsBestPractices
34
34
  expect(runner.errors[0].to_s).to eq("app/helpers/posts_helper.rb:3 - Don't rescue Exception")
35
35
  end
36
36
 
37
- it 'should not rescue exception in block rescue with named var' do
37
+ it 'does not rescue exception in block rescue with named var' do
38
38
  content = <<-EOF
39
39
  def my_method
40
40
  begin
@@ -49,7 +49,7 @@ module RailsBestPractices
49
49
  expect(runner.errors[0].to_s).to eq("app/helpers/posts_helper.rb:4 - Don't rescue Exception")
50
50
  end
51
51
 
52
- it 'should not rescue exception in block rescue without named var' do
52
+ it 'does not rescue exception in block rescue without named var' do
53
53
  content = <<-EOF
54
54
  def my_method
55
55
  begin
@@ -64,7 +64,7 @@ module RailsBestPractices
64
64
  expect(runner.errors[0].to_s).to eq("app/helpers/posts_helper.rb:4 - Don't rescue Exception")
65
65
  end
66
66
 
67
- it 'should allow rescue implicit StandardError in block rescue without named var' do
67
+ it 'allows rescue implicit StandardError in block rescue without named var' do
68
68
  content = <<-EOF
69
69
  def my_method
70
70
  begin
@@ -78,7 +78,7 @@ module RailsBestPractices
78
78
  expect(runner.errors.size).to eq(0)
79
79
  end
80
80
 
81
- it 'should allow rescue explicit StandardError in block rescue without named var' do
81
+ it 'allows rescue explicit StandardError in block rescue without named var' do
82
82
  content = <<-EOF
83
83
  def my_method
84
84
  begin
@@ -92,8 +92,8 @@ module RailsBestPractices
92
92
  expect(runner.errors.size).to eq(0)
93
93
  end
94
94
 
95
- it 'should not check ignored files' do
96
- runner = Core::Runner.new(reviews: NotRescueExceptionReview.new(ignored_files: /posts_helper/))
95
+ it 'does not check ignored files' do
96
+ runner = Core::Runner.new(reviews: described_class.new(ignored_files: /posts_helper/))
97
97
  content = <<-EOF
98
98
  def my_method
99
99
  do_something
@@ -5,9 +5,9 @@ require 'spec_helper'
5
5
  module RailsBestPractices
6
6
  module Reviews
7
7
  describe NotUseDefaultRouteReview do
8
- let(:runner) { Core::Runner.new(reviews: NotUseDefaultRouteReview.new) }
8
+ let(:runner) { Core::Runner.new(reviews: described_class.new) }
9
9
 
10
- it 'should not use default route' do
10
+ it 'does not use default route' do
11
11
  content = <<-EOF
12
12
  RailsBestpracticesCom::Application.routes.draw do |map|
13
13
  resources :posts
@@ -20,7 +20,7 @@ module RailsBestPractices
20
20
  expect(runner.errors[0].to_s).to eq('config/routes.rb:4 - not use default route')
21
21
  end
22
22
 
23
- it 'should no not use default route' do
23
+ it 'noes not use default route' do
24
24
  content = <<-EOF
25
25
  RailsBestpracticesCom::Application.routes.draw do |map|
26
26
  resources :posts
@@ -30,8 +30,8 @@ module RailsBestPractices
30
30
  expect(runner.errors.size).to eq(0)
31
31
  end
32
32
 
33
- it 'should not check ignored files' do
34
- runner = Core::Runner.new(reviews: NotUseDefaultRouteReview.new(ignored_files: /config\/routes\.rb/))
33
+ it 'does not check ignored files' do
34
+ runner = Core::Runner.new(reviews: described_class.new(ignored_files: %r{config/routes\.rb}))
35
35
  content = <<-EOF
36
36
  RailsBestpracticesCom::Application.routes.draw do |map|
37
37
  resources :posts
@@ -5,10 +5,10 @@ require 'spec_helper'
5
5
  module RailsBestPractices
6
6
  module Reviews
7
7
  describe NotUseTimeAgoInWordsReview do
8
- let(:runner) { Core::Runner.new(reviews: NotUseTimeAgoInWordsReview.new) }
8
+ let(:runner) { Core::Runner.new(reviews: described_class.new) }
9
9
 
10
10
  describe 'time_ago_in_words' do
11
- it 'should not use in views' do
11
+ it 'does not use in views' do
12
12
  content = <<-EOF
13
13
  <%= time_ago_in_words(post.created_at) %>
14
14
  EOF
@@ -17,7 +17,7 @@ module RailsBestPractices
17
17
  expect(runner.errors[0].to_s).to eq('app/views/posts/show.html.erb:1 - not use time_ago_in_words')
18
18
  end
19
19
 
20
- it 'should not use in helpers' do
20
+ it 'does not use in helpers' do
21
21
  content = <<-EOF
22
22
  def timeago
23
23
  content_tag(:p, time_ago_in_words(post.created_at))
@@ -30,7 +30,7 @@ module RailsBestPractices
30
30
  end
31
31
 
32
32
  describe 'distance_of_time_in_words_to_now' do
33
- it 'should not use in views' do
33
+ it 'does not use in views' do
34
34
  content = <<-EOF
35
35
  <%= distance_of_time_in_words_to_now(post.created_at) %>
36
36
  EOF
@@ -39,7 +39,7 @@ module RailsBestPractices
39
39
  expect(runner.errors[0].to_s).to eq('app/views/posts/show.html.erb:1 - not use time_ago_in_words')
40
40
  end
41
41
 
42
- it 'should not use in helpers' do
42
+ it 'does not use in helpers' do
43
43
  content = <<-EOF
44
44
  def timeago
45
45
  content_tag(:p, distance_of_time_in_words_to_now(post.created_at))
@@ -51,8 +51,8 @@ module RailsBestPractices
51
51
  end
52
52
  end
53
53
 
54
- it 'should not check ignored files' do
55
- runner = Core::Runner.new(reviews: NotUseTimeAgoInWordsReview.new(ignored_files: /posts_helper/))
54
+ it 'does not check ignored files' do
55
+ runner = Core::Runner.new(reviews: described_class.new(ignored_files: /posts_helper/))
56
56
  content = <<-EOF
57
57
  def timeago
58
58
  content_tag(:p, time_ago_in_words(post.created_at))
@@ -5,9 +5,9 @@ require 'spec_helper'
5
5
  module RailsBestPractices
6
6
  module Reviews
7
7
  describe OveruseRouteCustomizationsReview do
8
- let(:runner) { Core::Runner.new(reviews: OveruseRouteCustomizationsReview.new) }
8
+ let(:runner) { Core::Runner.new(reviews: described_class.new) }
9
9
 
10
- it 'should overuse route customizations' do
10
+ it 'overuses route customizations' do
11
11
  content = <<-EOF
12
12
  RailsBestpracticesCom::Application.routes.draw do
13
13
  resources :posts do
@@ -28,7 +28,7 @@ module RailsBestPractices
28
28
  expect(runner.errors[0].to_s).to eq('config/routes.rb:2 - overuse route customizations (customize_count > 3)')
29
29
  end
30
30
 
31
- it 'should overuse route customizations another way' do
31
+ it 'overuses route customizations another way' do
32
32
  content = <<-EOF
33
33
  RailsBestpracticesCom::Application.routes.draw do
34
34
  resources :posts do
@@ -44,7 +44,7 @@ module RailsBestPractices
44
44
  expect(runner.errors[0].to_s).to eq('config/routes.rb:2 - overuse route customizations (customize_count > 3)')
45
45
  end
46
46
 
47
- it 'should not overuse route customizations without customization' do
47
+ it 'does not overuse route customizations without customization' do
48
48
  content = <<-EOF
49
49
  RailsBestpracticesCom::Application.routes.draw do
50
50
  resources :posts
@@ -54,7 +54,7 @@ module RailsBestPractices
54
54
  expect(runner.errors.size).to eq(0)
55
55
  end
56
56
 
57
- it 'should not overuse route customizations when customize route is only one' do
57
+ it 'does not overuse route customizations when customize route is only one' do
58
58
  content = <<-EOF
59
59
  RailsBestpracticesCom::Application.routes.draw do
60
60
  resources :posts do
@@ -68,8 +68,8 @@ module RailsBestPractices
68
68
  expect(runner.errors.size).to eq(0)
69
69
  end
70
70
 
71
- it 'should not check ignored files' do
72
- runner = Core::Runner.new(reviews: OveruseRouteCustomizationsReview.new(ignored_files: /config\/routes\.rb/))
71
+ it 'does not check ignored files' do
72
+ runner = Core::Runner.new(reviews: described_class.new(ignored_files: %r{config/routes\.rb}))
73
73
  content = <<-EOF
74
74
  ActionController::Routing::Routes.draw do |map|
75
75
  map.resources :posts, member: { comments: :get,