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.
- data/.travis.yml +4 -1
- data/Gemfile +0 -3
- data/Gemfile.lock +10 -9
- data/README.md +2 -0
- data/lib/rails_best_practices/analyzer.rb +40 -21
- data/lib/rails_best_practices/core.rb +1 -0
- data/lib/rails_best_practices/core/check.rb +12 -0
- data/lib/rails_best_practices/core/configs.rb +7 -0
- data/lib/rails_best_practices/core/error.rb +2 -1
- data/lib/rails_best_practices/core/routes.rb +11 -5
- data/lib/rails_best_practices/core/runner.rb +6 -2
- data/lib/rails_best_practices/core_ext/sexp.rb +3 -1
- data/lib/rails_best_practices/prepares.rb +5 -0
- data/lib/rails_best_practices/prepares/config_prepare.rb +21 -0
- data/lib/rails_best_practices/prepares/route_prepare.rb +24 -7
- data/lib/rails_best_practices/reviews/protect_mass_assignment_review.rb +11 -3
- data/lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb +7 -3
- data/lib/rails_best_practices/version.rb +1 -1
- data/rails_best_practices.gemspec +1 -0
- data/spec/rails_best_practices/analyzer_spec.rb +52 -32
- data/spec/rails_best_practices/core/check_spec.rb +64 -45
- data/spec/rails_best_practices/core/checking_visitor_spec.rb +65 -64
- data/spec/rails_best_practices/core/configs_spec.rb +7 -0
- data/spec/rails_best_practices/core/controllers_spec.rb +4 -2
- data/spec/rails_best_practices/core/error_spec.rb +28 -22
- data/spec/rails_best_practices/core/helpers_spec.rb +4 -2
- data/spec/rails_best_practices/core/klasses_spec.rb +8 -6
- data/spec/rails_best_practices/core/mailers_spec.rb +4 -2
- data/spec/rails_best_practices/core/methods_spec.rb +37 -35
- data/spec/rails_best_practices/core/model_associations_spec.rb +17 -15
- data/spec/rails_best_practices/core/model_attributes_spec.rb +17 -15
- data/spec/rails_best_practices/core/models_spec.rb +4 -2
- data/spec/rails_best_practices/core/modules_spec.rb +21 -19
- data/spec/rails_best_practices/core/nil_spec.rb +23 -21
- data/spec/rails_best_practices/core/routes_spec.rb +21 -14
- data/spec/rails_best_practices/core/runner_spec.rb +17 -15
- data/spec/rails_best_practices/core_ext/sexp_spec.rb +32 -7
- data/spec/rails_best_practices/lexicals/remove_tab_check_spec.rb +35 -31
- data/spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb +35 -31
- data/spec/rails_best_practices/prepares/config_prepare_spec.rb +24 -0
- data/spec/rails_best_practices/prepares/controller_prepare_spec.rb +122 -123
- data/spec/rails_best_practices/prepares/helper_prepare_spec.rb +36 -32
- data/spec/rails_best_practices/prepares/mailer_prepare_spec.rb +12 -8
- data/spec/rails_best_practices/prepares/model_prepare_spec.rb +326 -322
- data/spec/rails_best_practices/prepares/route_prepare_spec.rb +619 -573
- data/spec/rails_best_practices/prepares/schema_prepare_spec.rb +25 -21
- data/spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb +85 -87
- data/spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb +224 -222
- data/spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb +30 -26
- data/spec/rails_best_practices/reviews/isolate_seed_data_review_spec.rb +79 -75
- data/spec/rails_best_practices/reviews/keep_finders_on_their_own_model_review_spec.rb +76 -72
- data/spec/rails_best_practices/reviews/law_of_demeter_review_spec.rb +138 -140
- data/spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb +38 -34
- data/spec/rails_best_practices/reviews/move_code_into_helper_review_spec.rb +22 -18
- data/spec/rails_best_practices/reviews/move_code_into_model_review_spec.rb +57 -53
- data/spec/rails_best_practices/reviews/move_finder_to_named_scope_review_spec.rb +62 -63
- data/spec/rails_best_practices/reviews/move_model_logic_into_model_review_spec.rb +51 -50
- data/spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb +140 -136
- data/spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb +48 -44
- data/spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb +42 -38
- data/spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb +151 -149
- data/spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb +86 -55
- data/spec/rails_best_practices/reviews/remove_empty_helpers_review_spec.rb +23 -19
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb +290 -286
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_helpers_review_spec.rb +76 -72
- data/spec/rails_best_practices/reviews/remove_unused_methods_in_models_review_spec.rb +601 -597
- data/spec/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review_spec.rb +55 -54
- data/spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb +34 -30
- data/spec/rails_best_practices/reviews/restrict_auto_generated_routes_review_spec.rb +288 -289
- data/spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb +59 -55
- data/spec/rails_best_practices/reviews/simplify_render_in_views_review_spec.rb +73 -69
- data/spec/rails_best_practices/reviews/use_before_filter_review_spec.rb +89 -98
- data/spec/rails_best_practices/reviews/use_model_association_review_spec.rb +52 -52
- data/spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb +192 -190
- data/spec/rails_best_practices/reviews/use_observer_review_spec.rb +114 -121
- data/spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb +189 -190
- data/spec/rails_best_practices/reviews/use_say_with_time_in_migrations_review_spec.rb +97 -93
- data/spec/rails_best_practices/reviews/use_scope_access_review_spec.rb +146 -151
- data/spec/spec_helper.rb +11 -20
- metadata +42 -26
- data/.watchr.example +0 -65
@@ -1,167 +1,171 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module RailsBestPractices
|
4
|
+
module Reviews
|
5
|
+
describe NeedlessDeepNestingReview do
|
6
|
+
let(:runner) { Core::Runner.new(:reviews => NeedlessDeepNestingReview.new) }
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
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
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
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
|
-
|
160
|
-
|
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
|
-
|
4
|
-
|
3
|
+
module RailsBestPractices
|
4
|
+
module Reviews
|
5
|
+
describe NotUseDefaultRouteReview do
|
6
|
+
let(:runner) { Core::Runner.new(:reviews => NotUseDefaultRouteReview.new) }
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
4
|
-
|
3
|
+
module RailsBestPractices
|
4
|
+
module Reviews
|
5
|
+
describe NotUseTimeAgoInWordsReview do
|
6
|
+
let(:runner) { Core::Runner.new(:reviews => NotUseTimeAgoInWordsReview.new) }
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|