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,28 +1,34 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::Error do
4
- it "should return error with filename, line number and message" do
5
- RailsBestPractices::Core::Error.new(
6
- :filename => "app/models/user.rb",
7
- :line_number => "100",
8
- :message => "not good",
9
- :type => "BogusReview").to_s.should == "app/models/user.rb:100 - not good"
10
- end
3
+ module RailsBestPractices::Core
4
+ describe Error do
5
+ it "should have highlight with false by default" do
6
+ Error.new.highlight.should == false
7
+ end
11
8
 
12
- it "should return short filename" do
13
- RailsBestPractices::Core::Runner.base_path = "../rails-bestpractices.com"
14
- RailsBestPractices::Core::Error.new(
15
- :filename => "../rails-bestpractices.com/app/models/user.rb",
16
- :line_number => "100",
17
- :message => "not good",
18
- :type => "BogusReview").short_filename.should == "app/models/user.rb"
19
- end
9
+ it "should return error with filename, line number and message" do
10
+ Error.new(
11
+ :filename => "app/models/user.rb",
12
+ :line_number => "100",
13
+ :message => "not good",
14
+ :type => "BogusReview").to_s.should == "app/models/user.rb:100 - not good"
15
+ end
16
+
17
+ it "should return short filename" do
18
+ Runner.base_path = "../rails-bestpractices.com"
19
+ Error.new(
20
+ :filename => "../rails-bestpractices.com/app/models/user.rb",
21
+ :line_number => "100",
22
+ :message => "not good",
23
+ :type => "BogusReview").short_filename.should == "app/models/user.rb"
24
+ end
20
25
 
21
- it "should return first line number" do
22
- RailsBestPractices::Core::Error.new(
23
- :filename => "app/models/user.rb",
24
- :line_number => "50,70,100",
25
- :message => "not good",
26
- :type => "BogusReview").first_line_number.should == "50"
26
+ it "should return first line number" do
27
+ Error.new(
28
+ :filename => "app/models/user.rb",
29
+ :line_number => "50,70,100",
30
+ :message => "not good",
31
+ :type => "BogusReview").first_line_number.should == "50"
32
+ end
27
33
  end
28
34
  end
@@ -1,5 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::Helpers do
4
- it { should be_a_kind_of RailsBestPractices::Core::Modules }
3
+ module RailsBestPractices::Core
4
+ describe Helpers do
5
+ it { should be_a_kind_of Modules }
6
+ end
5
7
  end
@@ -1,12 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::Klasses do
4
- it { should be_a_kind_of Array }
3
+ module RailsBestPractices::Core
4
+ describe Klasses do
5
+ it { should be_a_kind_of Array }
5
6
 
6
- context "Klass" do
7
- it "should get to_s" do
8
- klass = RailsBestPractices::Core::Klass.new("BlogPost", "Post", ["Admin"])
9
- klass.to_s.should == "Admin::BlogPost"
7
+ context "Klass" do
8
+ it "should get to_s" do
9
+ klass = Klass.new("BlogPost", "Post", ["Admin"])
10
+ klass.to_s.should == "Admin::BlogPost"
11
+ end
10
12
  end
11
13
  end
12
14
  end
@@ -1,5 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::Mailers do
4
- it { should be_a_kind_of RailsBestPractices::Core::Klasses }
3
+ module RailsBestPractices::Core
4
+ describe Mailers do
5
+ it { should be_a_kind_of Klasses }
6
+ end
5
7
  end
@@ -1,44 +1,46 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::Methods do
4
- let(:methods) { RailsBestPractices::Core::Methods.new }
3
+ module RailsBestPractices::Core
4
+ describe Methods do
5
+ let(:methods) { Methods.new }
5
6
 
6
- before :each do
7
- methods.add_method("Post", "create")
8
- methods.add_method("Post", "destroy")
9
- methods.add_method("Post", "save_or_update", {}, "protected")
10
- methods.add_method("Post", "find_by_sql", {}, "private")
11
- methods.add_method("Comment", "create")
12
- end
7
+ before :each do
8
+ methods.add_method("Post", "create")
9
+ methods.add_method("Post", "destroy")
10
+ methods.add_method("Post", "save_or_update", {}, "protected")
11
+ methods.add_method("Post", "find_by_sql", {}, "private")
12
+ methods.add_method("Comment", "create")
13
+ end
13
14
 
14
- it "should get_methods" do
15
- methods.get_methods("Post").map(&:method_name).should == ["create", "destroy", "save_or_update", "find_by_sql"]
16
- methods.get_methods("Post", "public").map(&:method_name).should == ["create", "destroy"]
17
- methods.get_methods("Post", "protected").map(&:method_name).should == ["save_or_update"]
18
- methods.get_methods("Post", "private").map(&:method_name).should == ["find_by_sql"]
19
- methods.get_methods("Comment").map(&:method_name).should == ["create"]
20
- end
15
+ it "should get_methods" do
16
+ methods.get_methods("Post").map(&:method_name).should == ["create", "destroy", "save_or_update", "find_by_sql"]
17
+ methods.get_methods("Post", "public").map(&:method_name).should == ["create", "destroy"]
18
+ methods.get_methods("Post", "protected").map(&:method_name).should == ["save_or_update"]
19
+ methods.get_methods("Post", "private").map(&:method_name).should == ["find_by_sql"]
20
+ methods.get_methods("Comment").map(&:method_name).should == ["create"]
21
+ end
21
22
 
22
- it "should has_method?" do
23
- methods.should be_has_method("Post", "create", "public")
24
- methods.should be_has_method("Post", "destroy", "public")
25
- methods.should_not be_has_method("Post", "save_or_update", "public")
26
- methods.should be_has_method("Post", "save_or_update", "protected")
27
- methods.should_not be_has_method("Post", "find_by_sql", "public")
28
- methods.should be_has_method("Post", "find_by_sql", "private")
29
- methods.should_not be_has_method("Comment", "destroy")
30
- end
23
+ it "should has_method?" do
24
+ methods.should be_has_method("Post", "create", "public")
25
+ methods.should be_has_method("Post", "destroy", "public")
26
+ methods.should_not be_has_method("Post", "save_or_update", "public")
27
+ methods.should be_has_method("Post", "save_or_update", "protected")
28
+ methods.should_not be_has_method("Post", "find_by_sql", "public")
29
+ methods.should be_has_method("Post", "find_by_sql", "private")
30
+ methods.should_not be_has_method("Comment", "destroy")
31
+ end
31
32
 
32
- it "should get_method" do
33
- methods.get_method("Post", "create", "public").should_not be_nil
34
- methods.get_method("Post", "create", "protected").should be_nil
35
- end
33
+ it "should get_method" do
34
+ methods.get_method("Post", "create", "public").should_not be_nil
35
+ methods.get_method("Post", "create", "protected").should be_nil
36
+ end
36
37
 
37
- it "should get_all_unused_methods" do
38
- methods.get_method("Comment", "create").mark_used
39
- methods.get_all_unused_methods("public").map(&:method_name).should == ["create", "destroy"]
40
- methods.get_all_unused_methods("protected").map(&:method_name).should == ["save_or_update"]
41
- methods.get_all_unused_methods("private").map(&:method_name).should == ["find_by_sql"]
42
- methods.get_all_unused_methods.map(&:method_name).should == ["create", "destroy", "save_or_update", "find_by_sql"]
38
+ it "should get_all_unused_methods" do
39
+ methods.get_method("Comment", "create").mark_used
40
+ methods.get_all_unused_methods("public").map(&:method_name).should == ["create", "destroy"]
41
+ methods.get_all_unused_methods("protected").map(&:method_name).should == ["save_or_update"]
42
+ methods.get_all_unused_methods("private").map(&:method_name).should == ["find_by_sql"]
43
+ methods.get_all_unused_methods.map(&:method_name).should == ["create", "destroy", "save_or_update", "find_by_sql"]
44
+ end
43
45
  end
44
46
  end
@@ -1,22 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::ModelAssociations do
4
- let(:model_associations) { RailsBestPractices::Core::ModelAssociations.new }
3
+ module RailsBestPractices::Core
4
+ describe ModelAssociations do
5
+ let(:model_associations) { ModelAssociations.new }
5
6
 
6
- before :each do
7
- model_associations.add_association("Project", "project_manager", "belongs_to")
8
- model_associations.add_association("Project", "people", "has_many", "Person")
9
- end
7
+ before :each do
8
+ model_associations.add_association("Project", "project_manager", "belongs_to")
9
+ model_associations.add_association("Project", "people", "has_many", "Person")
10
+ end
10
11
 
11
- it "should get model associations" do
12
- model_associations.get_association("Project", "project_manager").should == {"meta" => "belongs_to", "class_name" => "ProjectManager"}
13
- model_associations.get_association("Project", "people").should == {"meta" => "has_many", "class_name" => "Person"}
14
- model_associations.get_association("Project", "unknown").should be_nil
15
- end
12
+ it "should get model associations" do
13
+ model_associations.get_association("Project", "project_manager").should == {"meta" => "belongs_to", "class_name" => "ProjectManager"}
14
+ model_associations.get_association("Project", "people").should == {"meta" => "has_many", "class_name" => "Person"}
15
+ model_associations.get_association("Project", "unknown").should be_nil
16
+ end
16
17
 
