Sha256: b38184daa5c19b52013b6e0584f732cc0cadb56fc1d4af250f29700418d04c8a

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 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(SCSSLint::Linter::Comment.new, 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(SCSSLint::Linter::Comment.new, 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

1 entries across 1 versions & 1 rubygems

Version Path
scss_lint-0.56.0 spec/scss_lint/reporter/clean_files_reporter_spec.rb