Sha256: d7d17cd23e077dbab07b7b8b0a55c750ec74aa8ea9cc723d19fd6084107f601b

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

module RailsBestPractices
  module Reviews
    describe MoveCodeIntoHelperReview do
      let(:runner) { Core::Runner.new(:reviews => MoveCodeIntoHelperReview.new('array_count' => 2)) }

      it "should move code into helper" do
        content = <<-EOF
        <%= select_tag :state, options_for_select( [[t(:draft), "draft"],
                                                    [t(:published), "published"]],
                                                   params[:default_state] ) %>
        EOF
        runner.review('app/views/posts/show.html.erb', content)
        runner.should have(1).errors
        runner.errors[0].to_s.should == "app/views/posts/show.html.erb:1 - move code into helper (array_count >= 2)"
      end

      it "should not move code into helper with simple arguments" do
        content = <<-EOF
        <%= select_tag :state, options_for_select( Post.STATES ) %>
        EOF
        runner.review('app/views/posts/show.html.erb', content)
        runner.should have(0).errors
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_best_practices-1.9.1 spec/rails_best_practices/reviews/move_code_into_helper_review_spec.rb