Sha256: f5436d1f8c23359e46cd113a619049271cb39eb05b5688d6779cbc6e1b344442

Contents?: true

Size: 1.13 KB

Versions: 25

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe RailsBestPractices::Reviews::ReplaceInstanceVariableWithLocalVariableReview do
  let(:runner) { RailsBestPractices::Core::Runner.new(:reviews => RailsBestPractices::Reviews::ReplaceInstanceVariableWithLocalVariableReview.new) }

  it "should replace instance variable with local varialbe" do
    content = <<-EOF
    <%= @post.title %>
    EOF
    runner.review('app/views/posts/_post.html.erb', content)
    runner.should have(1).errors
    runner.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.review('app/views/posts/_post.html.haml', content)
    runner.should have(1).errors
    runner.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.review('app/views/posts/_post.html.erb', content)
    runner.should have(0).errors
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
rails_best_practices-1.6.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.5.3 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.5.2 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.5.1 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.5.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.4.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.3.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.2.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.1.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.0.1 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.0.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-0.10.1 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-0.10.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-raydog153-0.9.1 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-0.9.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-0.8.2 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-0.8.1 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-0.8.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-0.7.5 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-0.7.4 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb