Sha256: f9e06cc2a32009ae1d96d309f76f781d8bf2575d01a434e8de43e9ef582e8183

Contents?: true

Size: 905 Bytes

Versions: 2

Compression:

Stored size: 905 Bytes

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 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

2 entries across 2 versions & 1 rubygems

Version Path
rails_best_practices-0.3.0 spec/rails_best_practices/checks/replace_instance_variable_with_local_variable_check_spec.rb
rails_best_practices-0.2.16 spec/rails_best_practices/checks/replace_instance_variable_with_local_variable_check_spec.rb