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
@@ -19,16 +19,24 @@ module RailsBestPractices
|
|
19
19
|
"http://rails-bestpractices.com/posts/148-protect-mass-assignment"
|
20
20
|
end
|
21
21
|
|
22
|
-
# check class node, grep all command nodes,
|
22
|
+
# check class node, grep all command nodes,
|
23
|
+
# if config.active_record.whitelist_attributes is not set true,
|
24
|
+
# and if none of them is with message attr_accessible or attr_protected,
|
25
|
+
# and if not use devise or authlogic,
|
23
26
|
# then it should add attr_accessible or attr_protected to protect mass assignment.
|
24
27
|
def start_class(node)
|
25
|
-
if !rails_builtin?(node) && !devise?(node) && !authlogic?(node)
|
28
|
+
if !whitelist_attributes_config? && !rails_builtin?(node) && !devise?(node) && !authlogic?(node)
|
26
29
|
add_error "protect mass assignment"
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
30
33
|
private
|
34
|
+
def whitelist_attributes_config?
|
35
|
+
Prepares.configs["config.active_record.whitelist_attributes"] == "true"
|
36
|
+
end
|
37
|
+
|
31
38
|
def rails_builtin?(node)
|
39
|
+
node.grep_node(:sexp_type => [:vcall, :var_ref], :to_s => "attr_accessible").present? ||
|
32
40
|
node.grep_node(:sexp_type => :command, :message => %w(attr_accessible attr_protected)).present?
|
33
41
|
end
|
34
42
|
|
@@ -37,7 +45,7 @@ module RailsBestPractices
|
|
37
45
|
end
|
38
46
|
|
39
47
|
def authlogic?(node)
|
40
|
-
node.grep_node(:sexp_type => :vcall, :to_s => "acts_as_authentic").present? ||
|
48
|
+
node.grep_node(:sexp_type => [:vcall, :var_ref], :to_s => "acts_as_authentic").present? ||
|
41
49
|
node.grep_node(:sexp_type => :fcall, :message => "acts_as_authentic").present?
|
42
50
|
end
|
43
51
|
end
|
@@ -94,9 +94,13 @@ module RailsBestPractices
|
|
94
94
|
|
95
95
|
def internal_except_methods
|
96
96
|
%w(
|
97
|
-
initialize
|
98
|
-
|
99
|
-
|
97
|
+
initialize
|
98
|
+
validate validate_each validate_on_create validate_on_update
|
99
|
+
human_attribute_name
|
100
|
+
assign_attributes
|
101
|
+
to_xml to_json to_param
|
102
|
+
before_save before_create before_update before_destroy after_save after_create after_update after_destroy after_find after_initialize
|
103
|
+
method_missing
|
100
104
|
).map { |method_name| "*\##{method_name}" }
|
101
105
|
end
|
102
106
|
end
|
@@ -1,45 +1,65 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module RailsBestPractices
|
4
|
+
describe Analyzer do
|
5
|
+
subject { Analyzer.new(".") }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
describe "expand_dirs_to_files" do
|
8
|
+
it "should expand all files in spec directory" do
|
9
|
+
dir = File.dirname(__FILE__)
|
10
|
+
subject.expand_dirs_to_files(dir).should be_include(dir + '/analyzer_spec.rb')
|
11
|
+
end
|
10
12
|
end
|
11
|
-
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
describe "file_sort" do
|
15
|
+
it "should get models first, mailers, helpers and then others" do
|
16
|
+
files = ["app/controllers/users_controller.rb", "app/mailers/user_mailer.rb", "app/helpers/users_helper.rb", "app/models/user.rb", "app/views/users/index.html.haml", "app/views/users/show.html.slim", "lib/user.rb"]
|
17
|
+
subject.file_sort(files).should == ["app/models/user.rb", "app/mailers/user_mailer.rb", "app/helpers/users_helper.rb", "app/controllers/users_controller.rb", "app/views/users/index.html.haml", "app/views/users/show.html.slim", "lib/user.rb"]
|
18
|
+
end
|
17
19
|
end
|
18
|
-
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
describe "file_ignore" do
|
22
|
+
it "should ignore lib" do
|
23
|
+
files = ["app/controllers/users_controller.rb", "app/mailers/user_mailer.rb", "app/models/user.rb", "app/views/users/index.html.haml", "app/views/users/show.html.slim", "lib/user.rb"]
|
24
|
+
subject.file_ignore(files, 'lib/').should == ["app/controllers/users_controller.rb", "app/mailers/user_mailer.rb", "app/models/user.rb", "app/views/users/index.html.haml", "app/views/users/show.html.slim"]
|
25
|
+
end
|
24
26
|
end
|
25
|
-
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
describe "output_terminal_errors" do
|
29
|
+
it "should output errors in terminal" do
|
30
|
+
check1 = Reviews::LawOfDemeterReview.new
|
31
|
+
check2 = Reviews::UseQueryAttributeReview.new
|
32
|
+
runner = Core::Runner.new(:reviews => [check1, check2])
|
33
|
+
check1.add_error "law of demeter", "app/models/user.rb", 10
|
34
|
+
check2.add_error "use query attribute", "app/models/post.rb", 100
|
35
|
+
subject.runner = runner
|
36
|
+
subject.instance_variable_set("@options", {"without-color" => false})
|
37
|
+
|
38
|
+
$origin_stdout = $stdout
|
39
|
+
$stdout = StringIO.new
|
40
|
+
subject.output_terminal_errors
|
41
|
+
result = $stdout.string
|
42
|
+
$stdout = $origin_stdout
|
43
|
+
result.should == ["app/models/user.rb:10 - law of demeter".red, "app/models/post.rb:100 - use query attribute".red, "\nPlease go to http://rails-bestpractices.com to see more useful Rails Best Practices.".green, "\nFound 2 warnings.".red].join("\n") + "\n"
|
44
|
+
end
|
45
|
+
end
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
47
|
+
describe "errors_filter_block" do
|
48
|
+
it "should call errors_filter_block after analyze" do
|
49
|
+
analyzer = Analyzer.new("path", "silent" => true)
|
50
|
+
analyzer.errors_filter_block = lambda { |errors| errors.each { |error| error.highlight = true } }
|
51
|
+
analyzer.stub(:expand_dirs_to_files).and_return([])
|
52
|
+
analyzer.stub(:file_sort).and_return([])
|
53
|
+
analyzer.stub(:file_ignore).and_return([])
|
54
|
+
analyzer.stub(:process)
|
55
|
+
runner = stub
|
56
|
+
runner.stub(:color=)
|
57
|
+
errors = [Core::Error.new, Core::Error.new]
|
58
|
+
Core::Runner.stub(:new).and_return(runner)
|
59
|
+
runner.stub(:errors).and_return(errors)
|
60
|
+
analyzer.analyze
|
61
|
+
analyzer.send(:errors).should be_all(&:highlight)
|
62
|
+
end
|
43
63
|
end
|
44
64
|
end
|
45
65
|
end
|
@@ -1,63 +1,82 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module RailsBestPractices::Core
|
4
|
+
describe Check do
|
5
|
+
let(:check) { Check.new }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should match none of interesting files" do
|
11
|
-
check.interesting_files.should == []
|
12
|
-
end
|
13
|
-
|
14
|
-
context "node_start" do
|
15
|
-
it "should call start_if" do
|
16
|
-
node = stub(:sexp_type => :if)
|
17
|
-
check.should_receive(:send).with("start_if", node)
|
18
|
-
check.node_start(node)
|
7
|
+
it "should get empty interesting nodes" do
|
8
|
+
check.interesting_nodes.should == []
|
19
9
|
end
|
20
10
|
|
21
|
-
it "should
|
22
|
-
|
23
|
-
check.should_receive(:send).with("start_call", node)
|
24
|
-
check.node_start(node)
|
11
|
+
it "should match none of interesting files" do
|
12
|
+
check.interesting_files.should == []
|
25
13
|
end
|
26
|
-
end
|
27
14
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
15
|
+
context "node_start" do
|
16
|
+
it "should call start_if" do
|
17
|
+
node = stub(:sexp_type => :if)
|
18
|
+
check.should_receive(:send).with("start_if", node)
|
19
|
+
check.node_start(node)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should call start_call" do
|
23
|
+
node = stub(:sexp_type => :call)
|
24
|
+
check.should_receive(:send).with("start_call", node)
|
25
|
+
check.node_start(node)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should print node if debug mode" do
|
29
|
+
node = stub(:sexp_type => :call)
|
30
|
+
Check.class_eval { debug }
|
31
|
+
check.should_receive(:send).with("start_call", node)
|
32
|
+
check.should_receive(:ap).with(node)
|
33
|
+
check.node_start(node)
|
34
|
+
Check.class_eval { @debug = false }
|
35
|
+
end
|
33
36
|
end
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
context "node_end" do
|
39
|
+
it "should call end_if" do
|
40
|
+
node = stub(:sexp_type => :if)
|
41
|
+
check.should_receive(:send).with("end_if", node)
|
42
|
+
check.node_end(node)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should call end_call" do
|
46
|
+
node = stub(:sexp_type => :call)
|
47
|
+
check.should_receive(:send).with("end_call", node)
|
48
|
+
check.node_end(node)
|
49
|
+
end
|
39
50
|
end
|
40
|
-
end
|
41
51
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
52
|
+
context "callback" do
|
53
|
+
it "should add callback to start_call" do
|
54
|
+
execute = false
|
55
|
+
check.class.add_callback "start_call" do
|
56
|
+
execute = true
|
57
|
+
end
|
58
|
+
node = stub(:sexp_type => :call)
|
59
|
+
check.node_start(node)
|
60
|
+
execute.should be_true
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should ad callbacks to end_call" do
|
64
|
+
execute = false
|
65
|
+
check.class.add_callback "end_call" do
|
66
|
+
execute = true
|
67
|
+
end
|
68
|
+
node = stub(:sexp_type => :call)
|
69
|
+
check.node_end(node)
|
70
|
+
execute.should be_true
|
47
71
|
end
|
48
|
-
node = stub(:sexp_type => :call)
|
49
|
-
check.node_start(node)
|
50
|
-
execute.should be_true
|
51
72
|
end
|
52
73
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
74
|
+
context "debug" do
|
75
|
+
it "should be debug mode" do
|
76
|
+
Check.debug
|
77
|
+
Check.should be_debug
|
78
|
+
Check.class_eval { @debug = false }
|
57
79
|
end
|
58
|
-
node = stub(:sexp_type => :call)
|
59
|
-
check.node_end(node)
|
60
|
-
execute.should be_true
|
61
80
|
end
|
62
81
|
end
|
63
82
|
end
|
@@ -1,78 +1,79 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
|
5
|
-
end
|
6
|
-
class TestLexical2
|
7
|
-
end
|
8
|
-
class TestPrepare1 < RailsBestPractices::Core::Check
|
9
|
-
interesting_nodes :call
|
10
|
-
interesting_files MODEL_FILES
|
11
|
-
end
|
12
|
-
|
13
|
-
class TestPrepare2 < RailsBestPractices::Core::Check
|
14
|
-
interesting_nodes :class
|
15
|
-
interesting_files MAILER_FILES
|
16
|
-
end
|
17
|
-
|
18
|
-
class TestReview1 < RailsBestPractices::Core::Check
|
19
|
-
interesting_nodes :defn
|
20
|
-
interesting_files CONTROLLER_FILES
|
21
|
-
end
|
4
|
+
module RailsBestPractices::Core
|
22
5
|
|
23
|
-
class
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
describe RailsBestPractices::Core::CheckingVisitor do
|
29
|
-
let(:lexical1) { TestLexical1.new }
|
30
|
-
let(:lexical2) { TestLexical2.new }
|
31
|
-
let(:prepare1) { TestPrepare1.new }
|
32
|
-
let(:prepare2) { TestPrepare2.new }
|
33
|
-
let(:review1) { TestReview1.new }
|
34
|
-
let(:review2) { TestReview2.new }
|
35
|
-
let(:visitor) {
|
36
|
-
RailsBestPractices::Core::CheckingVisitor.new(
|
37
|
-
:lexicals => [lexical1, lexical2],
|
38
|
-
:prepares => [prepare1, prepare2],
|
39
|
-
:reviews => [review1, review2]
|
40
|
-
)
|
41
|
-
}
|
42
|
-
|
43
|
-
it "should lexical check" do
|
44
|
-
filename = "app/models/user.rb"
|
45
|
-
content = "class User; end"
|
46
|
-
lexical1.should_receive(:check).with(filename, content)
|
47
|
-
lexical2.should_receive(:check).with(filename, content)
|
48
|
-
visitor.lexical(filename, content)
|
6
|
+
class TestLexical1; end
|
7
|
+
class TestLexical2; end
|
8
|
+
class TestPrepare1 < Check
|
9
|
+
interesting_nodes :call
|
10
|
+
interesting_files MODEL_FILES
|
49
11
|
end
|
50
12
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
prepare1.should_receive(:node_end).with(node)
|
55
|
-
visitor.prepare(node)
|
13
|
+
class TestPrepare2 < Check
|
14
|
+
interesting_nodes :class
|
15
|
+
interesting_files MAILER_FILES
|
56
16
|
end
|
57
17
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
prepare2.should_receive(:node_end).with(node)
|
62
|
-
visitor.prepare(node)
|
18
|
+
class TestReview1 < Check
|
19
|
+
interesting_nodes :defn
|
20
|
+
interesting_files CONTROLLER_FILES
|
63
21
|
end
|
64
22
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
review1.should_receive(:node_end).with(node)
|
69
|
-
visitor.review(node)
|
23
|
+
class TestReview2 < Check
|
24
|
+
interesting_nodes :call
|
25
|
+
interesting_files VIEW_FILES
|
70
26
|
end
|
71
27
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
28
|
+
describe CheckingVisitor do
|
29
|
+
let(:lexical1) { TestLexical1.new }
|
30
|
+
let(:lexical2) { TestLexical2.new }
|
31
|
+
let(:prepare1) { TestPrepare1.new }
|
32
|
+
let(:prepare2) { TestPrepare2.new }
|
33
|
+
let(:review1) { TestReview1.new }
|
34
|
+
let(:review2) { TestReview2.new }
|
35
|
+
let(:visitor) {
|
36
|
+
CheckingVisitor.new(
|
37
|
+
:lexicals => [lexical1, lexical2],
|
38
|
+
:prepares => [prepare1, prepare2],
|
39
|
+
:reviews => [review1, review2]
|
40
|
+
)
|
41
|
+
}
|
42
|
+
|
43
|
+
it "should lexical check" do
|
44
|
+
filename = "app/models/user.rb"
|
45
|
+
content = "class User; end"
|
46
|
+
lexical1.should_receive(:check).with(filename, content)
|
47
|
+
lexical2.should_receive(:check).with(filename, content)
|
48
|
+
visitor.lexical(filename, content)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should prepare model associations" do
|
52
|
+
node = stub(:sexp_type => :call, :children => [], :file => "app/models/user.rb")
|
53
|
+
prepare1.should_receive(:node_start).with(node)
|
54
|
+
prepare1.should_receive(:node_end).with(node)
|
55
|
+
visitor.prepare(node)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should prepare mailer names" do
|
59
|
+
node = stub(:sexp_type => :class, :children => [], :file => "app/mailers/user_mailer.rb")
|
60
|
+
prepare2.should_receive(:node_start).with(node)
|
61
|
+
prepare2.should_receive(:node_end).with(node)
|
62
|
+
visitor.prepare(node)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should review controller method definitions" do
|
66
|
+
node = stub(:sexp_type => :defn, :children => [], :file => "app/controllers/users_controller.rb")
|
67
|
+
review1.should_receive(:node_start).with(node)
|
68
|
+
review1.should_receive(:node_end).with(node)
|
69
|
+
visitor.review(node)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should review view calls" do
|
73
|
+
node = stub(:sexp_type => :call, :children => [], :file => "app/views/users/new.html.erb")
|
74
|
+
review2.should_receive(:node_start).with(node)
|
75
|
+
review2.should_receive(:node_end).with(node)
|
76
|
+
visitor.review(node)
|
77
|
+
end
|
77
78
|
end
|
78
79
|
end
|