Sha256: dbb854da4df861651e22cd54cd5bf4bd29432c860714789508e2ca76b6a635a5

Contents?: true

Size: 1.93 KB

Versions: 16

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'

describe SCSSLint::Reporter::CleanFilesReporter do
  subject { described_class.new(lints, files, nil) }

  describe '#report_lints' do
    context 'when there are no lints and no files' do
      let(:files) { [] }
      let(:lints) { [] }

      it 'returns nil' do
        subject.report_lints.should be_nil
      end
    end

    context 'when there are no lints but some files were linted' do
      let(:files) { %w[c.scss b.scss a.scss] }
      let(:lints) { [] }

      it 'prints each file on its own line' do
        subject.report_lints.count("\n").should == 3
      end

      it 'prints the files in order' do
        subject.report_lints.split("\n")[0].should eq 'a.scss'
        subject.report_lints.split("\n")[1].should eq 'b.scss'
        subject.report_lints.split("\n")[2].should eq 'c.scss'
      end

      it 'prints a trailing newline' do
        subject.report_lints[-1].should == "\n"
      end
    end

    context 'when there are lints in some files' do
      let(:dirty_files) { %w[a.scss b.scss] }
      let(:clean_files) { %w[c.scss d.scss] }
      let(:files) { dirty_files + clean_files }

      let(:lints) do
        dirty_files.map do |file|
          SCSSLint::Lint.new(nil, file, SCSSLint::Location.new, '')
        end
      end

      it 'prints the file for each lint' do
        clean_files.each do |file|
          subject.report_lints.scan(file).count.should == 1
        end
      end

      it 'does not print clean files' do
        dirty_files.each do |file|
          subject.report_lints.scan(file).count.should == 0
        end
      end
    end

    context 'when there are lints in every file' do
      let(:files) { %w[a.scss b.scss c.scss d.scss] }

      let(:lints) do
        files.map do |file|
          SCSSLint::Lint.new(nil, file, SCSSLint::Location.new, '')
        end
      end

      it 'does not print clean files' do
        subject.report_lints.should be_nil
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
scss_lint-0.55.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.54.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.53.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.52.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.51.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.50.3 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.50.2 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.50.1 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.50.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.49.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.48.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.47.1 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.47.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.46.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.45.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb
scss_lint-0.44.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb