rails_best_practices 1.14.4 → 1.15.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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +1 -0
  4. data/README.md +26 -6
  5. data/lib/rails_best_practices/core/check.rb +15 -2
  6. data/lib/rails_best_practices/core/klasses.rb +13 -3
  7. data/lib/rails_best_practices/core/model_associations.rb +1 -1
  8. data/lib/rails_best_practices/core/runner.rb +2 -0
  9. data/lib/rails_best_practices/lexicals/long_line_check.rb +1 -1
  10. data/lib/rails_best_practices/prepares/route_prepare.rb +17 -1
  11. data/lib/rails_best_practices/reviews/always_add_db_index_review.rb +2 -2
  12. data/lib/rails_best_practices/reviews/isolate_seed_data_review.rb +2 -2
  13. data/lib/rails_best_practices/reviews/keep_finders_on_their_own_model_review.rb +1 -1
  14. data/lib/rails_best_practices/reviews/move_code_into_helper_review.rb +1 -1
  15. data/lib/rails_best_practices/reviews/move_code_into_model_review.rb +1 -1
  16. data/lib/rails_best_practices/reviews/move_model_logic_into_model_review.rb +1 -1
  17. data/lib/rails_best_practices/reviews/needless_deep_nesting_review.rb +1 -1
  18. data/lib/rails_best_practices/reviews/overuse_route_customizations_review.rb +1 -1
  19. data/lib/rails_best_practices/reviews/remove_unused_methods_in_models_review.rb +1 -2
  20. data/lib/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review.rb +1 -1
  21. data/lib/rails_best_practices/reviews/restrict_auto_generated_routes_review.rb +2 -1
  22. data/lib/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review.rb +15 -26
  23. data/lib/rails_best_practices/reviews/use_turbo_sprockets_rails3_review.rb +4 -2
  24. data/lib/rails_best_practices/version.rb +1 -1
  25. data/spec/rails_best_practices/analyzer_spec.rb +11 -11
  26. data/spec/rails_best_practices/core/check_spec.rb +1 -1
  27. data/spec/rails_best_practices/core/error_spec.rb +6 -6
  28. data/spec/rails_best_practices/core/klasses_spec.rb +26 -2
  29. data/spec/rails_best_practices/core/methods_spec.rb +18 -18
  30. data/spec/rails_best_practices/core/model_associations_spec.rb +6 -6
  31. data/spec/rails_best_practices/core/model_attributes_spec.rb +6 -6
  32. data/spec/rails_best_practices/core/modules_spec.rb +3 -3
  33. data/spec/rails_best_practices/core/routes_spec.rb +4 -4
  34. data/spec/rails_best_practices/core/runner_spec.rb +1 -1
  35. data/spec/rails_best_practices/lexicals/long_line_check_spec.rb +18 -6
  36. data/spec/rails_best_practices/lexicals/remove_tab_check_spec.rb +18 -5
  37. data/spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb +17 -5
  38. data/spec/rails_best_practices/prepares/config_prepare_spec.rb +1 -1
  39. data/spec/rails_best_practices/prepares/controller_prepare_spec.rb +13 -13
  40. data/spec/rails_best_practices/prepares/gemfile_prepare_spec.rb +1 -1
  41. data/spec/rails_best_practices/prepares/helper_prepare_spec.rb +2 -2
  42. data/spec/rails_best_practices/prepares/initializer_prepare_spec.rb +2 -2
  43. data/spec/rails_best_practices/prepares/mailer_prepare_spec.rb +1 -1
  44. data/spec/rails_best_practices/prepares/model_prepare_spec.rb +44 -44
  45. data/spec/rails_best_practices/prepares/route_prepare_spec.rb +102 -78
  46. data/spec/rails_best_practices/prepares/schema_prepare_spec.rb +6 -6
  47. data/spec/rails_best_practices/reviews/add_model_virtual_attribute_review_spec.rb +25 -9
  48. data/spec/rails_best_practices/reviews/always_add_db_index_review_spec.rb +43 -23
  49. data/spec/rails_best_practices/reviews/check_save_return_value_spec.rb +34 -20
  50. data/spec/rails_best_practices/reviews/default_scope_is_evil_review_spec.rb +16 -5
  51. data/spec/rails_best_practices/reviews/dry_bundler_in_capistrano_review_spec.rb +25 -3
  52. data/spec/rails_best_practices/reviews/hash_syntax_review_spec.rb +18 -7
  53. data/spec/rails_best_practices/reviews/isolate_seed_data_review_spec.rb +30 -7
  54. data/spec/rails_best_practices/reviews/keep_finders_on_their_own_model_review_spec.rb +24 -8
  55. data/spec/rails_best_practices/reviews/law_of_demeter_review_spec.rb +24 -12
  56. data/spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb +17 -5
  57. data/spec/rails_best_practices/reviews/move_code_into_helper_review_spec.rb +14 -3
  58. data/spec/rails_best_practices/reviews/move_code_into_model_review_spec.rb +24 -13
  59. data/spec/rails_best_practices/reviews/move_finder_to_named_scope_review_spec.rb +25 -6
  60. data/spec/rails_best_practices/reviews/move_model_logic_into_model_review_spec.rb +26 -4
  61. data/spec/rails_best_practices/reviews/needless_deep_nesting_review_spec.rb +31 -18
  62. data/spec/rails_best_practices/reviews/not_rescue_exception_spec.rb +23 -10
  63. data/spec/rails_best_practices/reviews/not_use_default_route_review_spec.rb +34 -7
  64. data/spec/rails_best_practices/reviews/not_use_times_ago_in_words_review_spec.rb +19 -8
  65. data/spec/rails_best_practices/reviews/overuse_route_customizations_review_spec.rb +33 -19
  66. data/spec/rails_best_practices/reviews/protect_mass_assignment_review_spec.rb +25 -13
  67. data/spec/rails_best_practices/reviews/remove_empty_helpers_review_spec.rb +14 -4
  68. data/spec/rails_best_practices/reviews/remove_unused_methods_in_controllers_review_spec.rb +91 -23
  69. data/spec/rails_best_practices/reviews/remove_unused_methods_in_helpers_review_spec.rb +20 -5
  70. data/spec/rails_best_practices/reviews/remove_unused_methods_in_models_review_spec.rb +66 -41
  71. data/spec/rails_best_practices/reviews/replace_complex_creation_with_factory_method_review_spec.rb +28 -4
  72. data/spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb +16 -7
  73. data/spec/rails_best_practices/reviews/restrict_auto_generated_routes_review_spec.rb +45 -32
  74. data/spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb +20 -9
  75. data/spec/rails_best_practices/reviews/simplify_render_in_views_review_spec.rb +23 -14
  76. data/spec/rails_best_practices/reviews/use_before_filter_review_spec.rb +34 -7
  77. data/spec/rails_best_practices/reviews/use_model_association_review_spec.rb +21 -6
  78. data/spec/rails_best_practices/reviews/use_multipart_alternative_as_content_type_of_email_review_spec.rb +124 -79
  79. data/spec/rails_best_practices/reviews/use_observer_review_spec.rb +12 -12
  80. data/spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb +16 -4
  81. data/spec/rails_best_practices/reviews/use_query_attribute_review_spec.rb +39 -27
  82. data/spec/rails_best_practices/reviews/use_say_with_time_in_migrations_review_spec.rb +22 -8
  83. data/spec/rails_best_practices/reviews/use_scope_access_review_spec.rb +39 -21
  84. data/spec/rails_best_practices/reviews/use_turbo_sprockets_rails3_review_spec.rb +66 -7
  85. metadata +36 -37
  86. data/.ruby-gemset +0 -1
@@ -13,34 +13,34 @@ module RailsBestPractices::Core
13
13
  end
14
14
 
15
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"]
16
+ expect(methods.get_methods("Post").map(&:method_name)).to eq(["create", "destroy", "save_or_update", "find_by_sql"])
17
+ expect(methods.get_methods("Post", "public").map(&:method_name)).to eq(["create", "destroy"])
18
+ expect(methods.get_methods("Post", "protected").map(&:method_name)).to eq(["save_or_update"])
19
+ expect(methods.get_methods("Post", "private").map(&:method_name)).to eq(["find_by_sql"])
20
+ expect(methods.get_methods("Comment").map(&:method_name)).to eq(["create"])
21
21
  end
22
22
 
23
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")
24
+ expect(methods).to be_has_method("Post", "create", "public")
25
+ expect(methods).to be_has_method("Post", "destroy", "public")
26
+ expect(methods).not_to be_has_method("Post", "save_or_update", "public")
27
+ expect(methods).to be_has_method("Post", "save_or_update", "protected")
28
+ expect(methods).not_to be_has_method("Post", "find_by_sql", "public")
29
+ expect(methods).to be_has_method("Post", "find_by_sql", "private")
30
+ expect(methods).not_to be_has_method("Comment", "destroy")
31
31
  end
32
32
 
33
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
34
+ expect(methods.get_method("Post", "create", "public")).not_to be_nil
35
+ expect(methods.get_method("Post", "create", "protected")).to be_nil
36
36
  end
37
37
 
38
38
  it "should get_all_unused_methods" do
39
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"]
40
+ expect(methods.get_all_unused_methods("public").map(&:method_name)).to eq(["create", "destroy"])
41
+ expect(methods.get_all_unused_methods("protected").map(&:method_name)).to eq(["save_or_update"])
42
+ expect(methods.get_all_unused_methods("private").map(&:method_name)).to eq(["find_by_sql"])
43
+ expect(methods.get_all_unused_methods.map(&:method_name)).to eq(["create", "destroy", "save_or_update", "find_by_sql"])
44
44
  end
45
45
  end
46
46
  end
@@ -10,15 +10,15 @@ module RailsBestPractices::Core
10
10
  end
11
11
 
12
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
13
+ expect(model_associations.get_association("Project", "project_manager")).to eq({"meta" => "belongs_to", "class_name" => "ProjectManager"})
14
+ expect(model_associations.get_association("Project", "people")).to eq({"meta" => "has_many", "class_name" => "Person"})
15
+ expect(model_associations.get_association("Project", "unknown")).to be_nil
16
16
  end
17
17
 
18
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
19
+ expect(model_associations.is_association?("Project", "project_manager")).to eq true
20
+ expect(model_associations.is_association?("Project", "people")).to eq true
21
+ expect(model_associations.is_association?("Project", "unknown")).to eq false
22
22
  end
23
23
  end
24
24
  end
@@ -10,15 +10,15 @@ module RailsBestPractices::Core
10
10
  end
11
11
 
12
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
13
+ expect(model_attributes.get_attribute_type("Post", "title")).to eq(:string)
14
+ expect(model_attributes.get_attribute_type("Post", "user_id")).to eq(:integer)
15
+ expect(model_attributes.get_attribute_type("Post", "unknonw")).to be_nil
16
16
  end
17
17
 
18
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
19
+ expect(model_attributes.is_attribute?("Post", "title")).to be true
20
+ expect(model_attributes.is_attribute?("Post", "user_id")).to be true
21
+ expect(model_attributes.is_attribute?("Post", "unknonw")).to be false
22
22
  end
23
23
  end
24
24
  end
@@ -10,7 +10,7 @@ module RailsBestPractices::Core
10
10
  end
11
11
  subject { Modules.new.tap { |modules| modules << @mod } }
12
12
  it "should add decendant to the corresponding module" do
13
- @mod.should_receive(:add_decendant).with("PostsController")
13
+ expect(@mod).to receive(:add_decendant).with("PostsController")
14
14
  subject.add_module_decendant("PostsHelper", "PostsController")
15
15
  end
16
16
  end
@@ -21,8 +21,8 @@ module RailsBestPractices::Core
21
21
  mod.add_decendant("Admin::UsersController")
22
22
  end
23
23
  }
24
- its(:to_s) { should == "Admin::UsersHelper" }
25
- its(:decendants) { should == ["Admin::UsersController"] }
24
+ it { expect(subject.to_s).to eq("Admin::UsersHelper") }
25
+ it { expect(subject.decendants).to eq(["Admin::UsersController"]) }
26
26
  end
27
27
  end
28
28
  end
@@ -6,23 +6,23 @@ module RailsBestPractices::Core
6
6
 
7
7
  it "should add route" do
8
8
  routes.add_route(["admin", "test"], "posts", "new")
9
- routes.map(&:to_s).should == ["Admin::Test::PostsController#new"]
9
+ expect(routes.map(&:to_s)).to eq(["Admin::Test::PostsController#new"])
10
10
  end
11
11
 
12
12
  context "route" do
13
13
  it "should add namesapces, controller name and action name" do
14
14
  route = Route.new(['admin', 'test'], 'posts', 'new')
15
- route.to_s.should == "Admin::Test::PostsController#new"
15
+ expect(route.to_s).to eq("Admin::Test::PostsController#new")
16
16
  end
17
17
 
18
18
  it "should add controller name with namespace" do
19
19
  route = Route.new(['admin'], 'test/posts', 'new')
20
- route.to_s.should == "Admin::Test::PostsController#new"
20
+ expect(route.to_s).to eq("Admin::Test::PostsController#new")
21
21
  end
22
22
 
23
23
  it "should add routes without controller" do
24
24
  route = Route.new(['posts'], nil, 'new')
25
- route.to_s.should == "PostsController#new"
25
+ expect(route.to_s).to eq("PostsController#new")
26
26
  end
27
27
  end
28
28
  end
@@ -6,7 +6,7 @@ module RailsBestPractices::Core
6
6
  shared_examples_for 'load_plugin_reviews' do
7
7
  it "should load plugins in lib/rails_best_practices/plugins/reviews" do
8
8
  runner = Runner.new
9
- runner.instance_variable_get('@reviews').map(&:class).should include(RailsBestPractices::Plugins::Reviews::NotUseRailsRootReview)
9
+ expect(runner.instance_variable_get('@reviews').map(&:class)).to include(RailsBestPractices::Plugins::Reviews::NotUseRailsRootReview)
10
10
  end
11
11
  end
12
12
 
@@ -16,11 +16,11 @@ end
16
16
  EOF
17
17
  content.gsub!("\n", "\t\n")
18
18
  runner.lexical('app/models/user.rb', content)
19
- runner.should have(1).errors
20
- runner.errors[0].to_s.should == "app/models/user.rb:3 - line is longer than 80 characters (81 characters)"
19
+ expect(runner.errors.size).to eq(1)
20
+ expect(runner.errors[0].to_s).to eq("app/models/user.rb:3 - line is longer than 80 characters (81 characters)")
21
21
  end
22
22
  it "should find long lines with own max size" do
23
- runner = Core::Runner.new(lexicals: LongLineCheck.new('max_line_length' => 90))
23
+ runner = Core::Runner.new(lexicals: LongLineCheck.new("max_line_length" => 90))
24
24
  content =<<-EOF
25
25
  class User < ActiveRecord::Base
26
26
  # 91 Chars
@@ -31,8 +31,8 @@ end
31
31
  EOF
32
32
  content.gsub!("\n", "\t\n")
33
33
  runner.lexical('app/models/user.rb', content)
34
- runner.should have(1).errors
35
- runner.errors[0].to_s.should == "app/models/user.rb:3 - line is longer than 90 characters (91 characters)"
34
+ expect(runner.errors.size).to eq(1)
35
+ expect(runner.errors[0].to_s).to eq("app/models/user.rb:3 - line is longer than 90 characters (91 characters)")
36
36
  end
37
37
  it "should not check non .rb files" do
38
38
  runner = Core::Runner.new(lexicals: LongLineCheck.new)
@@ -40,7 +40,19 @@ EOF
40
40
  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
41
41
  "
42
42
  runner.lexical('app/views/users/index.html.erb', content)
43
- runner.should have(0).errors
43
+ expect(runner.errors.size).to eq(0)
44
+ end
45
+ it "should not check ignored files" do
46
+ runner = Core::Runner.new(lexicals: LongLineCheck.new(max_line_length: 80, ignored_files: /user/))
47
+ content =<<-EOF
48
+ class User < ActiveRecord::Base
49
+ # 81 Chars
50
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
51
+ end
52
+ EOF
53
+ content.gsub!("\n", "\t\n")
54
+ runner.lexical('app/models/user.rb', content)
55
+ expect(runner.errors.size).to eq(0)
44
56
  end
45
57
  end
46
58
  end
@@ -13,8 +13,8 @@ module RailsBestPractices
13
13
  EOF
14
14
  content.gsub!("\n", "\t\n")
15
15
  runner.lexical('app/models/user.rb', content)
