Sha256: d3ea6a89772a6ac0a57cf3ed38a61c41cd9c2510cd195b5bffe7bfe9b0bdb857

Contents?: true

Size: 997 Bytes

Versions: 32

Compression:

Stored size: 997 Bytes

Contents

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

describe RailsBestPractices::Checks::MoveCodeIntoControllerCheck do
  before(:each) do
    @runner = RailsBestPractices::Core::Runner.new(RailsBestPractices::Checks::MoveCodeIntoControllerCheck.new)
  end
  
  it "should move code into controller" do
    content = <<-EOF
    <% @posts = Post.find(:all) %>
    <% @posts.each do |post| %>
      <%=h post.title %>
      <%=h post.content %>
    <% end %>
    EOF
    @runner.check('app/views/posts/index.html.erb', content)
    errors = @runner.errors
    errors.should_not be_empty
    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.check('app/views/posts/index.html.erb', content)
    errors = @runner.errors
    errors.should be_empty
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

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