Sha256: e3991f28b2ad69001930a4c499a55d3618549453e5add6bda2c7a14586f5a007

Contents?: true

Size: 1.15 KB

Versions: 30

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

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

  it "should remove trailing whitespace" do
    content =<<-EOF
    class User < ActiveRecord::Base
      has_many :projects
    end
    EOF
    content.gsub!("\n", "  \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 trailing whitespace"
  end

  it "should remove whitespace with third line" do
    content =<<-EOF
    class User < ActiveRecord::Base
      has_many :projects
    end
    EOF
    content.gsub!("d\n", "d  \n")
    runner.lexical('app/models/user.rb', content)
    runner.should have(1).errors
    runner.errors[0].to_s.should == "app/models/user.rb:3 - remove trailing whitespace"
  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

30 entries across 30 versions & 3 rubygems

Version Path
rails_best_practices-0.9.0 spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
rails_best_practices-0.8.2 spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
rails_best_practices-0.8.1 spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
rails_best_practices-0.8.0 spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
rails_best_practices-0.7.5 spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
rails_best_practices-0.7.4 spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
rails_best_practices-0.7.3 spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
rails_best_practices-0.7.2 spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
rails_best_practices-0.7.1 spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb
rails_best_practices-0.7.0 spec/rails_best_practices/lexicals/remove_trailing_whitespace_check_spec.rb