Permalink
Browse files

Adding in spec test for RemoveTab check

  • Loading branch information...
raydog153 committed Jun 14, 2011
1 parent 01b8a57 commit 1f8cd21066ef6ebc0d47084ba38f30063f46d02a
Showing with 39 additions and 0 deletions.
  1. +39 −0 spec/rails_best_practices/lexicals/remove_tab_check_spec.rb
@@ -0,0 +1,39 @@
+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

0 comments on commit 1f8cd21

Please sign in to comment.