rails_best_practices 1.9.0 → 1.9.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 (81) hide show
  1. data/.travis.yml +4 -1
  2. data/Gemfile +0 -3
  3. data/Gemfile.lock +10 -9
  4. data/README.md +2 -0
  5. data/lib/rails_best_practices/analyzer.rb +40 -21
  6. data/lib/rails_best_practices/core.rb +1 -0
  7. data/lib/rails_best_practices/core/check.rb +12 -0
  8. data/lib/rails_best_practices/core/configs.rb +7 -0
  9. data/lib/rails_best_practices/core/error.rb +2 -1
  10. data/lib/rails_best_practices/core/routes.rb +11 -5
  11. data/lib/rails_best_practices/core/runner.rb +6 -2
  12. data/lib/rails_best_practices/core_ext/sexp.rb +3 -1
  13. data/lib/rails_best_practices/prepares.rb +5 -0
  14. data/lib/rails_best_practices/prepares/config_prepare.rb +21 -0
  15. data/lib/rails_best_practices/prepares/route_prepare.rb +24 -7
  16. data/lib/rails_best_practices/reviews/protect_mass_assignment_review.rb +11 -3
  17. data/lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb +7 -3
  18. data/lib/rails_best_practices/version.rb +1 -1
  19. data/rails_best_practices.gemspec +1 -0
  20. data/spec/rails_best_practices/analyzer_spec.rb +52 -32
  21. data/spec/rails_best_practices/core/check_spec.rb +64 -45
  22. data/spec/rails_best_practices/core/checking_visitor_spec.rb +65 -64
  23. data/spec/rails_best_practices/core/configs_spec.rb +7 -0
  24. data/spec/rails_best_practices/core/controllers_spec.rb +4 -2
  25. data/spec/rails_best_practices/core/error_spec.rb +28 -22
  26. data/spec/rails_best_practices/core/helpers_spec.rb +4 -2
  27. data/spec/rails_best_practices/core/klasses_spec.rb +8 -6
  28. data/spec/rails_best_practices/core/mailers_spec.rb +4 -2
  29. data/spec/rails_best_practices/core/methods_spec.rb +37 -35
  30. data/spec/rails_best_practices/core/model_associations_spec.rb +17 -15
  31. data/spec/rails_best_practices/core/model_attributes_spec.rb +17 -15
  32. data/spec/rails_best_practices/core/models_spec.rb +4 -2
  33. data/spec/rails_best_practices/core/modules_spec.rb +21 -19
  34. data/spec/rails_best_practices/core/nil_spec.rb +23 -21
  35. data/spec/rails_best_practices/core/routes_spec.rb +21 -14
  36. data/spec/rails_best_practices/core/runner_spec.rb +17 -15
  37. data/spec/rails_best_practices/core_ext/sexp_spec.rb +32 -7
  38. data/spec/rails_best_practices/lexicals/remove_tab_check_spec.rb +35 -31
  39. data/spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb +35 -31
  40. data/spec/rails_best_practices/prepares/config_prepare_spec.rb +24 -0
  41. data/spec/rails_best_practices/prepares/controller_prepare_spec.rb +122 -123
  42. data/spec/rails_best_practices/prepares/helper_prepare_spec.rb +36 -32
  43. data/spec/rails_best_practices/prepares/mailer_prepare_spec.rb +12 -8
  44. data/spec/rails_best_practices/prepares/model_prepare_spec.rb +326 -322
  45. data/spec/rails_best_practices/prepares/route_prepare_spec.rb +619 -573
  46. data/spec/rails_best_practices/prepares/schema_prepare_spec.rb +25 -21
  47. data/spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb +85 -87
  48. data/spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb +224 -222
  49. data/spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb +30 -26
  50. data/spec/rails_best_practices/reviews/isolate_seed_data_review_spec.rb +79 -75
  51. data/spec/rails_best_practices/reviews/keep_finders_on_their_own_model_review_spec.rb +76 -72
  52. data/spec/rails_best_practices/reviews/law_of_demeter_review_spec.rb +138 -140
  53. data/spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb +38 -34
  54. data/spec/rails_best_practices/reviews/move_code_into_helper_review_spec.rb +22 -18
  55. data/spec/rails_best_practices/reviews/move_code_into_model_review_spec.rb +57 -53
  56. data/spec/rails_best_practices/reviews/move_finder_to_named_scope_review_spec.rb +62 -63
  57. data/spec/rails_best_practices/reviews/move_model_logic_into_model_review_spec.rb +51 -50
  58. data/spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb +140 -136
  59. data/spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb +48 -44
  60. data/spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb +42 -38
  61. data/spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb +151 -149
  62. data/spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb +86 -55
  63. data/spec/rails_best_practices/reviews/remove_empty_helpers_review_spec.rb +23 -19
  64. data/spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb +290 -286
  65. data/spec/rails_best_practices/reviews/remove_unused_methods_in_helpers_review_spec.rb +76 -72
  66. data/spec/rails_best_practices/reviews/remove_unused_methods_in_models_review_spec.rb +601 -597
  67. data/spec/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review_spec.rb +55 -54
  68. data/spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb +34 -30
  69. data/spec/rails_best_practices/reviews/restrict_auto_generated_routes_review_spec.rb +288 -289
  70. data/spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb +59 -55
  71. data/spec/rails_best_practices/reviews/simplify_render_in_views_review_spec.rb +73 -69
  72. data/spec/rails_best_practices/reviews/use_before_filter_review_spec.rb +89 -98
  73. data/spec/rails_best_practices/reviews/use_model_association_review_spec.rb +52 -52
  74. data/spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb +192 -190
  75. data/spec/rails_best_practices/reviews/use_observer_review_spec.rb +114 -121
  76. data/spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb +189 -190
  77. data/spec/rails_best_practices/reviews/use_say_with_time_in_migrations_review_spec.rb +97 -93
  78. data/spec/rails_best_practices/reviews/use_scope_access_review_spec.rb +146 -151
  79. data/spec/spec_helper.rb +11 -20
  80. metadata +42 -26
  81. data/.watchr.example +0 -65
@@ -1,167 +1,171 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Reviews::NeedlessDeepNestingReview do
4
- let(:runner) { RailsBestPractices::Core::Runner.new(:reviews => RailsBestPractices::Reviews::NeedlessDeepNestingReview.new) }
3
+ module RailsBestPractices
4
+ module Reviews
5
+ describe NeedlessDeepNestingReview do
6
+ let(:runner) { Core::Runner.new(:reviews => NeedlessDeepNestingReview.new) }
5
7
 
6
- describe "rails2" do
7
- it "should needless deep nesting" do
8
- content = <<-EOF
9
- map.resources :posts do |post|
10
- post.resources :comments do |comment|
11
- comment.resources :favorites
8
+ describe "rails2" do
9
+ it "should needless deep nesting" do
10
+ content = <<-EOF
11
+ map.resources :posts do |post|
12
+ post.resources :comments do |comment|
13
+ comment.resources :favorites
14
+ end
15
+ end
16
+ EOF
17
+ runner.review('config/routes.rb', content)
18
+ runner.should have(1).errors
19
+ runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
12
20
  end
13
- end
14
- EOF
15
- runner.review('config/routes.rb', content)
16
- runner.should have(1).errors
17
- runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
18
- end
19
21
 
20
- it "should not needless deep nesting for shallow" do
21
- content = <<-EOF
22
- map.resources :posts, :shallow => true do |post|
23
- post.resources :comments do |comment|
24
- comment.resources :favorites
22
+ it "should not needless deep nesting for shallow" do
23
+ content = <<-EOF
24
+ map.resources :posts, :shallow => true do |post|
25
+ post.resources :comments do |comment|
26
+ comment.resources :favorites
27
+ end
28
+ end
29
+ EOF
30
+ runner.review('config/routes.rb', content)
31
+ runner.should have(0).errors
25
32
  end
26
- end
27
- EOF
28
- runner.review('config/routes.rb', content)
29
- runner.should have(0).errors
30
- end
31
33
 
32
- it "should needless deep nesting with resource" do
33
- content = <<-EOF
34
- map.resources :posts do |post|
35
- post.resources :comments do |comment|
36
- comment.resource :vote
34
+ it "should needless deep nesting with resource" do
35
+ content = <<-EOF
36
+ map.resources :posts do |post|
37
+ post.resources :comments do |comment|
38
+ comment.resource :vote
39
+ end
40
+ end
41
+ EOF
42
+ runner.review('config/routes.rb', content)
43
+ runner.should have(1).errors
44
+ runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
37
45
  end
38
- end
39
- EOF
40
- runner.review('config/routes.rb', content)
41
- runner.should have(1).errors
42
- runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
43
- end
44
46
 
45
- it "should needless deep nesting with block node" do
46
- content = <<-EOF
47
- map.resources :posts do |post|
48
- post.resources :comments do |comment|
49
- comment.resources :favorites
47
+ it "should needless deep nesting with block node" do
48
+ content = <<-EOF
49
+ map.resources :posts do |post|
50
+ post.resources :comments do |comment|
51
+ comment.resources :favorites
52
+ end
53
+ post.resources :votes
54
+ end
55
+ EOF
56
+ runner.review('config/routes.rb', content)
57
+ runner.should have(1).errors
58
+ runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
50
59
  end
51
- post.resources :votes
52
- end
53
- EOF
54
- runner.review('config/routes.rb', content)
55
- runner.should have(1).errors
56
- runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
57
- end
58
60
 
59
- it "should no needless deep nesting" do
60
- content = <<-EOF
61
- map.resources :posts do |post|
62
- post.resources :comments
63
- end
61
+ it "should no needless deep nesting" do
62
+ content = <<-EOF
63
+ map.resources :posts do |post|
64
+ post.resources :comments
65
+ end
64
66
 
65
- map.resources :comments do |comment|
66
- comment.resources :favorites
67
- end
68
- EOF
69
- runner.review('config/routes.rb', content)
70
- runner.should have(0).errors
71
- end
67
+ map.resources :comments do |comment|
68
+ comment.resources :favorites
69
+ end
70
+ EOF
71
+ runner.review('config/routes.rb', content)
72
+ runner.should have(0).errors
73
+ end
72
74
 
73
- it "should no needless deep nesting with block node" do
74
- content = <<-EOF
75
- map.resources :comments do |comment|
76
- comment.resources :favorites
77
- comment.resources :votes
75
+ it "should no needless deep nesting with block node" do
76
+ content = <<-EOF
77
+ map.resources :comments do |comment|
78
+ comment.resources :favorites
79
+ comment.resources :votes
80
+ end
81
+ EOF
82
+ runner.review('config/routes.rb', content)
83
+ runner.should have(0).errors
84
+ end
78
85
  end
79
- EOF
80
- runner.review('config/routes.rb', content)
81
- runner.should have(0).errors
82
- end
83
- end
84
86
 
85
- describe "rails3" do
86
- it "should needless deep nesting" do
87
- content = <<-EOF
88
- resources :posts do
89
- resources :comments do
90
- resources :favorites
87
+ describe "rails3" do
88
+ it "should needless deep nesting" do
89
+ content = <<-EOF
90
+ resources :posts do
91
+ resources :comments do
92
+ resources :favorites
93
+ end
94
+ end
95
+ EOF
96
+ runner.review('config/routes.rb', content)
97
+ runner.should have(1).errors
98
+ runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
91
99
  end
92
- end
93
- EOF
94
- runner.review('config/routes.rb', content)
95
- runner.should have(1).errors
96
- runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
97
- end
98
100
 
99
- it "should not needless deep nesting for shallow" do
100
- content = <<-EOF
101
- resources :posts, :shallow => true do
102
- resources :comments do
103
- resources :favorites
101
+ it "should not needless deep nesting for shallow" do
102
+ content = <<-EOF
103
+ resources :posts, :shallow => true do
104
+ resources :comments do
105
+ resources :favorites
106
+ end
107
+ end
108
+ EOF
109
+ runner.review('config/routes.rb', content)
110
+ runner.should have(0).errors
104
111
  end
105
- end
106
- EOF
107
- runner.review('config/routes.rb', content)
108
- runner.should have(0).errors
109
- end
110
112
 
111
- it "should not needless deep nesting for shallow 4 levels" do
112
- content = <<-EOF
113
- resources :applications, shallow: true, only: [:index, :show, :create] do
114
- resources :events, only: [:index, :show, :create, :subscribe, :push] do
115
- resources :executions, only: [:index, :show] do
116
- resources :execution_statuses, only: :index
113
+ it "should not needless deep nesting for shallow 4 levels" do
114
+ content = <<-EOF
115
+ resources :applications, shallow: true, only: [:index, :show, :create] do
116
+ resources :events, only: [:index, :show, :create, :subscribe, :push] do
117
+ resources :executions, only: [:index, :show] do
118
+ resources :execution_statuses, only: :index
119
+ end
120
+ end
117
121
  end
122
+ EOF
123
+ runner.review('config/routes.rb', content)
124
+ runner.should have(0).errors
118
125
  end
119
- end
120
- EOF
121
- runner.review('config/routes.rb', content)
122
- runner.should have(0).errors
123
- end
124
126
 
125
- it "should needless deep nesting with resource" do
126
- content = <<-EOF
127
- resources :posts do
128
- resources :comments do
129
- resource :vote
127
+ it "should needless deep nesting with resource" do
128
+ content = <<-EOF
129
+ resources :posts do
130
+ resources :comments do
131
+ resource :vote
132
+ end
133
+ end
134
+ EOF
135
+ runner.review('config/routes.rb', content)
136
+ runner.should have(1).errors
137
+ runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
130
138
  end
131
- end
132
- EOF
133
- runner.review('config/routes.rb', content)
134
- runner.should have(1).errors
135
- runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
136
- end
137
139
 
138
- it "should needless deep nesting with block node" do
139
- content = <<-EOF
140
- resources :posts do
141
- resources :comments do
142
- resources :favorites
140
+ it "should needless deep nesting with block node" do
141
+ content = <<-EOF
142
+ resources :posts do
143
+ resources :comments do
144
+ resources :favorites
145
+ end
146
+ resources :votes
147
+ end
148
+ EOF
149
+ runner.review('config/routes.rb', content)
150
+ runner.should have(1).errors
151
+ runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
143
152
  end
144
- resources :votes
145
- end
146
- EOF
147
- runner.review('config/routes.rb', content)
148
- runner.should have(1).errors
149
- runner.errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)"
150
- end
151
153
 
152
- it "should no needless deep nesting" do
153
- content = <<-EOF
154
- resources :posts do
155
- resources :comments
156
- resources :votes
157
- end
154
+ it "should no needless deep nesting" do
155
+ content = <<-EOF
156
+ resources :posts do
157
+ resources :comments
158
+ resources :votes
159
+ end
158
160
 
159
- resources :comments do
160
- resources :favorites
161
+ resources :comments do
162
+ resources :favorites
163
+ end
164
+ EOF
165
+ runner.review('config/routes.rb', content)
166
+ runner.should have(0).errors
167
+ end
161
168
  end
162
- EOF
163
- runner.review('config/routes.rb', content)
164
- runner.should have(0).errors
165
169
  end
166
170
  end
167
171
  end
@@ -1,57 +1,61 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Reviews::NotUseDefaultRouteReview do
4
- let(:runner) { RailsBestPractices::Core::Runner.new(:reviews => RailsBestPractices::Reviews::NotUseDefaultRouteReview.new) }
3
+ module RailsBestPractices
4
+ module Reviews
5
+ describe NotUseDefaultRouteReview do
6
+ let(:runner) { Core::Runner.new(:reviews => NotUseDefaultRouteReview.new) }
5
7
 
6
- describe "rails2" do
7
- it "should not use default route" do
8
- content = <<-EOF
9
- ActionController::Routing::Routes.draw do |map|
10
- map.resources :posts, :member => { :push => :post }
8
+ describe "rails2" do
9
+ it "should not use default route" do
10
+ content = <<-EOF
11
+ ActionController::Routing::Routes.draw do |map|
12
+ map.resources :posts, :member => { :push => :post }
11
13
 
12
- map.connect ':controller/:action/:id'
13
- map.connect ':controller/:action/:id.:format'
14
- end
15
- EOF
16
- runner.review('config/routes.rb', content)
17
- runner.should have(2).errors
18
- runner.errors[0].to_s.should == "config/routes.rb:4 - not use default route"
19
- runner.errors[1].to_s.should == "config/routes.rb:5 - not use default route"
20
- end
14
+ map.connect ':controller/:action/:id'
15
+ map.connect ':controller/:action/:id.:format'
16
+ end
17
+ EOF
18
+ runner.review('config/routes.rb', content)
19
+ runner.should have(2).errors
20
+ runner.errors[0].to_s.should == "config/routes.rb:4 - not use default route"
21
+ runner.errors[1].to_s.should == "config/routes.rb:5 - not use default route"
22
+ end
21
23
 
22
- it "should no not use default route" do
23
- content = <<-EOF
24
- ActionController::Routing::Routes.draw do |map|
25
- map.resources :posts, :member => { :push => :post }
24
+ it "should no not use default route" do
25
+ content = <<-EOF
26
+ ActionController::Routing::Routes.draw do |map|
27
+ map.resources :posts, :member => { :push => :post }
28
+ end
29
+ EOF
30
+ runner.review('config/routes.rb', content)
31
+ runner.should have(0).errors
32
+ end
26
33
  end
27
- EOF
28
- runner.review('config/routes.rb', content)
29
- runner.should have(0).errors
30
- end
31
- end
32
34
 
33
- describe "rails3" do
34
- it "should not use default route" do
35
- content = <<-EOF
36
- RailsBestpracticesCom::Application.routes.draw do |map|
37
- resources :posts
35
+ describe "rails3" do
36
+ it "should not use default route" do
37
+ content = <<-EOF
38
+ RailsBestpracticesCom::Application.routes.draw do |map|
39
+ resources :posts
38
40
 
39
- match ':controller(/:action(/:id(.:format)))'
40
- end
41
- EOF
42
- runner.review('config/routes.rb', content)
43
- runner.should have(1).errors
44
- runner.errors[0].to_s.should == "config/routes.rb:4 - not use default route"
45
- end
41
+ match ':controller(/:action(/:id(.:format)))'
42
+ end
43
+ EOF
44
+ runner.review('config/routes.rb', content)
45
+ runner.should have(1).errors
46
+ runner.errors[0].to_s.should == "config/routes.rb:4 - not use default route"
47
+ end
46
48
 
47
- it "should no not use default route" do
48
- content = <<-EOF
49
- RailsBestpracticesCom::Application.routes.draw do |map|
50
- resources :posts
49
+ it "should no not use default route" do
50
+ content = <<-EOF
51
+ RailsBestpracticesCom::Application.routes.draw do |map|
52
+ resources :posts
53
+ end
54
+ EOF
55
+ runner.review('config/routes.rb', content)
56
+ runner.should have(0).errors
57
+ end
51
58
  end
52
- EOF
53
- runner.review('config/routes.rb', content)
54
- runner.should have(0).errors
55
59
  end
56
60
  end
57
61
  end
@@ -1,49 +1,53 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Reviews::NotUseTimeAgoInWordsReview do
4
- let(:runner) { RailsBestPractices::Core::Runner.new(:reviews => RailsBestPractices::Reviews::NotUseTimeAgoInWordsReview.new) }
3
+ module RailsBestPractices
4
+ module Reviews
5
+ describe NotUseTimeAgoInWordsReview do
6
+ let(:runner) { Core::Runner.new(:reviews => NotUseTimeAgoInWordsReview.new) }
5
7
 
6
- describe "time_ago_in_words" do
7
- it "should not use in views" do
8
- content =<<-EOF
9
- <%= time_ago_in_words(post.created_at) %>
10
- EOF
11
- runner.review('app/views/posts/show.html.erb', content)
12
- runner.should have(1).errors
13
- runner.errors[0].to_s.should == "app/views/posts/show.html.erb:1 - not use time_ago_in_words"
14
- end
8
+ describe "time_ago_in_words" do
9
+ it "should not use in views" do
10
+ content =<<-EOF
11
+ <%= time_ago_in_words(post.created_at) %>
12
+ EOF
13
+ runner.review('app/views/posts/show.html.erb', content)
14
+ runner.should have(1).errors
15
+ runner.errors[0].to_s.should == "app/views/posts/show.html.erb:1 - not use time_ago_in_words"
16
+ end
15
17
 
16
- it "should not use in helpers" do
17
- content =<<-EOF
18
- def timeago
19
- content_tag(:p, time_ago_in_words(post.created_at))
18
+ it "should not use in helpers" do
19
+ content =<<-EOF
20
+ def timeago
21
+ content_tag(:p, time_ago_in_words(post.created_at))
22
+ end
23
+ EOF
24
+ runner.review('app/helpers/posts_helper.rb', content)
25
+ runner.should have(1).errors
26
+ runner.errors[0].to_s.should == "app/helpers/posts_helper.rb:2 - not use time_ago_in_words"
27
+ end
20
28
  end
21
- EOF
22
- runner.review('app/helpers/posts_helper.rb', content)
23
- runner.should have(1).errors
24
- runner.errors[0].to_s.should == "app/helpers/posts_helper.rb:2 - not use time_ago_in_words"
25
- end
26
- end
27
29
 
28
- describe "distance_of_time_in_words_to_now" do
29
- it "should not use in views" do
30
- content =<<-EOF
31
- <%= distance_of_time_in_words_to_now(post.created_at) %>
32
- EOF
33
- runner.review('app/views/posts/show.html.erb', content)
34
- runner.should have(1).errors
35
- runner.errors[0].to_s.should == "app/views/posts/show.html.erb:1 - not use time_ago_in_words"
36
- end
30
+ describe "distance_of_time_in_words_to_now" do
31
+ it "should not use in views" do
32
+ content =<<-EOF
33
+ <%= distance_of_time_in_words_to_now(post.created_at) %>
34
+ EOF
35
+ runner.review('app/views/posts/show.html.erb', content)
36
+ runner.should have(1).errors
37
+ runner.errors[0].to_s.should == "app/views/posts/show.html.erb:1 - not use time_ago_in_words"
38
+ end
37
39
 
38
- it "should not use in helpers" do
39
- content =<<-EOF
40
- def timeago
41
- content_tag(:p, distance_of_time_in_words_to_now(post.created_at))
40
+ it "should not use in helpers" do
41
+ content =<<-EOF
42
+ def timeago
43
+ content_tag(:p, distance_of_time_in_words_to_now(post.created_at))
44
+ end
45
+ EOF
46
+ runner.review('app/helpers/posts_helper.rb', content)
47
+ runner.should have(1).errors
48
+ runner.errors[0].to_s.should == "app/helpers/posts_helper.rb:2 - not use time_ago_in_words"
49
+ end
42
50
  end
43
- EOF
44
- runner.review('app/helpers/posts_helper.rb', content)
45
- runner.should have(1).errors
46
- runner.errors[0].to_s.should == "app/helpers/posts_helper.rb:2 - not use time_ago_in_words"
47
51
  end
48
52
  end
49
53
  end