Sha256: b5039ea96b084e160be42d6328601bbd14a12491427d30ddb1b6e485970f2eb6

Contents?: true

Size: 1.96 KB

Versions: 17

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'

describe RailsBestPractices::Reviews::SimplifyRenderInControllersReview do
  let(:runner) { RailsBestPractices::Core::Runner.new(:reviews => RailsBestPractices::Reviews::SimplifyRenderInControllersReview.new) }

  it "should simplify render action view" do
    content =<<-EOF
    def edit
      render :action => :edit
    end
    EOF
    runner.review("app/controllers/posts_controller.rb", content)
    runner.should have(1).errors
    runner.errors[0].to_s.should == "app/controllers/posts_controller.rb:2 - simplify render in controllers"
  end

  it "should simplify render actions's template" do
    content =<<-EOF
    def edit
      render :template => 'books/edit'
    end
    EOF
    runner.review("app/controllers/posts_controller.rb", content)
    runner.should have(1).errors
    runner.errors[0].to_s.should == "app/controllers/posts_controller.rb:2 - simplify render in controllers"
  end

  it "should simplify render an arbitrary file" do
    content =<<-EOF
    def edit
      render :file => '/path/to/rails/app/views/books/edit'
    end
    EOF
    runner.review("app/controllers/posts_controller.rb", content)
    runner.should have(1).errors
    runner.errors[0].to_s.should == "app/controllers/posts_controller.rb:2 - simplify render in controllers"
  end

  it "should not simplify render action view" do
    content =<<-EOF
    render :edit
    EOF
    runner.review("app/controllers/posts_controller", content)
    runner.should have(0).errors
  end

  it "should not simplify render actions's template" do
    content =<<-EOF
    def edit
      render 'books/edit'
    end
    EOF
    runner.review("app/controllers/posts_controller.rb", content)
    runner.should have(0).errors
  end

  it "should not simplify render an arbitrary file" do
    content =<<-EOF
    def edit
      render '/path/to/rails/app/views/books/edit'
    end
    EOF
    runner.review("app/controllers/posts_controller.rb", content)
    runner.should have(0).errors
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
rails_best_practices-gorgeouscode-1.0.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.9.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.8.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.7.2 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.7.1 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.7.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.6.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.5.3 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.5.2 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.5.1 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.5.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.4.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.3.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.2.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.1.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.0.1 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb
rails_best_practices-1.0.0 spec/rails_best_practices/reviews/simplify_render_in_controllers_review_spec.rb