forked from sds/scss-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
99 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module SCSSLint | ||
# Reports a single line for each clean file (having zero lints). | ||
class Reporter::CleanFilesReporter < Reporter | ||
def report_lints | ||
dirty_files = lints.map(&:filename).uniq | ||
clean_files = files - dirty_files | ||
clean_files.sort.join("\n") + "\n" if clean_files.any? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require 'spec_helper' | ||
|
||
describe SCSSLint::Reporter::CleanFilesReporter do | ||
subject { described_class.new(lints, files) } | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters