xass 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile +9 -0
  4. data/Gemfile.lock +39 -0
  5. data/README.md +131 -193
  6. data/lib/initialize.rb +8 -0
  7. data/lib/xass.rb +67 -0
  8. data/spec/secrets.yml +4 -0
  9. data/spec/spec_helper.rb +8 -0
  10. data/spec/test_spec.rb +5 -0
  11. data/template/secrets.yml +2 -0
  12. data/xass.gemspec +15 -0
  13. metadata +53 -294
  14. data/.yardopts +0 -11
  15. data/CONTRIBUTING +0 -3
  16. data/MIT-LICENSE +0 -20
  17. data/Rakefile +0 -349
  18. data/VERSION +0 -1
  19. data/VERSION_NAME +0 -1
  20. data/bin/push +0 -13
  21. data/bin/sass +0 -13
  22. data/bin/sass-convert +0 -12
  23. data/bin/scss +0 -13
  24. data/extra/update_watch.rb +0 -13
  25. data/init.rb +0 -18
  26. data/lib/sass/cache_stores/base.rb +0 -88
  27. data/lib/sass/cache_stores/chain.rb +0 -33
  28. data/lib/sass/cache_stores/filesystem.rb +0 -64
  29. data/lib/sass/cache_stores/memory.rb +0 -47
  30. data/lib/sass/cache_stores/null.rb +0 -25
  31. data/lib/sass/cache_stores.rb +0 -15
  32. data/lib/sass/callbacks.rb +0 -66
  33. data/lib/sass/css.rb +0 -409
  34. data/lib/sass/engine.rb +0 -930
  35. data/lib/sass/environment.rb +0 -101
  36. data/lib/sass/error.rb +0 -201
  37. data/lib/sass/exec.rb +0 -707
  38. data/lib/sass/importers/base.rb +0 -139
  39. data/lib/sass/importers/filesystem.rb +0 -186
  40. data/lib/sass/importers.rb +0 -22
  41. data/lib/sass/logger/base.rb +0 -32
  42. data/lib/sass/logger/log_level.rb +0 -49
  43. data/lib/sass/logger.rb +0 -15
  44. data/lib/sass/media.rb +0 -213
  45. data/lib/sass/plugin/compiler.rb +0 -406
  46. data/lib/sass/plugin/configuration.rb +0 -123
  47. data/lib/sass/plugin/generic.rb +0 -15
  48. data/lib/sass/plugin/merb.rb +0 -48
  49. data/lib/sass/plugin/rack.rb +0 -60
  50. data/lib/sass/plugin/rails.rb +0 -47
  51. data/lib/sass/plugin/staleness_checker.rb +0 -199
  52. data/lib/sass/plugin.rb +0 -133
  53. data/lib/sass/railtie.rb +0 -10
  54. data/lib/sass/repl.rb +0 -57
  55. data/lib/sass/root.rb +0 -7
  56. data/lib/sass/script/arg_list.rb +0 -52
  57. data/lib/sass/script/bool.rb +0 -18
  58. data/lib/sass/script/color.rb +0 -606
  59. data/lib/sass/script/css_lexer.rb +0 -29
  60. data/lib/sass/script/css_parser.rb +0 -31
  61. data/lib/sass/script/funcall.rb +0 -245
  62. data/lib/sass/script/functions.rb +0 -1543
  63. data/lib/sass/script/interpolation.rb +0 -79
  64. data/lib/sass/script/lexer.rb +0 -345
  65. data/lib/sass/script/list.rb +0 -85
  66. data/lib/sass/script/literal.rb +0 -221
  67. data/lib/sass/script/node.rb +0 -99
  68. data/lib/sass/script/null.rb +0 -37
  69. data/lib/sass/script/number.rb +0 -453
  70. data/lib/sass/script/operation.rb +0 -110
  71. data/lib/sass/script/parser.rb +0 -502
  72. data/lib/sass/script/string.rb +0 -51
  73. data/lib/sass/script/string_interpolation.rb +0 -103
  74. data/lib/sass/script/unary_operation.rb +0 -69
  75. data/lib/sass/script/variable.rb +0 -58
  76. data/lib/sass/script.rb +0 -39
  77. data/lib/sass/scss/css_parser.rb +0 -36
  78. data/lib/sass/scss/parser.rb +0 -1180
  79. data/lib/sass/scss/rx.rb +0 -133
  80. data/lib/sass/scss/script_lexer.rb +0 -15
  81. data/lib/sass/scss/script_parser.rb +0 -25
  82. data/lib/sass/scss/static_parser.rb +0 -54
  83. data/lib/sass/scss.rb +0 -16
  84. data/lib/sass/selector/abstract_sequence.rb +0 -94
  85. data/lib/sass/selector/comma_sequence.rb +0 -92
  86. data/lib/sass/selector/sequence.rb +0 -507
  87. data/lib/sass/selector/simple.rb +0 -119
  88. data/lib/sass/selector/simple_sequence.rb +0 -215
  89. data/lib/sass/selector.rb +0 -452
  90. data/lib/sass/shared.rb +0 -76
  91. data/lib/sass/supports.rb +0 -229
  92. data/lib/sass/tree/charset_node.rb +0 -22
  93. data/lib/sass/tree/comment_node.rb +0 -82
  94. data/lib/sass/tree/content_node.rb +0 -9
  95. data/lib/sass/tree/css_import_node.rb +0 -60
  96. data/lib/sass/tree/debug_node.rb +0 -18
  97. data/lib/sass/tree/directive_node.rb +0 -42
  98. data/lib/sass/tree/each_node.rb +0 -24
  99. data/lib/sass/tree/extend_node.rb +0 -36
  100. data/lib/sass/tree/for_node.rb +0 -36
  101. data/lib/sass/tree/function_node.rb +0 -34
  102. data/lib/sass/tree/if_node.rb +0 -52
  103. data/lib/sass/tree/import_node.rb +0 -75
  104. data/lib/sass/tree/media_node.rb +0 -58
  105. data/lib/sass/tree/mixin_def_node.rb +0 -38
  106. data/lib/sass/tree/mixin_node.rb +0 -39
  107. data/lib/sass/tree/node.rb +0 -196
  108. data/lib/sass/tree/prop_node.rb +0 -152
  109. data/lib/sass/tree/return_node.rb +0 -18
  110. data/lib/sass/tree/root_node.rb +0 -78
  111. data/lib/sass/tree/rule_node.rb +0 -132
  112. data/lib/sass/tree/supports_node.rb +0 -51
  113. data/lib/sass/tree/trace_node.rb +0 -32
  114. data/lib/sass/tree/variable_node.rb +0 -30
  115. data/lib/sass/tree/visitors/base.rb +0 -75
  116. data/lib/sass/tree/visitors/check_nesting.rb +0 -147
  117. data/lib/sass/tree/visitors/convert.rb +0 -316
  118. data/lib/sass/tree/visitors/cssize.rb +0 -241
  119. data/lib/sass/tree/visitors/deep_copy.rb +0 -102
  120. data/lib/sass/tree/visitors/extend.rb +0 -68
  121. data/lib/sass/tree/visitors/perform.rb +0 -446
  122. data/lib/sass/tree/visitors/set_options.rb +0 -125
  123. data/lib/sass/tree/visitors/to_css.rb +0 -228
  124. data/lib/sass/tree/warn_node.rb +0 -18
  125. data/lib/sass/tree/while_node.rb +0 -18
  126. data/lib/sass/util/multibyte_string_scanner.rb +0 -155
  127. data/lib/sass/util/subset_map.rb +0 -109
  128. data/lib/sass/util/test.rb +0 -10
  129. data/lib/sass/util.rb +0 -948
  130. data/lib/sass/version.rb +0 -126
  131. data/lib/sass.rb +0 -95
  132. data/rails/init.rb +0 -1
  133. data/test/Gemfile +0 -3
  134. data/test/Gemfile.lock +0 -10
  135. data/test/sass/cache_test.rb +0 -89
  136. data/test/sass/callbacks_test.rb +0 -61
  137. data/test/sass/conversion_test.rb +0 -1760
  138. data/test/sass/css2sass_test.rb +0 -458
  139. data/test/sass/data/hsl-rgb.txt +0 -319
  140. data/test/sass/engine_test.rb +0 -3244
  141. data/test/sass/exec_test.rb +0 -86
  142. data/test/sass/extend_test.rb +0 -1482
  143. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  144. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  145. data/test/sass/functions_test.rb +0 -1139
  146. data/test/sass/importer_test.rb +0 -192
  147. data/test/sass/logger_test.rb +0 -58
  148. data/test/sass/mock_importer.rb +0 -49
  149. data/test/sass/more_results/more1.css +0 -9
  150. data/test/sass/more_results/more1_with_line_comments.css +0 -26
  151. data/test/sass/more_results/more_import.css +0 -29
  152. data/test/sass/more_templates/_more_partial.sass +0 -2
  153. data/test/sass/more_templates/more1.sass +0 -23
  154. data/test/sass/more_templates/more_import.sass +0 -11
  155. data/test/sass/plugin_test.rb +0 -564
  156. data/test/sass/results/alt.css +0 -4
  157. data/test/sass/results/basic.css +0 -9
  158. data/test/sass/results/cached_import_option.css +0 -3
  159. data/test/sass/results/compact.css +0 -5
  160. data/test/sass/results/complex.css +0 -86
  161. data/test/sass/results/compressed.css +0 -1
  162. data/test/sass/results/expanded.css +0 -19
  163. data/test/sass/results/filename_fn.css +0 -3
  164. data/test/sass/results/if.css +0 -3
  165. data/test/sass/results/import.css +0 -31
  166. data/test/sass/results/import_charset.css +0 -5
  167. data/test/sass/results/import_charset_1_8.css +0 -5
  168. data/test/sass/results/import_charset_ibm866.css +0 -5
  169. data/test/sass/results/import_content.css +0 -1
  170. data/test/sass/results/line_numbers.css +0 -49
  171. data/test/sass/results/mixins.css +0 -95
  172. data/test/sass/results/multiline.css +0 -24
  173. data/test/sass/results/nested.css +0 -22
  174. data/test/sass/results/options.css +0 -1
  175. data/test/sass/results/parent_ref.css +0 -13
  176. data/test/sass/results/script.css +0 -16
  177. data/test/sass/results/scss_import.css +0 -31
  178. data/test/sass/results/scss_importee.css +0 -2
  179. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  180. data/test/sass/results/subdir/subdir.css +0 -3
  181. data/test/sass/results/units.css +0 -11
  182. data/test/sass/results/warn_imported.css +0 -0
  183. data/test/sass/script_conversion_test.rb +0 -299
  184. data/test/sass/script_test.rb +0 -622
  185. data/test/sass/scss/css_test.rb +0 -1100
  186. data/test/sass/scss/rx_test.rb +0 -156
  187. data/test/sass/scss/scss_test.rb +0 -2106
  188. data/test/sass/scss/test_helper.rb +0 -37
  189. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  190. data/test/sass/templates/_double_import_loop2.sass +0 -1
  191. data/test/sass/templates/_filename_fn_import.scss +0 -11
  192. data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  193. data/test/sass/templates/_imported_charset_utf8.sass +0 -4
  194. data/test/sass/templates/_imported_content.sass +0 -3
  195. data/test/sass/templates/_partial.sass +0 -2
  196. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  197. data/test/sass/templates/alt.sass +0 -16
  198. data/test/sass/templates/basic.sass +0 -23
  199. data/test/sass/templates/bork1.sass +0 -2
  200. data/test/sass/templates/bork2.sass +0 -2
  201. data/test/sass/templates/bork3.sass +0 -2
  202. data/test/sass/templates/bork4.sass +0 -2
  203. data/test/sass/templates/bork5.sass +0 -3
  204. data/test/sass/templates/cached_import_option.scss +0 -3
  205. data/test/sass/templates/compact.sass +0 -17
  206. data/test/sass/templates/complex.sass +0 -305
  207. data/test/sass/templates/compressed.sass +0 -15
  208. data/test/sass/templates/double_import_loop1.sass +0 -1
  209. data/test/sass/templates/expanded.sass +0 -17
  210. data/test/sass/templates/filename_fn.scss +0 -18
  211. data/test/sass/templates/if.sass +0 -11
  212. data/test/sass/templates/import.sass +0 -12
  213. data/test/sass/templates/import_charset.sass +0 -9
  214. data/test/sass/templates/import_charset_1_8.sass +0 -6
  215. data/test/sass/templates/import_charset_ibm866.sass +0 -11
  216. data/test/sass/templates/import_content.sass +0 -4
  217. data/test/sass/templates/importee.less +0 -2
  218. data/test/sass/templates/importee.sass +0 -19
  219. data/test/sass/templates/line_numbers.sass +0 -13
  220. data/test/sass/templates/mixin_bork.sass +0 -5
  221. data/test/sass/templates/mixins.sass +0 -76
  222. data/test/sass/templates/multiline.sass +0 -20
  223. data/test/sass/templates/nested.sass +0 -25
  224. data/test/sass/templates/nested_bork1.sass +0 -2
  225. data/test/sass/templates/nested_bork2.sass +0 -2
  226. data/test/sass/templates/nested_bork3.sass +0 -2
  227. data/test/sass/templates/nested_bork4.sass +0 -2
  228. data/test/sass/templates/nested_import.sass +0 -2
  229. data/test/sass/templates/nested_mixin_bork.sass +0 -6
  230. data/test/sass/templates/options.sass +0 -2
  231. data/test/sass/templates/parent_ref.sass +0 -25
  232. data/test/sass/templates/same_name_different_ext.sass +0 -2
  233. data/test/sass/templates/same_name_different_ext.scss +0 -1
  234. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  235. data/test/sass/templates/script.sass +0 -101
  236. data/test/sass/templates/scss_import.scss +0 -11
  237. data/test/sass/templates/scss_importee.scss +0 -1
  238. data/test/sass/templates/single_import_loop.sass +0 -1
  239. data/test/sass/templates/subdir/import_up1.scss +0 -1
  240. data/test/sass/templates/subdir/import_up2.scss +0 -1
  241. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  242. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  243. data/test/sass/templates/subdir/subdir.sass +0 -6
  244. data/test/sass/templates/units.sass +0 -11
  245. data/test/sass/templates/warn.sass +0 -3
  246. data/test/sass/templates/warn_imported.sass +0 -4
  247. data/test/sass/test_helper.rb +0 -8
  248. data/test/sass/util/multibyte_string_scanner_test.rb +0 -147
  249. data/test/sass/util/subset_map_test.rb +0 -91
  250. data/test/sass/util_test.rb +0 -382
  251. data/test/test_helper.rb +0 -80
  252. /data/{test/sass/results/warn.css → template/files/.gitkeep} +0 -0
