Sha256: 2972b9832a0f875b885f1938de9277a4d20cd32d23dc5ed0ad791f4fe7c7ae5b

Contents?: true

Size: 1.24 KB

Versions: 28

Compression:

Stored size: 1.24 KB

Contents

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

describe RailsBestPractices::Checks::ReplaceInstanceVariableWithLocalVariableCheck do
  before(:each) do
    @runner = RailsBestPractices::Core::Runner.new(RailsBestPractices::Checks::ReplaceInstanceVariableWithLocalVariableCheck.new)
  end

  it "should replace instance variable with local varialbe" do
    content = <<-EOF
    <%= @post.title %>
    EOF
    @runner.check('app/views/posts/_post.html.erb', content)
    errors = @runner.errors
    errors.should_not be_empty
    errors[0].to_s.should == "app/views/posts/_post.html.erb:1 - replace instance variable with local variable"
  end

  it "should replace instance variable with local varialbe in haml file" do
    content = <<-EOF
= @post.title
    EOF
    @runner.check('app/views/posts/_post.html.haml', content)
    errors = @runner.errors
    errors.should_not be_empty
    errors[0].to_s.should == "app/views/posts/_post.html.haml:1 - replace instance variable with local variable"
  end

  it "should not replace instance variable with local varialbe" do
    content = <<-EOF
    <%= post.title %>
    EOF
    @runner.check('app/views/posts/_post.html.erb', content)
    errors = @runner.errors
    errors.should be_empty
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

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