Sha256: 17ce8184128a12a9b17b2f8e2776f00e10456d9e97d64eaf248a739f05b903bd

Contents?: true

Size: 1.56 KB

Versions: 17

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

module RailsBestPractices
  module Reviews
    describe ReplaceInstanceVariableWithLocalVariableReview do
      let(:runner) { Core::Runner.new(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 replace instance variable with local varialbe in slim file" do
        content = <<-EOF
= @post.title
        EOF
        runner.review('app/views/posts/_post.html.slim', content)
        runner.should have(1).errors
        runner.errors[0].to_s.should == "app/views/posts/_post.html.slim: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
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rails_best_practices-1.14.4 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.14.3 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.14.2 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.14.1 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.14.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.13.8 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.13.5 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.13.4 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.13.3 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.13.2 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.13.1 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.13.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.12.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.11.1 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.11.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.10.1 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb
rails_best_practices-1.10.0 spec/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review_spec.rb