Sha256: d668d9e0e1897a8444599d12e04df11f7182a2392125220816f1f51dfeba9c02

Contents?: true

Size: 1.03 KB

Versions: 13

Compression:

Stored size: 1.03 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)
  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"
  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

13 entries across 13 versions & 1 rubygems

Version Path
rails_best_practices-0.3.11 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.10 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.9 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.8 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.7 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.6 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.5 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.4 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.3 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.2 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.1 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.3.0 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
rails_best_practices-0.2.16 spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb