Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bcc620f

Browse files
committed
Add spec to capture extant excluded_files behavior.
1 parent c74d303 commit bcc620f

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

spec/cc/engine/csslint_spec.rb

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,43 @@ module CC
55
module Engine
66
describe CSSlint do
77
let(:code) { Dir.mktmpdir }
8-
let(:lint) { CSSlint.new(directory: code, io: nil, engine_config: {}) }
9-
let(:content) { '#id { color: red; }' }
8+
let(:engine_config) { {} }
9+
let(:lint) do
10+
CSSlint.new(directory: code, io: nil, engine_config: engine_config)
11+
end
12+
let(:id_selector_content) { '#id { color: red; }' }
1013

1114
describe '#run' do
1215
it 'analyzes *.css files' do
13-
create_source_file('foo.css', content)
16+
create_source_file('foo.css', id_selector_content)
1417
expect{ lint.run }.to output(/Don't use IDs in selectors./).to_stdout
1518
end
1619

1720
it "doesn't analyze *.scss files" do
18-
create_source_file('foo.scss', content)
21+
create_source_file('foo.scss', id_selector_content)
1922
expect{ lint.run }.to_not output.to_stdout
2023
end
2124

22-
def create_source_file(path, content)
23-
File.write(File.join(code, path), content)
25+
describe "with exclude_paths" do
26+
let(:engine_config) { {"exclude_paths" => %w(excluded.css)} }
27+
28+
before do
29+
create_source_file("not_excluded.css", "p { margin: 5px }")
30+
create_source_file("excluded.css", id_selector_content)
31+
end
32+
33+
it "excludes all matching paths" do
34+
expect{ lint.run }.not_to \
35+
output(/Don't use IDs in selectors./).to_stdout
36+
end
2437
end
2538
end
39+
40+
def create_source_file(path, content)
41+
abs_path = File.join(code, path)
42+
FileUtils.mkdir_p(File.dirname(abs_path))
43+
File.write(abs_path, content)
44+
end
2645
end
2746
end
2847
end

0 commit comments

Comments
 (0)