rails_best_practices 1.19.0 → 1.19.1

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