Sha256: b4b76bc838f3b2cfad6fdcbc274e47b4652ad74377fe46ebd3939083efc30529

Contents?: true

Size: 1.07 KB

Versions: 17

Compression:

Stored size: 1.07 KB

Contents

require File.join(File.dirname(__FILE__) + '/../../spec_helper')

describe RailsBestPractices::Checks::MoveCodeIntoHelperCheck do
  before(:each) do
    @runner = RailsBestPractices::Core::Runner.new(RailsBestPractices::Checks::MoveCodeIntoHelperCheck.new('array_count' => 2))
  end

  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.check('app/views/posts/show.html.erb', content)
    errors = @runner.errors
    errors.should_not be_empty
    errors[0].to_s.should == "app/views/posts/show.html.erb:3 - 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.check('app/views/posts/show.html.erb', content)
    errors = @runner.errors
    errors.should be_empty
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rails_best_practices-0.4.0 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.27 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.26 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.25 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.24 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.23 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.22 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.21 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.20 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.19 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.18 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.17 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.16 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.15 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.14 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.13 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.12 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb