Sha256: c694413718fb03c4a0bb5b368afc849214559337dfee6d86db546fd3d96e5c72

Contents?: true

Size: 1.39 KB

Versions: 17

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

module RailsBestPractices
  module Reviews
    describe MoveCodeIntoControllerReview do
      let(:runner) { Core::Runner.new(reviews: MoveCodeIntoControllerReview.new) }

      it "should move code into controller for method call" do
        content = <<-EOF
        <% Post.find(:all).each do |post| %>
          <%=h post.title %>
          <%=h post.content %>
        <% end %>
        EOF
        runner.review('app/views/posts/index.html.erb', content)
        runner.should have(1).errors
        runner.errors[0].to_s.should == "app/views/posts/index.html.erb:1 - move code into controller"
      end

      it "should move code into controller for assign" do
        content = <<-EOF
        <% @posts = Post.all %>
        <% @posts.each do |post| %>
          <%=h post.title %>
          <%=h post.content %>
        <% end %>
        EOF
        runner.review('app/views/posts/index.html.erb', content)
        runner.should have(1).errors
        runner.errors[0].to_s.should == "app/views/posts/index.html.erb:1 - move code into controller"
      end

      it "should not move code into controller" do
        content = <<-EOF
        <% @posts.each do |post| %>
          <%=h post.title %>
          <%=h post.content %>
        <% end %>
        EOF
        runner.review('app/views/posts/index.html.erb', content)
        runner.should have(0).errors
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rails_best_practices-1.14.4 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.14.3 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.14.2 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.14.1 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.14.0 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.13.8 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.13.5 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.13.4 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.13.3 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.13.2 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.13.1 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.13.0 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.12.0 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.11.1 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.11.0 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.10.1 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb
rails_best_practices-1.10.0 spec/rails_best_practices/reviews/move_code_into_controller_review_spec.rb