16
- runner.should have(1).errors
17
- runner.errors[0].to_s.should == "app/models/user.rb:1 - remove tab, use spaces instead"
16
+ expect(runner.errors.size).to eq(1)
17
+ expect(runner.errors[0].to_s).to eq("app/models/user.rb:1 - remove tab, use spaces instead")
18
18
  end
19
19
 
20
20
  it "should remove tab with third line" do
@@ -25,8 +25,8 @@ module RailsBestPractices
25
25
  end
26
26
  EOF
27
27
  runner.lexical('app/models/user.rb', content)
28
- runner.should have(1).errors
29
- runner.errors[0].to_s.should == "app/models/user.rb:3 - remove tab, use spaces instead"
28
+ expect(runner.errors.size).to eq(1)
29
+ expect(runner.errors[0].to_s).to eq("app/models/user.rb:3 - remove tab, use spaces instead")
30
30
  end
31
31
 
32
32
  it "should not remove trailing whitespace" do
@@ -36,7 +36,20 @@ module RailsBestPractices
36
36
  end
37
37
  EOF
38
38
  runner.lexical('app/models/user.rb', content)
39
- runner.should have(0).errors
39
+ expect(runner.errors.size).to eq(0)
40
+ end
41
+ it "should not check ignored files" do
42
+ runner = Core::Runner.new(lexicals: RemoveTabCheck.new(ignored_files: /user/))
43
+ content =<<-EOF
44
+ class User < ActiveRecord::Base
45
+ has_many :projects
46
+
47
+ \t
48
+ end
49
+ EOF
50
+ content.gsub!("\n", "\t\n")
51
+ runner.lexical('app/models/user.rb', content)
52
+ expect(runner.errors.size).to eq(0)
40
53
  end
41
54
  end
42
55
  end
@@ -13,8 +13,8 @@ module RailsBestPractices
13
13
  EOF
14
14
  content.gsub!("\n", " \n")
15
15
  runner.lexical('app/models/user.rb', content)
16
- runner.should have(1).errors
17
- runner.errors[0].to_s.should == "app/models/user.rb:1 - remove trailing whitespace"
16
+ expect(runner.errors.size).to eq(1)
17
+ expect(runner.errors[0].to_s).to eq("app/models/user.rb:1 - remove trailing whitespace")
18
18
  end
19
19
 
20
20
  it "should remove whitespace with third line" do
@@ -25,8 +25,8 @@ module RailsBestPractices
25
25
  EOF
26
26
  content.gsub!("d\n", "d \n")
27
27
  runner.lexical('app/models/user.rb', content)
28
- runner.should have(1).errors
29
- runner.errors[0].to_s.should == "app/models/user.rb:3 - remove trailing whitespace"
28
+ expect(runner.errors.size).to eq(1)
29
+ expect(runner.errors[0].to_s).to eq("app/models/user.rb:3 - remove trailing whitespace")
30
30
  end
31
31
 
32
32
  it "should not remove trailing whitespace" do
@@ -36,7 +36,19 @@ module RailsBestPractices
36
36
  end
37
37
  EOF
38
38
  runner.lexical('app/models/user.rb', content)
39
- runner.should have(0).errors
39
+ expect(runner.errors.size).to eq(0)
40
+ end
41
+
42
+ it "should not check ignored files" do
43
+ runner = Core::Runner.new(lexicals: RemoveTrailingWhitespaceCheck.new(ignored_files: /user/))
44
+ content =<<-EOF
45
+ class User < ActiveRecord::Base
46
+ has_many :projects
47
+ end
48
+ EOF
49
+ content.gsub!("\n", " \n")
50
+ runner.lexical('app/models/user.rb', content)
51
+ expect(runner.errors.size).to eq(0)
40
52
  end
41
53
  end
42
54
  end
@@ -16,7 +16,7 @@ module RailsBestPractices
16
16
  EOF
17
17
  runner.prepare('config/application.rb', content)
18
18
  configs = Prepares.configs
19
- configs["config.active_record.whitelist_attributes"].should == "true"
19
+ expect(configs["config.active_record.whitelist_attributes"]).to eq("true")
20
20
  end
21
21
  end
22
22
  end
@@ -15,7 +15,7 @@ module RailsBestPractices
15
15
  EOF
16
16
  runner.prepare('app/controllers/posts_controller.rb', content)
17
17
  methods = Prepares.controller_methods
18
- methods.get_methods("PostsController").map(&:method_name).should == ["index", "show"]
18
+ expect(methods.get_methods("PostsController").map(&:method_name)).to eq(["index", "show"])
19
19
  end
20
20
 
21
21
  it "should parse model methods with access control" do
@@ -31,10 +31,10 @@ module RailsBestPractices
31
31
  EOF
32
32
  runner.prepare('app/controllers/posts_controller.rb', content)
33
33
  methods = Prepares.controller_methods
34
- methods.get_methods("PostsController").map(&:method_name).should == ["index", "show", "resources", "resource"]
35
- methods.get_methods("PostsController", "public").map(&:method_name).should == ["index", "show"]
36
- methods.get_methods("PostsController", "protected").map(&:method_name).should == ["resources"]
37
- methods.get_methods("PostsController", "private").map(&:method_name).should == ["resource"]
34
+ expect(methods.get_methods("PostsController").map(&:method_name)).to eq(["index", "show", "resources", "resource"])
35
+ expect(methods.get_methods("PostsController", "public").map(&:method_name)).to eq(["index", "show"])
36
+ expect(methods.get_methods("PostsController", "protected").map(&:method_name)).to eq(["resources"])
37
+ expect(methods.get_methods("PostsController", "private").map(&:method_name)).to eq(["resource"])
38
38
  end
39
39
 
40
40
  it "should parse controller methods with module ::" do
@@ -46,7 +46,7 @@ module RailsBestPractices
46
46
  EOF
47
47
  runner.prepare('app/controllers/admin/posts_controller.rb', content)
48
48
  methods = Prepares.controller_methods
49
- methods.get_methods("Admin::Blog::PostsController").map(&:method_name).should == ["index", "show"]
49
+ expect(methods.get_methods("Admin::Blog::PostsController").map(&:method_name)).to eq(["index", "show"])
50
50
  end
51
51
 
52
52
  it "should parse controller methods with module" do
@@ -62,7 +62,7 @@ module RailsBestPractices
62
62
  EOF
63
63
  runner.prepare('app/controllers/admin/posts_controller.rb', content)
64
64
  methods = Prepares.controller_methods
65
- methods.get_methods("Admin::Blog::PostsController").map(&:method_name).should == ["index", "show"]
65
+ expect(methods.get_methods("Admin::Blog::PostsController").map(&:method_name)).to eq(["index", "show"])
66
66
  end
67
67
 
68
68
  context "inherited_resources" do
@@ -73,7 +73,7 @@ module RailsBestPractices
73
73
  EOF
74
74
  runner.prepare('app/controllers/posts_controller.rb', content)
75
75
  methods = Prepares.controller_methods
76
- methods.get_methods("PostsController").map(&:method_name).should == ["index", "show", "new", "create", "edit", "update", "destroy"]
76
+ expect(methods.get_methods("PostsController").map(&:method_name)).to eq(["index", "show", "new", "create", "edit", "update", "destroy"])
77
77
  end
78
78
 
79
79
  it "extend inherited_resources with actions" do
@@ -84,7 +84,7 @@ module RailsBestPractices
84
84
  EOF
85
85
  runner.prepare('app/controllers/posts_controller.rb', content)
86
86
  methods = Prepares.controller_methods
87
- methods.get_methods("PostsController").map(&:method_name).should == ["index", "show"]
87
+ expect(methods.get_methods("PostsController").map(&:method_name)).to eq(["index", "show"])
88
88
  end
89
89
 
90
90
  it "extend inherited_resources with all actions" do
@@ -95,7 +95,7 @@ module RailsBestPractices
95
95
  EOF
96
96
  runner.prepare('app/controllers/posts_controller.rb', content)
97
97
  methods = Prepares.controller_methods
98
- methods.get_methods("PostsController").map(&:method_name).should == ["index", "new", "create", "edit", "update", "destroy"]
98
+ expect(methods.get_methods("PostsController").map(&:method_name)).to eq(["index", "new", "create", "edit", "update", "destroy"])
99
99
  end
100
100
 
101
101
  it "extend inherited_resources with all actions with no arguments" do
@@ -106,7 +106,7 @@ module RailsBestPractices
106
106
  EOF
