Sha256: 810320b3c5862a1f408b1055707751caab46c1a88bcab69f2305750ffb132bf4

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require '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.review('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.review('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.review('app/views/posts/_post.html.erb', content)
    errors = @runner.errors
    errors.should be_empty
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_best_practices-0.6.6 spec/rails_best_practices/checks/replace_instance_variable_with_local_variable_check_spec.rb
rails_best_practices-0.6.5 spec/rails_best_practices/checks/replace_instance_variable_with_local_variable_check_spec.rb