@@ -133,7 +133,7 @@ def test_multiline_declarations
133133 end
134134
135135 def test_find_rule_sets
136- css = <<- CSS
136+ css = <<~ CSS
137137 h1, h2 { color: blue; }
138138 h1 { font-size: 10px; }
139139 h2 { font-size: 5px; }
@@ -144,9 +144,37 @@ def test_find_rule_sets
144144
145145 @cp . add_block! ( css )
146146 assert_equal 2 , @cp . find_rule_sets ( [ "h2" ] ) . size
147+ assert_equal 2 , @cp . find_rule_sets ( [ " h2 " ] ) . size
147148 assert_equal 3 , @cp . find_rule_sets ( [ "h1" , "h2" ] ) . size
148- assert_equal 2 , @cp . find_rule_sets ( [ "article h3" ] ) . size
149- assert_equal 2 , @cp . find_rule_sets ( [ " article \t \n h3 \n " ] ) . size
149+ assert_equal 1 , @cp . find_rule_sets ( [ "article h3" ] ) . size
150+ assert_equal 1 , @cp . find_rule_sets ( [ "article\n h3" ] ) . size
151+ assert_equal 0 , @cp . find_rule_sets ( [ " article \t \n h3 \n " ] ) . size
152+ end
153+
154+ def test_whitespace_in_selector_names
155+ css = <<~CSS
156+ h1 {}
157+ h1 pre{}
158+ .a.b.c
159+ .d.e.f {}
160+ h1 > pre {}
161+ input[name="Joe"]{}
162+ input[name="Joe Doe"]{}
163+ input:not(a,b){}
164+ CSS
165+
166+ @cp . add_block! ( css )
167+
168+ assert_equal (
169+ [ "h1" ,
170+ "h1 pre" ,
171+ ".a.b.c\n .d.e.f" ,
172+ "h1 > pre" ,
173+ "input[name=\" Joe\" ]" ,
174+ "input[name=\" Joe Doe\" ]" ,
175+ "input:not(a,b)" ] ,
176+ @cp . rules_by_media_query [ :all ] . flat_map ( &:selectors )
177+ )
150178 end
151179
152180 def test_calculating_specificity
@@ -171,13 +199,17 @@ def test_calculating_specificity
171199
172200 def test_converting_uris
173201 base_uri = 'http://www.example.org/style/basic.css'
174- [ "body { background: url(yellow) };" , "body { background: url('yellow') };" ,
175- "body { background: url('/style/yellow') };" ,
176- "body { background: url(\" ../style/yellow\" ) };" ,
177- "body { background: url(\" lib/../../style/yellow\" ) };" ] . each do |css |
178- converted_css = CssParser . convert_uris ( css , base_uri )
179- assert_equal "body { background: url('http://www.example.org/style/yellow') };" , converted_css
180- end
202+ [
203+ "body { background: url(yellow) };" ,
204+ "body { background: url('yellow') };" ,
205+ "body { background: url('/style/yellow') };" ,
206+ "body { background: url(\" ../style/yellow\" ) };" ,
207+ "body { background: url(\" lib/../../style/yellow\" ) };"
208+ ]
209+ . each do |css |
210+ converted_css = CssParser . convert_uris ( css , base_uri )
211+ assert_equal "body { background: url('http://www.example.org/style/yellow') };" , converted_css
212+ end
181213
182214 converted_css = CssParser . convert_uris ( "body { background: url(../style/yellow-dot_symbol$.png?abc=123&def=456&ghi=789#1011) };" , base_uri )
183215 assert_equal "body { background: url('http://www.example.org/style/yellow-dot_symbol$.png?abc=123&def=456&ghi=789#1011') };" , converted_css
0 commit comments