Sha256: 27ac7c2ecaeaaf5413aad0618d76222c265d6153f9586bd3f42a87655e161204
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
require File.join(File.dirname(__FILE__) + '/../../spec_helper') describe RailsBestPractices::Checks::NeedlessDeepNestingCheck do before(:each) do @runner = RailsBestPractices::Core::Runner.new(RailsBestPractices::Checks::NeedlessDeepNestingCheck.new) end describe "rails2" do it "should needless deep nesting" do content = <<-EOF map.resources :posts do |post| post.resources :comments do |comment| comment.resources :favorites end end EOF @runner.check('config/routes.rb', content) errors = @runner.errors errors.should_not be_empty errors[0].to_s.should == "config/routes.rb:3 - needless deep nesting (nested_count > 2)" end it "should no needless deep nesting" do content = <<-EOF map.resources :posts do |post| post.resources :comments end map.resources :comments do |comment| comment.resources :favorites end EOF @runner.check('config/routes.rb', content) errors = @runner.errors errors.should be_empty end end describe "rails3" do it "should needless deep nesting" do content = <<-EOF resources :posts do resources :comments do resources :favorites end end EOF @runner.check('config/routes.rb', content) errors = @runner.errors errors.should_not be_empty errors[0].to_s.should == "config/routes.rb:4 - needless deep nesting (nested_count > 2)" end it "should no needless deep nesting" do content = <<-EOF resources :posts do resources :comments resources :votes end resources :comments do resources :favorites end EOF @runner.check('config/routes.rb', content) errors = @runner.errors errors.should be_empty end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_best_practices-0.4.0 | spec/rails_best_practices/checks/needless_deep_nesting_check_spec.rb |