Sha256: ce3820ca6e84f9df8c2ccd17a18f616277ddb281d18058cbbaccab29bae17672

Contents?: true

Size: 1.08 KB

Versions: 19

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe RailsBestPractices::Lexicals::RemoveTabCheck do
  let(:runner) { RailsBestPractices::Core::Runner.new(:lexicals => RailsBestPractices::Lexicals::RemoveTabCheck.new) }

  it "should remove tab" do
    content =<<-EOF
    class User < ActiveRecord::Base
      has_many :projects
    end
    EOF
    content.gsub!("\n", "\t\n")
    runner.lexical('app/models/user.rb', content)
    runner.should have(1).errors
    runner.errors[0].to_s.should == "app/models/user.rb:1 - remove tab, use spaces instead"
  end

  it "should remove tab with third line" do
    content =<<-EOF
    class User < ActiveRecord::Base
      has_many :projects
\t
    end
    EOF
    runner.lexical('app/models/user.rb', content)
    runner.should have(1).errors
    runner.errors[0].to_s.should == "app/models/user.rb:3 - remove tab, use spaces instead"
  end

  it "should not remove trailing whitespace" do
    content =<<-EOF
    class User < ActiveRecord::Base
      has_many :projects
    end
    EOF
    runner.lexical('app/models/user.rb', content)
    runner.should have(0).errors
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
rails_best_practices-gorgeouscode-1.0.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.9.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.8.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.7.2 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.7.1 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.7.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.6.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.5.3 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.5.2 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.5.1 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.5.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.4.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.3.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.2.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.1.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.0.1 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-1.0.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-0.10.1 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
rails_best_practices-0.10.0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb