Sha256: c0c6ed61afad55aacc5e7c7b0f7d620589246e3dd925bdad79dba66981b11405

Contents?: true

Size: 1.26 KB

Versions: 17

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

module RailsBestPractices
  module Lexicals
    describe RemoveTrailingWhitespaceCheck do
      let(:runner) { Core::Runner.new(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
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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