@@ -1,1760 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../test_helper'
3
-
4
- class ConversionTest < Test::Unit::TestCase
5
- def test_basic
6
- assert_renders <<SASS, <<SCSS
7
- foo bar
8
- baz: bang
9
- bip: bop
10
- SASS
11
- foo bar {
12
- baz: bang;
13
- bip: bop;
14
- }
15
- SCSS
16
- assert_renders <<SASS, <<SCSS, :old => true
17
- foo bar
18
- :baz bang
19
- :bip bop
20
- SASS
21
- foo bar {
22
- baz: bang;
23
- bip: bop;
24
- }
25
- SCSS
26
- end
27
-
28
- def test_empty_selector
29
- assert_renders "foo bar", "foo bar {}"
30
- end
31
-
32
- def test_empty_directive
33
- assert_scss_to_sass "@media screen", "@media screen {}"
34
- assert_scss_to_scss "@media screen {}"
35
- end
36
-
37
- def test_empty_control_directive
38
- assert_renders "@if false", "@if false {}"
39
- end
40
-
41
- def test_nesting
42
- assert_renders <<SASS, <<SCSS
43
- foo bar
44
- baz bang
45
- baz: bang
46
- bip: bop
47
- blat: boo
48
- SASS
49
- foo bar {
50
- baz bang {
51
- baz: bang;
52
- bip: bop;
53
- }
54
- blat: boo;
55
- }
56
- SCSS
57
- end
58
-
59
- def test_nesting_with_parent_ref
60
- assert_renders <<SASS, <<SCSS
61
- foo bar
62
- &:hover
63
- baz: bang
64
- SASS
65
- foo bar {
66
- &:hover {
67
- baz: bang;
68
- }
69
- }
70
- SCSS
71
- end
72
-
73
- def test_selector_interpolation
74
- assert_renders <<SASS, <<SCSS
75
- foo \#{$bar + "baz"}.bip
76
- baz: bang
77
-
78
- foo /\#{$bar + "baz"}/ .bip
79
- baz: bang
80
- SASS
81
- foo \#{$bar + "baz"}.bip {
82
- baz: bang;
83
- }
84
-
85
- foo /\#{$bar + "baz"}/ .bip {
86
- baz: bang;
87
- }
88
- SCSS
89
- end
90
-
91
- def test_multiline_selector_with_commas
92
- assert_renders <<SASS, <<SCSS
93
- foo bar,
94
- baz bang
95
- baz: bang
96
- SASS
97
- foo bar,
98
- baz bang {
99
- baz: bang;
100
- }
101
- SCSS
102
-
103
- assert_renders <<SASS, <<SCSS
104
- blat
105
- foo bar,
106
- baz bang
107
- baz: bang
108
- SASS
109
- blat {
110
- foo bar,
111
- baz bang {
112
- baz: bang;
113
- }
114
- }
115
- SCSS
116
- end
117
-
118
- def test_multiline_selector_without_commas
119
- assert_scss_to_sass <<SASS, <<SCSS
120
- foo bar baz bang
121
- baz: bang
122
- SASS
123
- foo bar
124
- baz bang {
125
- baz: bang;
126
- }
127
- SCSS
128
-
129
- assert_scss_to_scss <<SCSS
130
- foo bar
131
- baz bang {
132
- baz: bang;
133
- }
134
- SCSS
135
- end
136
-
137
- def test_escaped_selector
138
- assert_renders <<SASS, <<SCSS
139
- foo bar
140
- \\:hover
141
- baz: bang
142
- SASS
143
- foo bar {
144
- :hover {
145
- baz: bang;
146
- }
147
- }
148
- SCSS
149
- end
150
-
151
- def test_property_name_interpolation
152
- assert_renders <<SASS, <<SCSS
153
- foo bar
154
- baz\#{$bang}bip\#{$bop}: 12
155
- SASS
156
- foo bar {
157
- baz\#{$bang}bip\#{$bop}: 12;
158
- }
159
- SCSS
160
- end
161
-
162
- def test_property_value_interpolation
163
- assert_renders <<SASS, <<SCSS
164
- foo bar
165
- baz: 12 \#{$bang} bip \#{"bop"} blat
166
- SASS
167
- foo bar {
168
- baz: 12 \#{$bang} bip \#{"bop"} blat;
169
- }
170
- SCSS
171
- end
172
-
173
- def test_dynamic_properties
174
- assert_renders <<SASS, <<SCSS
175
- foo bar
176
- baz: 12 $bang "bip"
177
- SASS
178
- foo bar {
179
- baz: 12 $bang "bip";
180
- }
181
- SCSS
182
- end
183
-
184
- def test_dynamic_properties_with_old
185
- assert_renders <<SASS, <<SCSS, :old => true
186
- foo bar
187
- :baz 12 $bang "bip"
188
- SASS
189
- foo bar {
190
- baz: 12 $bang "bip";
191
- }
192
- SCSS
193
- end
194
-
195
- def test_multiline_properties
196
- assert_scss_to_sass <<SASS, <<SCSS
197
- foo bar
198
- baz: bip bam boon
199
- SASS
200
- foo bar {
201
- baz:
202
- bip
203
- bam
204
- boon;
205
- }
206
- SCSS
207
-
208
- assert_scss_to_scss <<OUT, <<IN
209
- foo bar {
210
- baz: bip bam boon;
211
- }
212
- OUT
213
- foo bar {
214
- baz:
215
- bip
216
- bam
217
- boon;
218
- }
219
- IN
220
- end
221
-
222
- def test_multiline_dynamic_properties
223
- assert_scss_to_sass <<SASS, <<SCSS
224
- foo bar
225
- baz: $bip "bam" 12px
226
- SASS
227
- foo bar {
228
- baz:
229
- $bip
230
- "bam"
231
- 12px;
232
- }
233
- SCSS
234
-
235
- assert_scss_to_scss <<OUT, <<IN
236
- foo bar {
237
- baz: $bip "bam" 12px;
238
- }
239
- OUT
240
- foo bar {
241
- baz:
242
- $bip
243
- "bam"
244
- 12px;
245
- }
246
- IN
247
- end
248
-
249
- def test_silent_comments
250
- assert_renders <<SASS, <<SCSS
251
- // foo
252
-
253
- // bar
254
-
255
- // baz
256
-
257
- foo bar
258
- a: b
259
- SASS
260
- // foo
261
-
262
- // bar
263
-
264
- // baz
265
-
266
- foo bar {
267
- a: b;
268
- }
269
- SCSS
270
-
271
- assert_renders <<SASS, <<SCSS
272
- // foo
273
- // bar
274
- // baz
275
- // bang
276
-
277
- foo bar
278
- a: b
279
- SASS
280
- // foo
281
- // bar
282
- // baz
283
- // bang
284
-
285
- foo bar {
286
- a: b;
287
- }
288
- SCSS
289
-
290
- assert_sass_to_scss <<SCSS, <<SASS
291
- // foo
292
- // bar
293
- // baz
294
- // bang
295
-
296
- foo bar {
297
- a: b;
298
- }
299
- SCSS
300
- // foo
301
- // bar
302
- // baz
303
- // bang
304
-
305
- foo bar
306
- a: b
307
- SASS
308
- end
309
-
310
- def test_nested_silent_comments
311
- assert_renders <<SASS, <<SCSS
312
- foo
313
- bar: baz
314
- // bip bop
315
- // beep boop
316
- bang: bizz
317
- // bubble bubble
318
- // toil trouble
319
- SASS
320
- foo {
321
- bar: baz;
322
- // bip bop
323
- // beep boop
324
- bang: bizz;
325
- // bubble bubble
326
- // toil trouble
327
- }
328
- SCSS
329
-
330
- assert_sass_to_scss <<SCSS, <<SASS
331
- foo {
332
- bar: baz;
333
- // bip bop
334
- // beep boop
335
- // bap blimp
336
- bang: bizz;
337
- // bubble bubble
338
- // toil trouble
339
- // gorp
340
- }
341
- SCSS
342
- foo
343
- bar: baz
344
- // bip bop
345
- beep boop
346
- bap blimp
347
- bang: bizz
348
- // bubble bubble
349
- toil trouble
350
- gorp
351
- SASS
352
- end
353
-
354
- def test_loud_comments
355
- assert_renders <<SASS, <<SCSS
356
- /* foo
357
-
358
- /* bar
359
-
360
- /* baz
361
-
362
- foo bar
363
- a: b
364
- SASS
365
- /* foo */
366
-
367
- /* bar */
368
-
369
- /* baz */
370
-
371
- foo bar {
372
- a: b;
373
- }
374
- SCSS
375
-
376
- assert_scss_to_sass <<SASS, <<SCSS
377
- /* foo
378
- * bar
379
- * baz
380
- * bang
381
-
382
- foo bar
383
- a: b
384
- SASS
385
- /* foo
386
- bar
387
- baz
388
- bang */
389
-
390
- foo bar {
391
- a: b;
392
- }
393
- SCSS
394
-
395
- assert_scss_to_scss <<SCSS
396
- /* foo
397
- bar
398
- baz
399
- bang */
400
-
401
- foo bar {
402
- a: b;
403
- }
404
- SCSS
405
-
406
- assert_renders <<SASS, <<SCSS
407
- /* foo
408
- * bar
409
- * baz
410
- * bang
411
-
412
- foo bar
413
- a: b
414
- SASS
415
- /* foo
416
- * bar
417
- * baz
418
- * bang */
419
-
420
- foo bar {
421
- a: b;
422
- }
423
- SCSS
424
- end
425
-
426
- def test_nested_loud_comments
427
- assert_renders <<SASS, <<SCSS
428
- foo
429
- bar: baz
430
- /* bip bop
431
- * beep boop
432
- bang: bizz
433
- /* bubble bubble
434
- * toil trouble
435
- SASS
436
- foo {
437
- bar: baz;
438
- /* bip bop
439
- * beep boop */
440
- bang: bizz;
441
- /* bubble bubble
442
- * toil trouble */
443
- }
444
- SCSS
445
-
446
- assert_sass_to_scss <<SCSS, <<SASS
447
- foo {
448
- bar: baz;
449
- /* bip bop
450
- * beep boop
451
- * bap blimp */
452
- bang: bizz;
453
- /* bubble bubble
454
- * toil trouble
455
- * gorp */
456
- }
457
- SCSS
458
- foo
459
- bar: baz
460
- /* bip bop
461
- beep boop
462
- bap blimp
463
- bang: bizz
464
- /* bubble bubble
465
- toil trouble
466
- gorp
467
- SASS
468
- end
469
-
470
- def test_loud_comments_with_weird_indentation
471
- assert_scss_to_sass <<SASS, <<SCSS
472
- foo
473
- /* foo
474
- * bar
475
- * baz
476
- a: b
477
- SASS
478
- foo {
479
- /* foo
480
- bar
481
- baz */
482
- a: b;
483
- }
484
- SCSS
485
-
486
- assert_sass_to_scss <<SCSS, <<SASS
487
- foo {
488
- /* foo
489
- * bar
490
- * baz */
491
- a: b;
492
- }
493
- SCSS
494
- foo
495
- /* foo
496
- bar
497
- baz
498
- a: b
499
- SASS
500
- end
501
-
502
- def test_immediately_preceding_comments
503
- assert_renders <<SASS, <<SCSS
504
- /* Foo
505
- * Bar
506
- * Baz
507
- .foo#bar
508
- a: b
509
- SASS
510
- /* Foo
511
- * Bar
512
- * Baz */
513
- .foo#bar {
514
- a: b;
515
- }
516
- SCSS
517
-
518
- assert_renders <<SASS, <<SCSS
519
- // Foo
520
- // Bar
521
- // Baz
522
- =foo
523
- a: b
524
- SASS
525
- // Foo
526
- // Bar
527
- // Baz
528
- @mixin foo {
529
- a: b;
530
- }
531
- SCSS
532
- end
533
-
534
- def test_debug
535
- assert_renders <<SASS, <<SCSS
536
- foo
537
- @debug 12px
538
- bar: baz
539
- SASS
540
- foo {
541
- @debug 12px;
542
- bar: baz;
543
- }
544
- SCSS
545
- end
546
-
547
- def test_directive_without_children
548
- assert_renders <<SASS, <<SCSS
549
- foo
550
- @foo #bar "baz"
551
- bar: baz
552
- SASS
553
- foo {
554
- @foo #bar "baz";
555
- bar: baz;
556
- }
557
- SCSS
558
- end
559
-
560
- def test_directive_with_prop_children
561
- assert_renders <<SASS, <<SCSS
562
- foo
563
- @foo #bar "baz"
564
- a: b
565
- c: d
566
-
567
- bar: baz
568
- SASS
569
- foo {
570
- @foo #bar "baz" {
571
- a: b;
572
- c: d;
573
- }
574
-
575
- bar: baz;
576
- }
577
- SCSS
578
- end
579
-
580
- def test_directive_with_rule_children
581
- assert_renders <<SASS, <<SCSS
582
- foo
583
- @foo #bar "baz"
584
- #blat
585
- a: b
586
- .bang
587
- c: d
588
- e: f
589
-
590
- bar: baz
591
- SASS
592
- foo {
593
- @foo #bar "baz" {
594
- #blat {
595
- a: b;
596
- }
597
- .bang {
598
- c: d;
599
- e: f;
600
- }
601
- }
602
-
603
- bar: baz;
604
- }
605
- SCSS
606
- end
607
-
608
- def test_directive_with_rule_and_prop_children
609
- assert_renders <<SASS, <<SCSS
610
- foo
611
- @foo #bar "baz"
612
- g: h
613
- #blat
614
- a: b
615
- .bang
616
- c: d
617
- e: f
618
- i: j
619
-
620
- bar: baz
621
- SASS
622
- foo {
623
- @foo #bar "baz" {
624
- g: h;
625
- #blat {
626
- a: b;
627
- }
628
- .bang {
629
- c: d;
630
- e: f;
631
- }
632
- i: j;
633
- }
634
-
635
- bar: baz;
636
- }
637
- SCSS
638
- end
639
-
640
- def test_charset
641
- assert_renders <<SASS, <<SCSS
642
- @charset "utf-8"
643
- SASS
644
- @charset "utf-8";
645
- SCSS
646
- end
647
-
648
- def test_for
649
- assert_renders <<SASS, <<SCSS
650
- foo
651
- @for $a from $b to $c
652
- a: b
653
- @for $c from 1 to 16
654
- d: e
655
- f: g
656
- SASS
657
- foo {
658
- @for $a from $b to $c {
659
- a: b;
660
- }
661
- @for $c from 1 to 16 {
662
- d: e;
663
- f: g;
664
- }
665
- }
666
- SCSS
667
- end
668
-
669
- def test_while
670
- assert_renders <<SASS, <<SCSS
671
- foo
672
- @while flaz($a + $b)
673
- a: b
674
- @while 1
675
- d: e
676
- f: g
677
- SASS
678
- foo {
679
- @while flaz($a + $b) {
680
- a: b;
681
- }
682
- @while 1 {
683
- d: e;
684
- f: g;
685
- }
686
- }
687
- SCSS
688
- end
689
-
690
- def test_if
691
- assert_renders <<SASS, <<SCSS
692
- foo
693
- @if $foo or $bar
694
- a: b
695
- @if $baz
696
- d: e
697
- @else if $bang
698
- f: g
699
- @else
700
- h: i
701
- SASS
702
- foo {
703
- @if $foo or $bar {
704
- a: b;
705
- }
706
- @if $baz {
707
- d: e;
708
- }
709
- @else if $bang {
710
- f: g;
711
- }
712
- @else {
713
- h: i;
714
- }
715
- }
716
- SCSS
717
- end
718
-
719
- def test_each
720
- assert_renders <<SASS, <<SCSS
721
- a
722
- @each $number in 1px 2px 3px 4px
723
- b: $number
724
-
725
- c
726
- @each $str in foo, bar, baz, bang
727
- d: $str
728
- SASS
729
- a {
730
- @each $number in 1px 2px 3px 4px {
731
- b: $number;
732
- }
733
- }
734
-
735
- c {
736
- @each $str in foo, bar, baz, bang {
737
- d: $str;
738
- }
739
- }
740
- SCSS
741
- end
742
-
743
- def test_import
744
- assert_renders <<SASS, <<SCSS
745
- @import foo
746
-
747
- @import url(bar.css)
748
-
749
- foo
750
- bar: baz
751
- SASS
752
- @import "foo";
753
-
754
- @import url(bar.css);
755
-
756
- foo {
757
- bar: baz;
758
- }
759
- SCSS
760
-
761
- assert_renders <<SASS, <<SCSS
762
- @import foo.css
763
-
764
- @import url(bar.css)
765
-
766
- foo
767
- bar: baz
768
- SASS
769
- @import "foo.css";
770
-
771
- @import url(bar.css);
772
-
773
- foo {
774
- bar: baz;
775
- }
776
- SCSS
777
- end
778
-
779
- def test_import_as_directive_in_sass
780
- assert_equal "@import foo.css\n", to_sass('@import "foo.css"')
781
- end
782
-
783
- def test_import_as_directive_in_scss
784
- assert_renders <<SASS, <<SCSS
785
- @import "foo.css" print
786
- SASS
787
- @import "foo.css" print;
788
- SCSS
789
-
790
- assert_renders <<SASS, <<SCSS
791
- @import url(foo.css) screen, print
792
- SASS
793
- @import url(foo.css) screen, print;
794
- SCSS
795
- end
796
-
797
- def test_adjacent_imports
798
- assert_renders <<SASS, <<SCSS
799
- @import foo.sass
800
- @import bar.scss
801
- @import baz
802
- SASS
803
- @import "foo.sass";
804
- @import "bar.scss";
805
- @import "baz";
806
- SCSS
807
- end
808
-
809
- def test_non_adjacent_imports
810
- assert_renders <<SASS, <<SCSS
811
- @import foo.sass
812
-
813
- @import bar.scss
814
-
815
- @import baz
816
- SASS
817
- @import "foo.sass";
818
-
819
- @import "bar.scss";
820
-
821
- @import "baz";
822
- SCSS
823
- end
824
-
825
- def test_import_with_interpolation
826
- assert_renders <<SASS, <<SCSS
827
- $family: unquote("Droid+Sans")
828
-
829
- @import url("http://fonts.googleapis.com/css?family=\#{$family}")
830
- SASS
831
- $family: unquote("Droid+Sans");
832
-
833
- @import url("http://fonts.googleapis.com/css?family=\#{$family}");
834
- SCSS
835
- end
836
-
837
- def test_extend
838
- assert_renders <<SASS, <<SCSS
839
- .foo
840
- @extend .bar
841
- @extend .baz:bang
842
- SASS
843
- .foo {
844
- @extend .bar;
845
- @extend .baz:bang;
846
- }
847
- SCSS
848
- end
849
-
850
- def test_comma_extendee
851
- assert_renders <<SASS, <<SCSS
852
- .baz
853
- @extend .foo, .bar
854
- SASS
855
- .baz {
856
- @extend .foo, .bar;
857
- }
858
- SCSS
859
- end
860
-
861
- def test_argless_mixin_definition
862
- assert_renders <<SASS, <<SCSS
863
- =foo-bar
864
- baz
865
- a: b
866
- SASS
867
- @mixin foo-bar {
868
- baz {
869
- a: b;
870
- }
871
- }
872
- SCSS
873
-
874
- assert_scss_to_sass <<SASS, <<SCSS
875
- =foo-bar
876
- baz
877
- a: b
878
- SASS
879
- @mixin foo-bar() {
880
- baz {
881
- a: b;
882
- }
883
- }
884
- SCSS
885
-
886
- assert_sass_to_scss <<SCSS, <<SASS
887
- @mixin foo-bar {
888
- baz {
889
- a: b;
890
- }
891
- }
892
- SCSS
893
- =foo-bar()
894
- baz
895
- a: b
896
- SASS
897
- end
898
-
899
- def test_mixin_definition_without_defaults
900
- assert_renders <<SASS, <<SCSS
901
- =foo-bar($baz, $bang)
902
- baz
903
- a: $baz $bang
904
- SASS
905
- @mixin foo-bar($baz, $bang) {
906
- baz {
907
- a: $baz $bang;
908
- }
909
- }
910
- SCSS
911
- end
912
-
913
- def test_mixin_definition_with_defaults
914
- assert_renders <<SASS, <<SCSS
915
- =foo-bar($baz, $bang: 12px)
916
- baz
917
- a: $baz $bang
918
- SASS
919
- @mixin foo-bar($baz, $bang: 12px) {
920
- baz {
921
- a: $baz $bang;
922
- }
923
- }
924
- SCSS
925
-
926
- assert_sass_to_scss <<SCSS, <<SASS
927
- @mixin foo-bar($baz, $bang: foo) {
928
- baz {
929
- a: $baz $bang;
930
- }
931
- }
932
- SCSS
933
- =foo-bar($baz, $bang: foo)
934
- baz
935
- a: $baz $bang
936
- SASS
937
- end
938
-
939
- def test_argless_mixin_include
940
- assert_renders <<SASS, <<SCSS
941
- foo
942
- +foo-bar
943
- a: blip
944
- SASS
945
- foo {
946
- @include foo-bar;
947
- a: blip;
948
- }
949
- SCSS
950
- end
951
-
952
- def test_mixin_include
953
- assert_renders <<SASS, <<SCSS
954
- foo
955
- +foo-bar(12px, "blaz")
956
- a: blip
957
- SASS
958
- foo {
959
- @include foo-bar(12px, "blaz");
960
- a: blip;
961
- }
962
- SCSS
963
- end
964
-
965
- def test_mixin_include_with_keyword_args
966
- assert_renders <<SASS, <<SCSS
967
- foo
968
- +foo-bar(12px, "blaz", $blip: blap, $bloop: blop)
969
- +foo-bar($blip: blap, $bloop: blop)
970
- a: blip
971
- SASS
972
- foo {
973
- @include foo-bar(12px, "blaz", $blip: blap, $bloop: blop);
974
- @include foo-bar($blip: blap, $bloop: blop);
975
- a: blip;
976
- }
977
- SCSS
978
- end
979
-
980
- def test_argless_function_definition
981
- assert_renders <<SASS, <<SCSS
982
- @function foo()
983
- $var: 1 + 1
984
- @return $var
985
- SASS
986
- @function foo() {
987
- $var: 1 + 1;
988
- @return $var;
989
- }
990
- SCSS
991
- end
992
-
993
- def test_function_definition_without_defaults
994
- assert_renders <<SASS, <<SCSS
995
- @function foo($var1, $var2)
996
- @if $var1
997
- @return $var1 + $var2
998
- SASS
999
- @function foo($var1, $var2) {
1000
- @if $var1 {
1001
- @return $var1 + $var2;
1002
- }
1003
- }
1004
- SCSS
1005
- end
1006
-
1007
- def test_function_definition_with_defaults
1008
- assert_renders <<SASS, <<SCSS
1009
- @function foo($var1, $var2: foo)
1010
- @if $var1
1011
- @return $var1 + $var2
1012
- SASS
1013
- @function foo($var1, $var2: foo) {
1014
- @if $var1 {
1015
- @return $var1 + $var2;
1016
- }
1017
- }
1018
- SCSS
1019
- end
1020
-
1021
- def test_variable_definition
1022
- assert_renders <<SASS, <<SCSS
1023
- $var1: 12px + 15px
1024
-
1025
- foo
1026
- $var2: flaz(#abcdef)
1027
- val: $var1 $var2
1028
- SASS
1029
- $var1: 12px + 15px;
1030
-
1031
- foo {
1032
- $var2: flaz(#abcdef);
1033
- val: $var1 $var2;
1034
- }
1035
- SCSS
1036
- end
1037
-
1038
- def test_guarded_variable_definition
1039
- assert_renders <<SASS, <<SCSS
1040
- $var1: 12px + 15px !default
1041
-
1042
- foo
1043
- $var2: flaz(#abcdef) !default
1044
- val: $var1 $var2
1045
- SASS
1046
- $var1: 12px + 15px !default;
1047
-
1048
- foo {
1049
- $var2: flaz(#abcdef) !default;
1050
- val: $var1 $var2;
1051
- }
1052
- SCSS
1053
- end
1054
-
1055
- def test_multiple_variable_definitions
1056
- assert_renders <<SASS, <<SCSS
1057
- $var1: foo
1058
- $var2: bar
1059
- $var3: baz
1060
-
1061
- $var4: bip
1062
- $var5: bap
1063
- SASS
1064
- $var1: foo;
1065
- $var2: bar;
1066
- $var3: baz;
1067
-
1068
- $var4: bip;
1069
- $var5: bap;
1070
- SCSS
1071
- end
1072
-
1073
- def test_division_asserted_with_parens
1074
- assert_renders <<SASS, <<SCSS
1075
- foo
1076
- a: (1px / 2px)
1077
- SASS
1078
- foo {
1079
- a: (1px / 2px);
1080
- }
1081
- SCSS
1082
- end
1083
-
1084
- def test_division_not_asserted_when_unnecessary
1085
- assert_renders <<SASS, <<SCSS
1086
- $var: 1px / 2px
1087
-
1088
- foo
1089
- a: $var
1090
- SASS
1091
- $var: 1px / 2px;
1092
-
1093
- foo {
1094
- a: $var;
1095
- }
1096
- SCSS
1097
-
1098
- assert_renders <<SASS, <<SCSS
1099
- $var: 1px
1100
-
1101
- foo
1102
- a: $var / 2px
1103
- SASS
1104
- $var: 1px;
1105
-
1106
- foo {
1107
- a: $var / 2px;
1108
- }
1109
- SCSS
1110
-
1111
- assert_renders <<SASS, <<SCSS
1112
- foo
1113
- a: 1 + 1px / 2px
1114
- SASS
1115
- foo {
1116
- a: 1 + 1px / 2px;
1117
- }
1118
- SCSS
1119
- end
1120
-
1121
- def test_literal_slash
1122
- assert_renders <<SASS, <<SCSS
1123
- foo
1124
- a: 1px / 2px
1125
- SASS
1126
- foo {
1127
- a: 1px / 2px;
1128
- }
1129
- SCSS
1130
- end
1131
-
1132
- def test_directive_with_interpolation
1133
- assert_renders <<SASS, <<SCSS
1134
- $baz: 12
1135
-
1136
- @foo bar\#{$baz} qux
1137
- a: b
1138
- SASS
1139
- $baz: 12;
1140
-
1141
- @foo bar\#{$baz} qux {
1142
- a: b;
1143
- }
1144
- SCSS
1145
- end
1146
-
1147
- def test_media_with_interpolation
1148
- assert_renders <<SASS, <<SCSS
1149
- $baz: 12
1150
-
1151
- @media bar\#{$baz}
1152
- a: b
1153
- SASS
1154
- $baz: 12;
1155
-
1156
- @media bar\#{$baz} {
1157
- a: b;
1158
- }
1159
- SCSS
1160
- end
1161
-
1162
- def test_media_with_expressions
1163
- assert_sass_to_scss <<SCSS, <<SASS
1164
- $media1: screen;
1165
- $media2: print;
1166
- $var: -webkit-min-device-pixel-ratio;
1167
- $val: 20;
1168
-
1169
- @media \#{$media1} and ($var + "-foo": $val + 5), only \#{$media2} {
1170
- a: b;
1171
- }
1172
- SCSS
1173
- $media1: screen
1174
- $media2: print
1175
- $var: -webkit-min-device-pixel-ratio
1176
- $val: 20
1177
-
1178
- @media \#{$media1} and ($var + "-foo": $val + 5), only \#{$media2}
1179
- a: b
1180
- SASS
1181
-
1182
- assert_scss_to_sass <<SASS, <<SCSS
1183
- $media1: screen
1184
- $media2: print
1185
- $var: -webkit-min-device-pixel-ratio
1186
- $val: 20
1187
-
1188
- @media \#{$media1} and ($var + "-foo": $val + 5), only \#{$media2}
1189
- a: b
1190
- SASS
1191
- $media1: screen;
1192
- $media2: print;
1193
- $var: -webkit-min-device-pixel-ratio;
1194
- $val: 20;
1195
-
1196
- @media \#{$media1} and ($var + "-foo": $val + 5), only \#{$media2} {
1197
- a: b;
1198
- }
1199
- SCSS
1200
- end
1201
-
1202
- def test_supports_with_expressions
1203
- assert_renders <<SASS, <<SCSS
1204
- $query: "(feature1: val)"
1205
- $feature: feature2
1206
- $val: val
1207
-
1208
- @supports \#{$query} and ($feature: $val) or (not ($feature + 3: $val + 4))
1209
- foo
1210
- a: b
1211
- SASS
1212
- $query: "(feature1: val)";
1213
- $feature: feature2;
1214
- $val: val;
1215
-
1216
- @supports \#{$query} and ($feature: $val) or (not ($feature + 3: $val + 4)) {
1217
- foo {
1218
- a: b;
1219
- }
1220
- }
1221
- SCSS
1222
- end
1223
-
1224
- # Hacks
1225
-
1226
- def test_declaration_hacks
1227
- assert_renders <<SASS, <<SCSS
1228
- foo
1229
- _name: val
1230
- *name: val
1231
- #name: val
1232
- .name: val
1233
- name/**/: val
1234
- name/*\\**/: val
1235
- name: val
1236
- SASS
1237
- foo {
1238
- _name: val;
1239
- *name: val;
1240
- #name: val;
1241
- .name: val;
1242
- name/**/: val;
1243
- name/*\\**/: val;
1244
- name: val;
1245
- }
1246
- SCSS
1247
- end
1248
-
1249
- def test_old_declaration_hacks
1250
- assert_renders <<SASS, <<SCSS, :old => true
1251
- foo
1252
- :_name val
1253
- :*name val
1254
- :#name val
1255
- :.name val
1256
- :name val
1257
- SASS
1258
- foo {
1259
- _name: val;
1260
- *name: val;
1261
- #name: val;
1262
- .name: val;
1263
- name: val;
1264
- }
1265
- SCSS
1266
- end
1267
-
1268
- def test_selector_hacks
1269
- assert_selector_renders = lambda do |s|
1270
- assert_renders <<SASS, <<SCSS
1271
- #{s}
1272
- a: b
1273
- SASS
1274
- #{s} {
1275
- a: b;
1276
- }
1277
- SCSS
1278
- end
1279
-
1280
- assert_selector_renders['> E']
1281
- assert_selector_renders['+ E']
1282
- assert_selector_renders['~ E']
1283
- assert_selector_renders['> > E']
1284
-
1285
- assert_selector_renders['E*']
1286
- assert_selector_renders['E*.foo']
1287
- assert_selector_renders['E*:hover']
1288
- end
1289
-
1290
- def test_disallowed_colon_hack
1291
- assert_raise_message(Sass::SyntaxError, 'The ":name: val" hack is not allowed in the Sass indented syntax') do
1292
- to_sass("foo {:name: val;}", :syntax => :scss)
1293
- end
1294
- end
1295
-
1296
- def test_nested_properties
1297
- assert_renders <<SASS, <<SCSS
1298
- div
1299
- before: before
1300
- background:
1301
- color: blue
1302
- repeat: no-repeat
1303
- after: after
1304
- SASS
1305
- div {
1306
- before: before;
1307
- background: {
1308
- color: blue;
1309
- repeat: no-repeat;
1310
- };
1311
- after: after;
1312
- }
1313
-
1314
- SCSS
1315
- end
1316
-
1317
- def test_dasherize
1318
- assert_sass_to_scss(<<SCSS, <<SASS, :dasherize => true)
1319
- @mixin under-scored-mixin($under-scored-arg: $under-scored-default) {
1320
- bar: $under-scored-arg;
1321
- }
1322
-
1323
- div {
1324
- foo: under-scored-fn($under-scored-var + "before\#{$another-under-scored-var}after");
1325
- @include under-scored-mixin($passed-arg);
1326
- selector-\#{$under-scored-interp}: bold;
1327
- }
1328
-
1329
- @if $under-scored {
1330
- @for $for-var from $from-var to $to-var {
1331
- @while $while-var == true {
1332
- $while-var: false;
1333
- }
1334
- }
1335
- }
1336
- SCSS
1337
- =under_scored_mixin($under_scored_arg: $under_scored_default)
1338
- bar: $under_scored_arg
1339
- div
1340
- foo: under_scored_fn($under_scored_var + "before\#{$another_under_scored_var}after")
1341
- +under_scored_mixin($passed_arg)
1342
- selector-\#{$under_scored_interp}: bold
1343
- @if $under_scored
1344
- @for $for_var from $from_var to $to_var
1345
- @while $while_var == true
1346
- $while_var : false
1347
- SASS
1348
- end
1349
-
1350
- def test_loud_comment_conversion
1351
- assert_renders(<<SASS, <<SCSS)
1352
- /*! \#{"interpolated"}
1353
- SASS
1354
- /*! \#{"interpolated"} */
1355
- SCSS
1356
- end
1357
-
1358
- def test_content_conversion
1359
- assert_renders(<<SASS, <<SCSS)
1360
- $color: blue
1361
-
1362
- =context($class, $color: red)
1363
- .\#{$class}
1364
- background-color: $color
1365
- @content
1366
- border-color: $color
1367
-
1368
- +context(parent)
1369
- +context(child, $color: yellow)
1370
- color: $color
1371
- SASS
1372
- $color: blue;
1373
-
1374
- @mixin context($class, $color: red) {
1375
- .\#{$class} {
1376
- background-color: $color;
1377
- @content;
1378
- border-color: $color;
1379
- }
1380
- }
1381
-
1382
- @include context(parent) {
1383
- @include context(child, $color: yellow) {
1384
- color: $color;
1385
- }
1386
- }
1387
- SCSS
1388
-
1389
- end
1390
-
1391
- def test_empty_content
1392
- assert_scss_to_scss(<<SCSS)
1393
- @mixin foo {
1394
- @content;
1395
- }
1396
-
1397
- @include foo {}
1398
- SCSS
1399
- end
1400
-
1401
- def test_placeholder_conversion
1402
- assert_renders(<<SASS, <<SCSS)
1403
- #content a%foo.bar
1404
- color: blue
1405
- SASS
1406
- #content a%foo.bar {
1407
- color: blue;
1408
- }
1409
- SCSS
1410
- end
1411
-
1412
- def test_reference_selector
1413
- assert_renders(<<SASS, <<SCSS)
1414
- foo /bar|baz/ bang
1415
- a: b
1416
- SASS
1417
- foo /bar|baz/ bang {
1418
- a: b;
1419
- }
1420
- SCSS
1421
- end
1422
-
1423
- def test_subject
1424
- assert_renders(<<SASS, <<SCSS)
1425
- foo bar! baz
1426
- a: b
1427
- SASS
1428
- foo bar! baz {
1429
- a: b;
1430
- }
1431
- SCSS
1432
- end
1433
-
1434
- def test_placeholder_interoplation_conversion
1435
- assert_renders(<<SASS, <<SCSS)
1436
- $foo: foo
1437
-
1438
- %\#{$foo}
1439
- color: blue
1440
-
1441
- .bar
1442
- @extend %foo
1443
- SASS
1444
- $foo: foo;
1445
-
1446
- %\#{$foo} {
1447
- color: blue;
1448
- }
1449
-
1450
- .bar {
1451
- @extend %foo;
1452
- }
1453
- SCSS
1454
- end
1455
-
1456
- def test_indent
1457
- assert_renders <<SASS, <<SCSS, :indent => " "
1458
- foo bar
1459
- baz bang
1460
- baz: bang
1461
- bip: bop
1462
- blat: boo
1463
- SASS
1464
- foo bar {
1465
- baz bang {
1466
- baz: bang;
1467
- bip: bop;
1468
- }
1469
- blat: boo;
1470
- }
1471
- SCSS
1472
-
1473
- assert_renders <<SASS, <<SCSS, :indent => "\t"
1474
- foo bar
1475
- baz bang
1476
- baz: bang
1477
- bip: bop
1478
- blat: boo
1479
- SASS
1480
- foo bar {
1481
- baz bang {
1482
- baz: bang;
1483
- bip: bop;
1484
- }
1485
- blat: boo;
1486
- }
1487
- SCSS
1488
-
1489
- assert_sass_to_scss <<SCSS, <<SASS, :indent => " "
1490
- foo bar {
1491
- baz bang {
1492
- baz: bang;
1493
- bip: bop;
1494
- }
1495
- blat: boo;
1496
- }
1497
- SCSS
1498
- foo bar
1499
- baz bang
1500
- baz: bang
1501
- bip: bop
1502
- blat: boo
1503
- SASS
1504
-
1505
- assert_sass_to_scss <<SCSS, <<SASS, :indent => "\t"
1506
- foo bar {
1507
- baz bang {
1508
- baz: bang;
1509
- bip: bop;
1510
- }
1511
- blat: boo;
1512
- }
1513
- SCSS
1514
- foo bar
1515
- baz bang
1516
- baz: bang
1517
- bip: bop
1518
- blat: boo
1519
- SASS
1520
-
1521
- assert_scss_to_sass <<SASS, <<SCSS, :indent => " "
1522
- foo bar
1523
- baz bang
1524
- baz: bang
1525
- bip: bop
1526
- blat: boo
1527
- SASS
1528
- foo bar {
1529
- baz bang {
1530
- baz: bang;
1531
- bip: bop;
1532
- }
1533
- blat: boo;
1534
- }
1535
- SCSS
1536
-
1537
- assert_scss_to_sass <<SASS, <<SCSS, :indent => "\t"
1538
- foo bar
1539
- baz bang
1540
- baz: bang
1541
- bip: bop
1542
- blat: boo
1543
- SASS
1544
- foo bar {
1545
- baz bang {
1546
- baz: bang;
1547
- bip: bop;
1548
- }
1549
- blat: boo;
1550
- }
1551
- SCSS
1552
- end
1553
-
1554
- def test_extend_with_optional
1555
- assert_scss_to_sass <<SASS, <<SCSS
1556
- foo
1557
- @extend .bar !optional
1558
- SASS
1559
- foo {
1560
- @extend .bar !optional;
1561
- }
1562
- SCSS
1563
- end
1564
-
1565
- def test_mixin_var_args
1566
- assert_scss_to_sass <<SASS, <<SCSS
1567
- =foo($args...)
1568
- a: b
1569
-
1570
- =bar($a, $args...)
1571
- a: b
1572
-
1573
- .foo
1574
- +foo($list...)
1575
- +bar(1, $list...)
1576
- SASS
1577
- @mixin foo($args...) {
1578
- a: b;
1579
- }
1580
-
1581
- @mixin bar($a, $args...) {
1582
- a: b;
1583
- }
1584
-
1585
- .foo {
1586
- @include foo($list...);
1587
- @include bar(1, $list...);
1588
- }
1589
- SCSS
1590
- end
1591
-
1592
- def test_function_var_args
1593
- assert_scss_to_sass <<SASS, <<SCSS
1594
- @function foo($args...)
1595
- @return foo
1596
-
1597
- @function bar($a, $args...)
1598
- @return bar
1599
-
1600
- .foo
1601
- a: foo($list...)
1602
- b: bar(1, $list...)
1603
- SASS
1604
- @function foo($args...) {
1605
- @return foo;
1606
- }
1607
-
1608
- @function bar($a, $args...) {
1609
- @return bar;
1610
- }
1611
-
1612
- .foo {
1613
- a: foo($list...);
1614
- b: bar(1, $list...);
1615
- }
1616
- SCSS
1617
- end
1618
-
1619
- ## Regression Tests
1620
-
1621
- def test_list_in_args
1622
- assert_renders(<<SASS, <<SCSS)
1623
- +mixin((a, b, c))
1624
-
1625
- +mixin($arg: (a, b, c))
1626
-
1627
- +mixin(a, b, (c, d, e)...)
1628
- SASS
1629
- @include mixin((a, b, c));
1630
-
1631
- @include mixin($arg: (a, b, c));
1632
-
1633
- @include mixin(a, b, (c, d, e)...);
1634
- SCSS
1635
- end
1636
-
1637
- def test_media_query_with_expr
1638
- assert_scss_to_sass <<SASS, <<SCSS
1639
- @media foo and (bar: baz)
1640
- a: b
1641
- SASS
1642
- @media foo and (bar: baz) {
1643
- a: b; }
1644
- SCSS
1645
- end
1646
-
1647
- def test_nested_if_statements
1648
- assert_renders(<<SASS, <<SCSS)
1649
- @if $foo
1650
- one
1651
- a: b
1652
- @else
1653
- @if $bar
1654
- two
1655
- a: b
1656
- @else
1657
- three
1658
- a: b
1659
- SASS
1660
- @if $foo {
1661
- one {
1662
- a: b;
1663
- }
1664
- }
1665
- @else {
1666
- @if $bar {
1667
- two {
1668
- a: b;
1669
- }
1670
- }
1671
- @else {
1672
- three {
1673
- a: b;
1674
- }
1675
- }
1676
- }
1677
- SCSS
1678
- end
1679
-
1680
- def test_comment_indentation
1681
- assert_renders(<<SASS, <<SCSS, :indent => ' ')
1682
- foo
1683
- // bar
1684
- /* baz
1685
- a: b
1686
- SASS
1687
- foo {
1688
- // bar
1689
- /* baz */
1690
- a: b;
1691
- }
1692
- SCSS
1693
- end
1694
-
1695
- def test_ambiguous_negation
1696
- assert_renders(<<SASS, <<SCSS, :indent => ' ')
1697
- foo
1698
- ok: -$foo
1699
- comma: 10px, -$foo
1700
- needs-parens: 10px (-$foo)
1701
- no-parens: a 50px + 60px b
1702
- SASS
1703
- foo {
1704
- ok: -$foo;
1705
- comma: 10px, -$foo;
1706
- needs-parens: 10px (-$foo);
1707
- no-parens: a 50px + 60px b;
1708
- }
1709
- SCSS
1710
- end
1711
-
1712
- private
1713
-
1714
- def assert_sass_to_sass(sass, options = {})
1715
- assert_equal(sass.rstrip, to_sass(sass, options).rstrip,
1716
- "Expected Sass to transform to itself")
1717
- end
1718
-
1719
- def assert_scss_to_sass(sass, scss, options = {})
1720
- assert_equal(sass.rstrip, to_sass(scss, options.merge(:syntax => :scss)).rstrip,
1721
- "Expected SCSS to transform to Sass")
1722
- end
1723
-
1724
- def assert_scss_to_scss(scss, in_scss = nil, options = nil)
1725
- if in_scss.is_a?(Hash)
1726
- options = in_scss
1727
- in_scss = nil
1728
- end
1729
-
1730
- in_scss ||= scss
1731
- options ||= {}
1732
-
1733
- assert_equal(scss.rstrip, to_scss(in_scss, options.merge(:syntax => :scss)).rstrip,
1734
- "Expected SCSS to transform to #{scss == in_scss ? 'itself' : 'SCSS'}")
1735
- end
1736
-
1737
- def assert_sass_to_scss(scss, sass, options = {})
1738
- assert_equal(scss.rstrip, to_scss(sass, options).rstrip,
1739
- "Expected Sass to transform to SCSS")
1740
- end
1741
-
1742
- def assert_renders(sass, scss, options = {})
1743
- assert_sass_to_sass(sass, options)
1744
- assert_scss_to_sass(sass, scss, options)
1745
- assert_scss_to_scss(scss, options)
1746
- assert_sass_to_scss(scss, sass, options)
1747
- end
1748
-
1749
- def to_sass(scss, options = {})
1750
- Sass::Util.silence_sass_warnings do
1751
- Sass::Engine.new(scss, options).to_tree.to_sass(options)
1752
- end
1753
- end
1754
-
1755
- def to_scss(sass, options = {})
1756
- Sass::Util.silence_sass_warnings do
1757
- Sass::Engine.new(sass, options).to_tree.to_scss(options)
1758
- end
1759
- end
1760
- end