107
107
  runner.prepare('app/controllers/posts_controller.rb', content)
108
108
  methods = Prepares.controller_methods
109
- methods.get_methods("PostsController").map(&:method_name).should == ["index", "show", "new", "create", "edit", "update", "destroy"]
109
+ expect(methods.get_methods("PostsController").map(&:method_name)).to eq(["index", "show", "new", "create", "edit", "update", "destroy"])
110
110
  end
111
111
 
112
112
  it "DSL inherit_resources" do
@@ -117,7 +117,7 @@ module RailsBestPractices
117
117
  EOF
118
118
  runner.prepare('app/controllers/posts_controller.rb', content)
119
119
  methods = Prepares.controller_methods
120
- methods.get_methods("PostsController").map(&:method_name).should == ["index", "show", "new", "create", "edit", "update", "destroy"]
120
+ expect(methods.get_methods("PostsController").map(&:method_name)).to eq(["index", "show", "new", "create", "edit", "update", "destroy"])
121
121
  end
122
122
  end
123
123
  end
@@ -136,7 +136,7 @@ module RailsBestPractices
136
136
  EOF
137
137
  runner.prepare('app/controllers/posts_controller.rb', content)
138
138
  helpers = Prepares.helpers
139
- helpers.first.decendants.should == ["PostsController"]
139
+ expect(helpers.first.decendants).to eq(["PostsController"])
140
140
  end
141
141
  end
142
142
  end
@@ -26,7 +26,7 @@ PLATFORMS
26
26
  EOF
27
27
  runner.prepare('Gemfile.lock', content)
28
28
  gems = Prepares.gems
29
- gems.map(&:to_s).should == ["rails (3.2.13)", "mysql2 (0.3.12b6)"]
29
+ expect(gems.map(&:to_s)).to eq(["rails (3.2.13)", "mysql2 (0.3.12b6)"])
30
30
  end
31
31
  end
32
32
  end
@@ -15,7 +15,7 @@ module RailsBestPractices
15
15
  EOF
16
16
  runner.prepare('app/helpers/posts_helper.rb', content)
17
17
  methods = Prepares.helper_methods
18
- methods.get_methods("PostsHelper").map(&:method_name).should == ["used", "unused"]
18
+ expect(methods.get_methods("PostsHelper").map(&:method_name)).to eq(["used", "unused"])
19
19
  end
20
20
 
21
21
  it "should parse helpers" do
@@ -37,7 +37,7 @@ module RailsBestPractices
37
37
  EOF
38
38
  runner.prepare("app/helpers/base_helper.rb", content)
39
39
  helpers = Prepares.helpers
40
- helpers.map(&:to_s).should == ["PostsHelper", "Admin::UsersHelper", "Admin", "Admin::BaseHelper"]
40
+ expect(helpers.map(&:to_s)).to eq(["PostsHelper", "Admin::UsersHelper", "Admin", "Admin::BaseHelper"])
41
41
  end
42
42
  end
43
43
  end
@@ -14,7 +14,7 @@ module RailsBestPractices
14
14
  EOF
15
15
  runner.prepare('config/initializers/ar.rb', content)
16
16
  configs = Prepares.configs
17
- configs["railsbp.include_forbidden_attributes_protection"].should == "true"
17
+ expect(configs["railsbp.include_forbidden_attributes_protection"]).to eq("true")
18
18
  end
19
19
 
20
20
  it "should not set include_forbidden_attributes_protection config" do
@@ -24,7 +24,7 @@ module RailsBestPractices
24
24
  EOF
25
25
  runner.prepare('config/initializers/ar.rb', content)
26
26
  configs = Prepares.configs
27
- configs["railsbp.include_forbidden_attributes_protection"].should be_nil
27
+ expect(configs["railsbp.include_forbidden_attributes_protection"]).to be_nil
28
28
  end
29
29
  end
30
30
  end
@@ -11,7 +11,7 @@ module RailsBestPractices
11
11
  end
12
12
  EOF
13
13
  runner.prepare('app/mailers/project_mailer.rb', content)
14
- Prepares.mailers.map(&:to_s).should == ["ProjectMailer"]
14
+ expect(Prepares.mailers.map(&:to_s)).to eq(["ProjectMailer"])
15
15
  end
16
16
  end
17
17
  end