@@ -5,24 +5,43 @@ module CC
5
5
module Engine
6
6
describe CSSlint do
7
7
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; }' }
10
13
11
14
describe '#run' do
12
15
it 'analyzes *.css files' do
13
- create_source_file ( 'foo.css' , content )
16
+ create_source_file ( 'foo.css' , id_selector_content )
14
17
expect { lint . run } . to output ( /Don't use IDs in selectors./ ) . to_stdout
15
18
end
16
19
17
20
it "doesn't analyze *.scss files" do
18
- create_source_file ( 'foo.scss' , content )
21
+ create_source_file ( 'foo.scss' , id_selector_content )
19
22
expect { lint . run } . to_not output . to_stdout
20
23
end
21
24
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
24
37
end
25
38
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
26
45
end
27
46
end
28
47
end
0 commit comments