17
- it "should check is model associatiosn" do
18
- model_associations.is_association?("Project", "project_manager").should be_true
19
- model_associations.is_association?("Project", "people").should be_true
20
- model_associations.is_association?("Project", "unknown").should be_false
18
+ it "should check is model associatiosn" do
19
+ model_associations.is_association?("Project", "project_manager").should be_true
20
+ model_associations.is_association?("Project", "people").should be_true
21
+ model_associations.is_association?("Project", "unknown").should be_false
22
+ end
21
23
  end
22
24
  end
@@ -1,22 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::ModelAttributes do
4
- let(:model_attributes) { RailsBestPractices::Core::ModelAttributes.new }
3
+ module RailsBestPractices::Core
4
+ describe ModelAttributes do
5
+ let(:model_attributes) { ModelAttributes.new }
5
6
 
6
- before :each do
7
- model_attributes.add_attribute("Post", "title", :string)
8
- model_attributes.add_attribute("Post", "user_id", :integer)
9
- end
7
+ before :each do
8
+ model_attributes.add_attribute("Post", "title", :string)
9
+ model_attributes.add_attribute("Post", "user_id", :integer)
10
+ end
10
11
 
11
- it "should get model attributes" do
12
- model_attributes.get_attribute_type("Post", "title").should == :string
13
- model_attributes.get_attribute_type("Post", "user_id").should == :integer
14
- model_attributes.get_attribute_type("Post", "unknonw").should be_nil
15
- end
12
+ it "should get model attributes" do
13
+ model_attributes.get_attribute_type("Post", "title").should == :string
14
+ model_attributes.get_attribute_type("Post", "user_id").should == :integer
15
+ model_attributes.get_attribute_type("Post", "unknonw").should be_nil
16
+ end
16
17
 
17
- it "should check is model attributes" do
18
- model_attributes.is_attribute?("Post", "title").should be_true
19
- model_attributes.is_attribute?("Post", "user_id").should be_true
20
- model_attributes.is_attribute?("Post", "unknonw").should be_false
18
+ it "should check is model attributes" do
19
+ model_attributes.is_attribute?("Post", "title").should be_true
20
+ model_attributes.is_attribute?("Post", "user_id").should be_true
21
+ model_attributes.is_attribute?("Post", "unknonw").should be_false
22
+ end
21
23
  end
22
24
  end
@@ -1,5 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::Models do
4
- it { should be_a_kind_of RailsBestPractices::Core::Klasses }
3
+ module RailsBestPractices::Core
4
+ describe Models do
5
+ it { should be_a_kind_of Klasses }
6
+ end
5
7
  end
@@ -1,26 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::Modules do
4
- it { should be_a_kind_of Array }
3
+ module RailsBestPractices::Core
4
+ describe Modules do
5
+ it { should be_a_kind_of Array }
5
6
 
6
- context "Modules" do
7
- before do
8
- @mod = RailsBestPractices::Core::Mod.new("PostsHelper", [])
9
- end
10
- subject { RailsBestPractices::Core::Modules.new.tap { |modules| modules << @mod } }
11
- it "should add decendant to the corresponding module" do
12
- @mod.should_receive(:add_decendant).with("PostsController")
13
- subject.add_module_decendant("PostsHelper", "PostsController")
7
+ context "Modules" do
8
+ before do
9
+ @mod = Mod.new("PostsHelper", [])
10
+ end
11
+ subject { Modules.new.tap { |modules| modules << @mod } }
12
+ it "should add decendant to the corresponding module" do
13
+ @mod.should_receive(:add_decendant).with("PostsController")
14
+ subject.add_module_decendant("PostsHelper", "PostsController")
15
+ end
14
16
  end
15
- end
16
17
 
17
- context "Mod" do
18
- subject {
19
- RailsBestPractices::Core::Mod.new("UsersHelper", ["Admin"]).tap do |mod|
20
- mod.add_decendant("Admin::UsersController")
21
- end
22
- }
23
- its(:to_s) { should == "Admin::UsersHelper" }
24
- its(:decendants) { should == ["Admin::UsersController"] }
18
+ context "Mod" do
19
+ subject {
20
+ Mod.new("UsersHelper", ["Admin"]).tap do |mod|
21
+ mod.add_decendant("Admin::UsersController")
22
+ end
23
+ }
24
+ its(:to_s) { should == "Admin::UsersHelper" }
25
+ its(:decendants) { should == ["Admin::UsersController"] }
26
+ end
25
27
  end
26
28
  end
@@ -1,35 +1,37 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::Nil do
4
- let(:core_nil) { RailsBestPractices::Core::Nil.new }
3
+ module RailsBestPractices::Core
4
+ describe Nil do
5
+ let(:core_nil) { Nil.new }
5
6
 
6
- context "to_s" do
7
- it "should return self" do
8
- core_nil.to_s.should == core_nil
7
+ context "to_s" do
8
+ it "should return self" do
9
+ core_nil.to_s.should == core_nil
10
+ end
9
11
  end
10
- end
11
12
 
12
- context "hash_size" do
13
- it "should return 0" do
14
- core_nil.hash_size.should == 0
13
+ context "hash_size" do
14
+ it "should return 0" do
15
+ core_nil.hash_size.should == 0
16
+ end
15
17
  end
16
- end
17
18
 
18
- context "method_missing" do
19
- it "should return self" do
20
- core_nil.undefined.should == core_nil
19
+ context "method_missing" do
20
+ it "should return self" do
21
+ core_nil.undefined.should == core_nil
22
+ end
21
23
  end
22
- end
23
24
 
24
- context "present?" do
25
- it "should return false" do
26
- core_nil.should_not be_present
25
+ context "present?" do
26
+ it "should return false" do
27
+ core_nil.should_not be_present
28
+ end
27
29
  end
28
- end
29
30
 
30
- context "blank?" do
31
- it "should return true" do
32
- core_nil.should be_blank
31
+ context "blank?" do
32
+ it "should return true" do
33
+ core_nil.should be_blank
34
+ end
33
35
  end
34
36
  end
35
37
  end
@@ -1,22 +1,29 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::Routes do
4
- let(:routes) { RailsBestPractices::Core::Routes.new }
3
+ module RailsBestPractices::Core
4
+ describe Routes do
5
+ let(:routes) { Routes.new }
5
6
 
6
- it "should add route" do
7
- routes.add_route(["admin", "test"], "posts", "new")
8
- routes.map(&:to_s).should == ["Admin::Test::PostsController#new"]
9
- end
10
-
11
- context "route" do
12
- it "should add namesapces, controller name and action name" do
13
- route = RailsBestPractices::Core::Route.new(['admin', 'test'], 'posts', 'new')
14
- route.to_s.should == "Admin::Test::PostsController#new"
7
+ it "should add route" do
8
+ routes.add_route(["admin", "test"], "posts", "new")
9
+ routes.map(&:to_s).should == ["Admin::Test::PostsController#new"]
15
10
  end
16
11
 
17
- it "should add controller name with namespace" do
18
- route = RailsBestPractices::Core::Route.new(['admin'], 'test/posts', 'new')
19
- route.to_s.should == "Admin::Test::PostsController#new"
12
+ context "route" do
13
+ it "should add namesapces, controller name and action name" do
14
+ route = Route.new(['admin', 'test'], 'posts', 'new')
15
+ route.to_s.should == "Admin::Test::PostsController#new"
16
+ end
17
+
18
+ it "should add controller name with namespace" do
19
+ route = Route.new(['admin'], 'test/posts', 'new')
20
+ route.to_s.should == "Admin::Test::PostsController#new"
21
+ end
22
+
23
+ it "should add routes without controller" do
24
+ route = Route.new(['posts'], nil, 'new')
25
+ route.to_s.should == "PostsController#new"
26
+ end
20
27
  end
21
28
  end
22
29
  end
@@ -1,22 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RailsBestPractices::Core::Runner do
4
- describe "load_plugin_reviews" do
5
- shared_examples_for 'load_plugin_reviews' do
6
- it "should load plugins in lib/rails_best_practices/plugins/reviews" do
7
- runner = RailsBestPractices::Core::Runner.new
8
- runner.instance_variable_get('@reviews').map(&:class).should include(RailsBestPractices::Plugins::Reviews::NotUseRailsRootReview)
3
+ module RailsBestPractices::Core
4
+ describe Runner do
5
+ describe "load_plugin_reviews" do
6
+ shared_examples_for 'load_plugin_reviews' do
7
+ it "should load plugins in lib/rails_best_practices/plugins/reviews" do
8
+ runner = Runner.new
9
+ runner.instance_variable_get('@reviews').map(&:class).should include(RailsBestPractices::Plugins::Reviews::NotUseRailsRootReview)
10
+ end
9
11
  end
10
- end
11
12
 
12
- context "given a path that ends with a slash" do
13
- before { RailsBestPractices::Core::Runner.base_path = 'spec/fixtures/' }
14
- it_should_behave_like 'load_plugin_reviews'
15
- end
13
+ context "given a path that ends with a slash" do
14
+ before { Runner.base_path = 'spec/fixtures/' }
15
+ it_should_behave_like 'load_plugin_reviews'
16
+ end
16
17
 
17
- context "given a path that does not end with a slash" do
18
- before { RailsBestPractices::Core::Runner.base_path = 'spec/fixtures' }
19
- it_should_behave_like 'load_plugin_reviews'
18
+ context "given a path that does not end with a slash" do
19
+ before { Runner.base_path = 'spec/fixtures' }
20
+ it_should_behave_like 'load_plugin_reviews'
21
+ end
20
22
  end
21
23
  end
22
- end
24
+ end