sass 3.4.25 → 3.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/CODE_OF_CONDUCT.md +1 -1
  3. data/CONTRIBUTING.md +3 -3
  4. data/README.md +17 -9
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/VERSION_NAME +1 -1
  8. data/extra/sass-spec-ref.sh +9 -1
  9. data/lib/sass.rb +0 -7
  10. data/lib/sass/cache_stores/filesystem.rb +1 -1
  11. data/lib/sass/css.rb +1 -2
  12. data/lib/sass/engine.rb +39 -29
  13. data/lib/sass/environment.rb +26 -5
  14. data/lib/sass/error.rb +2 -2
  15. data/lib/sass/exec/base.rb +2 -13
  16. data/lib/sass/exec/sass_scss.rb +1 -5
  17. data/lib/sass/features.rb +1 -0
  18. data/lib/sass/importers/filesystem.rb +6 -4
  19. data/lib/sass/logger/base.rb +11 -0
  20. data/lib/sass/plugin/compiler.rb +20 -50
  21. data/lib/sass/plugin/configuration.rb +2 -2
  22. data/lib/sass/railtie.rb +1 -1
  23. data/lib/sass/script/css_parser.rb +4 -1
  24. data/lib/sass/script/functions.rb +308 -81
  25. data/lib/sass/script/lexer.rb +63 -9
  26. data/lib/sass/script/parser.rb +287 -118
  27. data/lib/sass/script/tree/funcall.rb +35 -34
  28. data/lib/sass/script/tree/interpolation.rb +0 -3
  29. data/lib/sass/script/tree/list_literal.rb +23 -8
  30. data/lib/sass/script/tree/map_literal.rb +2 -2
  31. data/lib/sass/script/tree/node.rb +0 -8
  32. data/lib/sass/script/tree/operation.rb +1 -8
  33. data/lib/sass/script/value.rb +2 -0
  34. data/lib/sass/script/value/arg_list.rb +1 -1
  35. data/lib/sass/script/value/base.rb +17 -0
  36. data/lib/sass/script/value/callable.rb +25 -0
  37. data/lib/sass/script/value/color.rb +8 -2
  38. data/lib/sass/script/value/function.rb +19 -0
  39. data/lib/sass/script/value/helpers.rb +37 -11
  40. data/lib/sass/script/value/list.rb +35 -14
  41. data/lib/sass/script/value/map.rb +2 -2
  42. data/lib/sass/script/value/number.rb +3 -2
  43. data/lib/sass/scss/css_parser.rb +6 -1
  44. data/lib/sass/scss/parser.rb +145 -56
  45. data/lib/sass/scss/rx.rb +5 -11
  46. data/lib/sass/scss/static_parser.rb +20 -42
  47. data/lib/sass/selector.rb +4 -0
  48. data/lib/sass/selector/abstract_sequence.rb +7 -6
  49. data/lib/sass/selector/comma_sequence.rb +9 -5
  50. data/lib/sass/selector/pseudo.rb +20 -3
  51. data/lib/sass/selector/sequence.rb +35 -10
  52. data/lib/sass/selector/simple.rb +9 -2
  53. data/lib/sass/selector/simple_sequence.rb +8 -4
  54. data/lib/sass/source/map.rb +2 -6
  55. data/lib/sass/stack.rb +21 -1
  56. data/lib/sass/tree/charset_node.rb +1 -1
  57. data/lib/sass/tree/prop_node.rb +45 -53
  58. data/lib/sass/tree/rule_node.rb +6 -8
  59. data/lib/sass/tree/visitors/check_nesting.rb +1 -1
  60. data/lib/sass/tree/visitors/convert.rb +2 -3
  61. data/lib/sass/tree/visitors/cssize.rb +4 -15
  62. data/lib/sass/tree/visitors/deep_copy.rb +1 -1
  63. data/lib/sass/tree/visitors/extend.rb +2 -8
  64. data/lib/sass/tree/visitors/perform.rb +23 -15
  65. data/lib/sass/tree/visitors/set_options.rb +1 -1
  66. data/lib/sass/tree/visitors/to_css.rb +49 -22
  67. data/lib/sass/util.rb +72 -310
  68. data/lib/sass/util/multibyte_string_scanner.rb +127 -131
  69. data/lib/sass/util/normalized_map.rb +1 -8
  70. data/lib/sass/version.rb +0 -4
  71. metadata +55 -202
  72. data/Rakefile +0 -453
  73. data/lib/sass/script/css_variable_warning.rb +0 -52
  74. data/lib/sass/util/cross_platform_random.rb +0 -19
  75. data/lib/sass/util/ordered_hash.rb +0 -192
  76. data/test/sass-spec.yml +0 -3
  77. data/test/sass/cache_test.rb +0 -131
  78. data/test/sass/callbacks_test.rb +0 -61
  79. data/test/sass/compiler_test.rb +0 -236
  80. data/test/sass/conversion_test.rb +0 -2188
  81. data/test/sass/css2sass_test.rb +0 -526
  82. data/test/sass/css_variable_test.rb +0 -132
  83. data/test/sass/data/hsl-rgb.txt +0 -319
  84. data/test/sass/encoding_test.rb +0 -219
  85. data/test/sass/engine_test.rb +0 -3447
  86. data/test/sass/exec_test.rb +0 -96
  87. data/test/sass/extend_test.rb +0 -1733
  88. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  89. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  90. data/test/sass/functions_test.rb +0 -1977
  91. data/test/sass/importer_test.rb +0 -421
  92. data/test/sass/logger_test.rb +0 -58
  93. data/test/sass/mock_importer.rb +0 -49
  94. data/test/sass/more_results/more1.css +0 -9
  95. data/test/sass/more_results/more1_with_line_comments.css +0 -26
  96. data/test/sass/more_results/more_import.css +0 -29
  97. data/test/sass/more_templates/_more_partial.sass +0 -2
  98. data/test/sass/more_templates/more1.sass +0 -23
  99. data/test/sass/more_templates/more_import.sass +0 -11
  100. data/test/sass/plugin_test.rb +0 -556
  101. data/test/sass/results/alt.css +0 -4
  102. data/test/sass/results/basic.css +0 -9
  103. data/test/sass/results/cached_import_option.css +0 -3
  104. data/test/sass/results/compact.css +0 -5
  105. data/test/sass/results/complex.css +0 -86
  106. data/test/sass/results/compressed.css +0 -1
  107. data/test/sass/results/expanded.css +0 -19
  108. data/test/sass/results/filename_fn.css +0 -3
  109. data/test/sass/results/if.css +0 -3
  110. data/test/sass/results/import.css +0 -31
  111. data/test/sass/results/import_charset.css +0 -5
  112. data/test/sass/results/import_charset_1_8.css +0 -5
  113. data/test/sass/results/import_charset_ibm866.css +0 -5
  114. data/test/sass/results/import_content.css +0 -1
  115. data/test/sass/results/line_numbers.css +0 -49
  116. data/test/sass/results/mixins.css +0 -95
  117. data/test/sass/results/multiline.css +0 -24
  118. data/test/sass/results/nested.css +0 -22
  119. data/test/sass/results/options.css +0 -1
  120. data/test/sass/results/parent_ref.css +0 -13
  121. data/test/sass/results/script.css +0 -16
  122. data/test/sass/results/scss_import.css +0 -31
  123. data/test/sass/results/scss_importee.css +0 -2
  124. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  125. data/test/sass/results/subdir/subdir.css +0 -3
  126. data/test/sass/results/units.css +0 -11
  127. data/test/sass/results/warn.css +0 -0
  128. data/test/sass/results/warn_imported.css +0 -0
  129. data/test/sass/script_conversion_test.rb +0 -357
  130. data/test/sass/script_test.rb +0 -1431
  131. data/test/sass/scss/css_test.rb +0 -1281
  132. data/test/sass/scss/rx_test.rb +0 -160
  133. data/test/sass/scss/scss_test.rb +0 -4205
  134. data/test/sass/scss/test_helper.rb +0 -37
  135. data/test/sass/source_map_test.rb +0 -1055
  136. data/test/sass/superselector_test.rb +0 -210
  137. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  138. data/test/sass/templates/_double_import_loop2.sass +0 -1
  139. data/test/sass/templates/_filename_fn_import.scss +0 -11
  140. data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  141. data/test/sass/templates/_imported_charset_utf8.sass +0 -4
  142. data/test/sass/templates/_imported_content.sass +0 -3
  143. data/test/sass/templates/_partial.sass +0 -2
  144. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  145. data/test/sass/templates/alt.sass +0 -16
  146. data/test/sass/templates/basic.sass +0 -23
  147. data/test/sass/templates/bork1.sass +0 -2
  148. data/test/sass/templates/bork2.sass +0 -2
  149. data/test/sass/templates/bork3.sass +0 -2
  150. data/test/sass/templates/bork4.sass +0 -2
  151. data/test/sass/templates/bork5.sass +0 -3
  152. data/test/sass/templates/cached_import_option.scss +0 -3
  153. data/test/sass/templates/compact.sass +0 -17
  154. data/test/sass/templates/complex.sass +0 -305
  155. data/test/sass/templates/compressed.sass +0 -15
  156. data/test/sass/templates/double_import_loop1.sass +0 -1
  157. data/test/sass/templates/expanded.sass +0 -17
  158. data/test/sass/templates/filename_fn.scss +0 -18
  159. data/test/sass/templates/if.sass +0 -11
  160. data/test/sass/templates/import.sass +0 -12
  161. data/test/sass/templates/import_charset.sass +0 -9
  162. data/test/sass/templates/import_charset_1_8.sass +0 -6
  163. data/test/sass/templates/import_charset_ibm866.sass +0 -11
  164. data/test/sass/templates/import_content.sass +0 -4
  165. data/test/sass/templates/importee.less +0 -2
  166. data/test/sass/templates/importee.sass +0 -19
  167. data/test/sass/templates/line_numbers.sass +0 -13
  168. data/test/sass/templates/mixin_bork.sass +0 -5
  169. data/test/sass/templates/mixins.sass +0 -76
  170. data/test/sass/templates/multiline.sass +0 -20
  171. data/test/sass/templates/nested.sass +0 -25
  172. data/test/sass/templates/nested_bork1.sass +0 -2
  173. data/test/sass/templates/nested_bork2.sass +0 -2
  174. data/test/sass/templates/nested_bork3.sass +0 -2
  175. data/test/sass/templates/nested_bork4.sass +0 -2
  176. data/test/sass/templates/nested_import.sass +0 -2
  177. data/test/sass/templates/nested_mixin_bork.sass +0 -6
  178. data/test/sass/templates/options.sass +0 -2
  179. data/test/sass/templates/parent_ref.sass +0 -25
  180. data/test/sass/templates/same_name_different_ext.sass +0 -2
  181. data/test/sass/templates/same_name_different_ext.scss +0 -1
  182. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  183. data/test/sass/templates/script.sass +0 -101
  184. data/test/sass/templates/scss_import.scss +0 -12
  185. data/test/sass/templates/scss_importee.scss +0 -1
  186. data/test/sass/templates/single_import_loop.sass +0 -1
  187. data/test/sass/templates/subdir/import_up1.scss +0 -1
  188. data/test/sass/templates/subdir/import_up2.scss +0 -1
  189. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  190. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  191. data/test/sass/templates/subdir/subdir.sass +0 -6
  192. data/test/sass/templates/units.sass +0 -11
  193. data/test/sass/templates/warn.sass +0 -3
  194. data/test/sass/templates/warn_imported.sass +0 -4
  195. data/test/sass/test_helper.rb +0 -8
  196. data/test/sass/util/multibyte_string_scanner_test.rb +0 -155
  197. data/test/sass/util/normalized_map_test.rb +0 -51
  198. data/test/sass/util/subset_map_test.rb +0 -91
  199. data/test/sass/util_test.rb +0 -438
  200. data/test/sass/value_helpers_test.rb +0 -179
  201. data/test/test_helper.rb +0 -110
  202. data/vendor/listen/CHANGELOG.md +0 -1
  203. data/vendor/listen/CONTRIBUTING.md +0 -38
  204. data/vendor/listen/Gemfile +0 -20
  205. data/vendor/listen/Guardfile +0 -8
  206. data/vendor/listen/LICENSE +0 -20
  207. data/vendor/listen/README.md +0 -349
  208. data/vendor/listen/Rakefile +0 -5
  209. data/vendor/listen/Vagrantfile +0 -96
  210. data/vendor/listen/lib/listen.rb +0 -54
  211. data/vendor/listen/lib/listen/adapter.rb +0 -327
  212. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  213. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  214. data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  215. data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  216. data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  217. data/vendor/listen/lib/listen/directory_record.rb +0 -406
  218. data/vendor/listen/lib/listen/listener.rb +0 -323
  219. data/vendor/listen/lib/listen/turnstile.rb +0 -32
  220. data/vendor/listen/lib/listen/version.rb +0 -3
  221. data/vendor/listen/listen.gemspec +0 -28
  222. data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  223. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  224. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  225. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  226. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  227. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  228. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  229. data/vendor/listen/spec/listen/listener_spec.rb +0 -258
  230. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  231. data/vendor/listen/spec/listen_spec.rb +0 -67
  232. data/vendor/listen/spec/spec_helper.rb +0 -25
  233. data/vendor/listen/spec/support/adapter_helper.rb +0 -666
  234. data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  235. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  236. data/vendor/listen/spec/support/listeners_helper.rb +0 -179
  237. data/vendor/listen/spec/support/platform_helper.rb +0 -15
@@ -1,236 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'minitest/autorun'
3
- require File.dirname(__FILE__) + '/../test_helper'
4
- require 'sass/plugin'
5
- require 'sass/plugin/compiler'
6
-
7
- class CompilerTest < MiniTest::Test
8
- class FakeListener
9
- attr_accessor :options
10
- attr_accessor :directories
11
- attr_reader :start_called
12
- attr_reader :thread
13
-
14
- def initialize(*args, &on_filesystem_event)
15
- self.options = args.last.is_a?(Hash) ? args.pop : {}
16
- self.directories = args
17
- @on_filesystem_event = on_filesystem_event
18
- @start_called = false
19
- reset_events!
20
- end
21
-
22
- def fire_events!(*args)
23
- @on_filesystem_event.call(@modified, @added, @removed)
24
- reset_events!
25
- end
26
-
27
- def changed(filename)
28
- @modified << File.expand_path(filename)
29
- end
30
-
31
- def added(filename)
32
- @added << File.expand_path(filename)
33
- end
34
-
35
- def removed(filename)
36
- @removed << File.expand_path(filename)
37
- end
38
-
39
- def on_start!(&run_during_start)
40
- @run_during_start = run_during_start
41
- end
42
-
43
- # used for Listen < 2.0
44
- def start!
45
- @run_during_start.call(self) if @run_during_start
46
- end
47
-
48
- # used for Listen >= 2.0
49
- def start
50
- parent = Thread.current
51
- @thread = Thread.new do
52
- @run_during_start.call(self) if @run_during_start
53
- parent.raise Interrupt
54
- end
55
- end
56
-
57
- def stop
58
- end
59
-
60
- def reset_events!
61
- @modified = []
62
- @added = []
63
- @removed = []
64
- end
65
- end
66
-
67
- module MockWatcher
68
- attr_accessor :run_during_start
69
- attr_accessor :update_stylesheets_times
70
- attr_accessor :update_stylesheets_called_with
71
- attr_accessor :deleted_css_files
72
-
73
- def fake_listener
74
- @fake_listener
75
- end
76
-
77
- def update_stylesheets(individual_files)
78
- @update_stylesheets_times ||= 0
79
- @update_stylesheets_times += 1
80
- (@update_stylesheets_called_with ||= []) << individual_files
81
- end
82
-
83
- def try_delete_css(css_filename)
84
- (@deleted_css_files ||= []) << css_filename
85
- end
86
-
87
- private
88
- def create_listener(*args, &on_filesystem_event)
89
- if Sass::Util.listen_geq_2?
90
- args.pop if args.last.is_a?(Hash)
91
- args.map do |dir|
92
- @fake_listener = FakeListener.new(*args, &on_filesystem_event)
93
- @fake_listener.on_start!(&run_during_start)
94
- @fake_listener
95
- end
96
- else
97
- @fake_listener = FakeListener.new(*args, &on_filesystem_event)
98
- @fake_listener.on_start!(&run_during_start)
99
- @fake_listener
100
- end
101
- end
102
- end
103
-
104
- def test_initialize
105
- watcher
106
- end
107
-
108
- def test_watch_starts_the_listener
109
- start_called = false
110
- c = watcher do |listener|
111
- start_called = true
112
- end
113
- c.watch
114
- assert start_called, "start! was not called"
115
- end
116
-
117
- def test_sass_callbacks_fire_from_listener_events
118
- c = watcher do |listener|
119
- listener.changed "changed.scss"
120
- listener.added "added.scss"
121
- listener.removed "removed.scss"
122
- listener.fire_events!
123
- end
124
-
125
- modified_fired = false
126
- c.on_template_modified do |sass_file|
127
- modified_fired = true
128
- assert_equal "changed.scss", sass_file
129
- end
130
-
131
- added_fired = false
132
- c.on_template_created do |sass_file|
133
- added_fired = true
134
- assert_equal "added.scss", sass_file
135
- end
136
-
137
- removed_fired = false
138
- c.on_template_deleted do |sass_file|
139
- removed_fired = true
140
- assert_equal "removed.scss", sass_file
141
- end
142
-
143
- c.watch
144
-
145
- assert_equal 2, c.update_stylesheets_times
146
- assert modified_fired
147
- assert added_fired
148
- assert removed_fired
149
- end
150
-
151
- def test_removing_a_sass_file_removes_corresponding_css_file
152
- c = watcher do |listener|
153
- listener.removed "remove_me.scss"
154
- listener.fire_events!
155
- end
156
-
157
- c.watch
158
-
159
- assert_equal "./remove_me.css", c.deleted_css_files.first
160
- end
161
-
162
- def test_an_importer_can_watch_an_image
163
- image_importer = Sass::Importers::Filesystem.new(".")
164
- class << image_importer
165
- def watched_file?(filename)
166
- filename =~ /\.png$/
167
- end
168
- end
169
- c = watcher(:load_paths => [image_importer]) do |listener|
170
- listener.changed "image.png"
171
- listener.fire_events!
172
- end
173
-
174
- modified_fired = false
175
- c.on_template_modified do |f|
176
- modified_fired = true
177
- assert_equal "image.png", f
178
- end
179
-
180
- c.watch
181
-
182
- assert_equal 2, c.update_stylesheets_times
183
- assert modified_fired
184
- end
185
-
186
- def test_watching_specific_files_and_one_is_deleted
187
- directories = nil
188
- c = watcher do |listener|
189
- directories = listener.directories
190
- listener.removed File.expand_path("./foo.scss")
191
- listener.fire_events!
192
- end
193
- c.watch([[File.expand_path("./foo.scss"), File.expand_path("./foo.css"), nil]])
194
- assert directories.include?(File.expand_path(".")), directories.inspect
195
- assert_equal File.expand_path("./foo.css"), c.deleted_css_files.first, "the corresponding css file was not deleted"
196
- assert_equal [], c.update_stylesheets_called_with[1], "the sass file should not have been compiled"
197
- end
198
-
199
- def test_watched_directories_are_dedupped
200
- directories = nil
201
- c = watcher(:load_paths => [".", "./foo", "."]) do |listener|
202
- directories = listener.directories
203
- end
204
- c.watch
205
- assert_equal [File.expand_path(".")], directories
206
- end
207
-
208
- def test_a_changed_css_in_a_watched_directory_does_not_force_a_compile
209
- c = watcher do |listener|
210
- listener.changed "foo.css"
211
- listener.fire_events!
212
- end
213
-
214
- c.on_template_modified do |f|
215
- assert false, "Should not have been called"
216
- end
217
-
218
- c.watch
219
-
220
- assert_equal 1, c.update_stylesheets_times
221
- end
222
-
223
- private
224
-
225
- def default_options
226
- {:template_location => [[".","."]]}
227
- end
228
-
229
- def watcher(options = {}, &run_during_start)
230
- options = default_options.merge(options)
231
- watcher = Sass::Plugin::Compiler.new(options)
232
- watcher.extend(MockWatcher)
233
- watcher.run_during_start = run_during_start
234
- watcher
235
- end
236
- end
@@ -1,2188 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../test_helper'
3
-
4
- class ConversionTest < MiniTest::Test
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
- silence_warnings {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_renders "@media screen", "@media screen {}"
34
- end
35
-
36
- def test_empty_control_directive
37
- assert_renders "@if false", "@if false {}"
38
- end
39
-
40
- def test_nesting
41
- assert_renders <<SASS, <<SCSS
42
- foo bar
43
- baz bang
44
- baz: bang
45
- bip: bop
46
-
47
- blat: boo
48
- SASS
49
- foo bar {
50
- baz bang {
51
- baz: bang;
52
- bip: bop;
53
- }
54
-
55
- blat: boo;
56
- }
57
- SCSS
58
- end
59
-
60
- def test_nesting_with_parent_ref
61
- assert_renders <<SASS, <<SCSS
62
- foo bar
63
- &:hover
64
- baz: bang
65
- SASS
66
- foo bar {
67
- &:hover {
68
- baz: bang;
69
- }
70
- }
71
- SCSS
72
- end
73
-
74
- def test_selector_interpolation
75
- assert_renders <<SASS, <<SCSS
76
- foo \#{$bar + "baz"}.bip
77
- baz: bang
78
-
79
- foo /\#{$bar + "baz"}/ .bip
80
- baz: bang
81
- SASS
82
- foo \#{$bar + "baz"}.bip {
83
- baz: bang;
84
- }
85
-
86
- foo /\#{$bar + "baz"}/ .bip {
87
- baz: bang;
88
- }
89
- SCSS
90
- end
91
-
92
- def test_multiline_selector_with_commas
93
- assert_renders <<SASS, <<SCSS
94
- foo bar,
95
- baz bang
96
- baz: bang
97
- SASS
98
- foo bar,
99
- baz bang {
100
- baz: bang;
101
- }
102
- SCSS
103
-
104
- assert_renders <<SASS, <<SCSS
105
- blat
106
- foo bar,
107
- baz bang
108
- baz: bang
109
- SASS
110
- blat {
111
- foo bar,
112
- baz bang {
113
- baz: bang;
114
- }
115
- }
116
- SCSS
117
- end
118
-
119
- def test_multiline_selector_without_commas
120
- assert_scss_to_sass <<SASS, <<SCSS
121
- foo bar baz bang
122
- baz: bang
123
- SASS
124
- foo bar
125
- baz bang {
126
- baz: bang;
127
- }
128
- SCSS
129
-
130
- assert_scss_to_scss <<SCSS
131
- foo bar
132
- baz bang {
133
- baz: bang;
134
- }
135
- SCSS
136
- end
137
-
138
- def test_escaped_selector
139
- assert_renders <<SASS, <<SCSS
140
- foo bar
141
- \\:hover
142
- baz: bang
143
- SASS
144
- foo bar {
145
- :hover {
146
- baz: bang;
147
- }
148
- }
149
- SCSS
150
- end
151
-
152
- def test_property_name_interpolation
153
- assert_renders <<SASS, <<SCSS
154
- foo bar
155
- baz\#{$bang}bip\#{$bop}: 12
156
- SASS
157
- foo bar {
158
- baz\#{$bang}bip\#{$bop}: 12;
159
- }
160
- SCSS
161
- end
162
-
163
- def test_property_value_interpolation
164
- assert_renders <<SASS, <<SCSS
165
- foo bar
166
- baz: 12 \#{$bang} bip \#{"bop"} blat
167
- SASS
168
- foo bar {
169
- baz: 12 \#{$bang} bip \#{"bop"} blat;
170
- }
171
- SCSS
172
- end
173
-
174
- def test_dynamic_properties
175
- assert_renders <<SASS, <<SCSS
176
- foo bar
177
- baz: 12 $bang "bip"
178
- SASS
179
- foo bar {
180
- baz: 12 $bang "bip";
181
- }
182
- SCSS
183
- end
184
-
185
- def test_dynamic_properties_with_old
186
- silence_warnings {assert_renders <<SASS, <<SCSS, :old => true}
187
- foo bar
188
- :baz 12 $bang "bip"
189
- SASS
190
- foo bar {
191
- baz: 12 $bang "bip";
192
- }
193
- SCSS
194
- end
195
-
196
- def test_multiline_properties
197
- assert_scss_to_sass <<SASS, <<SCSS
198
- foo bar
199
- baz: bip bam boon
200
- SASS
201
- foo bar {
202
- baz:
203
- bip
204
- bam
205
- boon;
206
- }
207
- SCSS
208
-
209
- assert_scss_to_scss <<OUT, <<IN
210
- foo bar {
211
- baz: bip bam boon;
212
- }
213
- OUT
214
- foo bar {
215
- baz:
216
- bip
217
- bam
218
- boon;
219
- }
220
- IN
221
- end
222
-
223
- def test_multiline_dynamic_properties
224
- assert_scss_to_sass <<SASS, <<SCSS
225
- foo bar
226
- baz: $bip "bam" 12px
227
- SASS
228
- foo bar {
229
- baz:
230
- $bip
231
- "bam"
232
- 12px;
233
- }
234
- SCSS
235
-
236
- assert_scss_to_scss <<OUT, <<IN
237
- foo bar {
238
- baz: $bip "bam" 12px;
239
- }
240
- OUT
241
- foo bar {
242
- baz:
243
- $bip
244
- "bam"
245
- 12px;
246
- }
247
- IN
248
- end
249
-
250
- def test_silent_comments
251
- assert_renders <<SASS, <<SCSS
252
- // foo
253
-
254
- // bar
255
-
256
- // baz
257
-
258
- foo bar
259
- a: b
260
- SASS
261
- // foo
262
-
263
- // bar
264
-
265
- // baz
266
-
267
- foo bar {
268
- a: b;
269
- }
270
- SCSS
271
-
272
- assert_renders <<SASS, <<SCSS
273
- // foo
274
- // bar
275
- // baz
276
- // bang
277
-
278
- foo bar
279
- a: b
280
- SASS
281
- // foo
282
- // bar
283
- // baz
284
- // bang
285
-
286
- foo bar {
287
- a: b;
288
- }
289
- SCSS
290
-
291
- assert_renders <<SASS, <<SCSS
292
- // foo
293
- // bar
294
- // baz
295
- // bang
296
-
297
- foo bar
298
- a: b
299
- SASS
300
- // foo
301
- // bar
302
- // baz
303
- // bang
304
-
305
- foo bar {
306
- a: b;
307
- }
308
- SCSS
309
- end
310
-
311
- def test_nested_silent_comments
312
- assert_renders <<SASS, <<SCSS
313
- foo
314
- bar: baz
315
-
316
- // bip bop
317
- // beep boop
318
- bang: bizz
319
-
320
- // bubble bubble
321
- // toil trouble
322
- SASS
323
- foo {
324
- bar: baz;
325
-
326
- // bip bop
327
- // beep boop
328
- bang: bizz;
329
-
330
- // bubble bubble
331
- // toil trouble
332
- }
333
- SCSS
334
-
335
- assert_sass_to_scss <<SCSS, <<SASS
336
- foo {
337
- bar: baz;
338
-
339
- // bip bop
340
- // beep boop
341
- // bap blimp
342
- bang: bizz;
343
-
344
- // bubble bubble
345
- // toil trouble
346
- // gorp
347
- }
348
- SCSS
349
- foo
350
- bar: baz
351
-
352
- // bip bop
353
- beep boop
354
- bap blimp
355
- bang: bizz
356
-
357
- // bubble bubble
358
- toil trouble
359
- gorp
360
- SASS
361
- end
362
-
363
- def test_preserves_triple_slash_comments
364
- assert_renders <<SASS, <<SCSS
365
- /// foo
366
- /// bar
367
- foo
368
- /// bip bop
369
- /// beep boop
370
- SASS
371
- /// foo
372
- /// bar
373
- foo {
374
- /// bip bop
375
- /// beep boop
376
- }
377
- SCSS
378
- end
379
-
380
- def test_loud_comments
381
- assert_renders <<SASS, <<SCSS
382
- /* foo
383
-
384
- /* bar
385
-
386
- /* baz
387
-
388
- foo bar
389
- a: b
390
- SASS
391
- /* foo */
392
-
393
- /* bar */
394
-
395
- /* baz */
396
-
397
- foo bar {
398
- a: b;
399
- }
400
- SCSS
401
-
402
- assert_scss_to_sass <<SASS, <<SCSS
403
- /* foo
404
- * bar
405
- * baz
406
- * bang
407
-
408
- foo bar
409
- a: b
410
- SASS
411
- /* foo
412
- bar
413
- baz
414
- bang */
415
-
416
- foo bar {
417
- a: b;
418
- }
419
- SCSS
420
-
421
- assert_scss_to_scss <<SCSS
422
- /* foo
423
- bar
424
- baz
425
- bang */
426
-
427
- foo bar {
428
- a: b;
429
- }
430
- SCSS
431
-
432
- assert_renders <<SASS, <<SCSS
433
- /* foo
434
- * bar
435
- * baz
436
- * bang
437
-
438
- foo bar
439
- a: b
440
- SASS
441
- /* foo
442
- * bar
443
- * baz
444
- * bang */
445
-
446
- foo bar {
447
- a: b;
448
- }
449
- SCSS
450
- end
451
-
452
- def test_nested_loud_comments
453
- assert_renders <<SASS, <<SCSS
454
- foo
455
- bar: baz
456
-
457
- /* bip bop
458
- * beep boop
459
- bang: bizz
460
-
461
- /* bubble bubble
462
- * toil trouble
463
- SASS
464
- foo {
465
- bar: baz;
466
-
467
- /* bip bop
468
- * beep boop */
469
- bang: bizz;
470
-
471
- /* bubble bubble
472
- * toil trouble */
473
- }
474
- SCSS
475
-
476
- assert_sass_to_scss <<SCSS, <<SASS
477
- foo {
478
- bar: baz;
479
-
480
- /* bip bop
481
- * beep boop
482
- * bap blimp */
483
- bang: bizz;
484
-
485
- /* bubble bubble
486
- * toil trouble
487
- * gorp */
488
- }
489
- SCSS
490
- foo
491
- bar: baz
492
-
493
- /* bip bop
494
- beep boop
495
- bap blimp
496
- bang: bizz
497
-
498
- /* bubble bubble
499
- toil trouble
500
- gorp
501
- SASS
502
- end
503
-
504
- def test_preserves_double_star_comments
505
- assert_renders <<SASS, <<SCSS
506
- /** foo
507
- * bar
508
- foo
509
- /** bip bop
510
- * beep boop
511
- SASS
512
- /** foo
513
- * bar */
514
- foo {
515
- /** bip bop
516
- * beep boop */
517
- }
518
- SCSS
519
- end
520
-
521
- def test_loud_comments_with_weird_indentation
522
- assert_scss_to_sass <<SASS, <<SCSS
523
- foo
524
- /* foo
525
- * bar
526
- * baz
527
- a: b
528
- SASS
529
- foo {
530
- /* foo
531
- bar
532
- baz */
533
- a: b;
534
- }
535
- SCSS
536
-
537
- assert_sass_to_scss <<SCSS, <<SASS
538
- foo {
539
- /* foo
540
- * bar
541
- * baz */
542
- a: b;
543
- }
544
- SCSS
545
- foo
546
- /* foo
547
- bar
548
- baz
549
- a: b
550
- SASS
551
- end
552
-
553
- def test_loud_comment_containing_silent_comment
554
- assert_scss_to_sass <<SASS, <<SCSS
555
- /*
556
- *// foo bar
557
- SASS
558
- /*
559
- // foo bar
560
- */
561
- SCSS
562
- end
563
-
564
- def test_silent_comment_containing_loud_comment
565
- assert_scss_to_sass <<SASS, <<SCSS
566
- // /*
567
- // * foo bar
568
- // */
569
- SASS
570
- // /*
571
- // * foo bar
572
- // */
573
- SCSS
574
- end
575
-
576
- def test_immediately_preceding_comments
577
- assert_renders <<SASS, <<SCSS
578
- /* Foo
579
- * Bar
580
- * Baz
581
- .foo#bar
582
- a: b
583
- SASS
584
- /* Foo
585
- * Bar
586
- * Baz */
587
- .foo#bar {
588
- a: b;
589
- }
590
- SCSS
591
-
592
- assert_renders <<SASS, <<SCSS
593
- // Foo
594
- // Bar
595
- // Baz
596
- =foo
597
- a: b
598
- SASS
599
- // Foo
600
- // Bar
601
- // Baz
602
- @mixin foo {
603
- a: b;
604
- }
605
- SCSS
606
- end
607
-
608
- def test_immediately_following_comments
609
- assert_sass_to_scss <<SCSS, <<SASS
610
- .foobar {
611
- // trailing comment
612
- a: 1px;
613
- }
614
- SCSS
615
- .foobar // trailing comment
616
- a: 1px
617
- SASS
618
-
619
- assert_sass_to_scss <<SCSS, <<SASS
620
- .foobar {
621
- // trailing comment
622
- a: 1px;
623
- }
624
- SCSS
625
- .foobar /* trailing comment */
626
- a: 1px
627
- SASS
628
- end
629
-
630
- def test_debug
631
- assert_renders <<SASS, <<SCSS
632
- foo
633
- @debug 12px
634
-
635
- bar: baz
636
- SASS
637
- foo {
638
- @debug 12px;
639
-
640
- bar: baz;
641
- }
642
- SCSS
643
- end
644
-
645
- def test_error
646
- assert_renders <<SASS, <<SCSS
647
- foo
648
- @error "oh no!"
649
-
650
- bar: baz
651
- SASS
652
- foo {
653
- @error "oh no!";
654
-
655
- bar: baz;
656
- }
657
- SCSS
658
- end
659
-
660
- def test_directive_without_children
661
- assert_renders <<SASS, <<SCSS
662
- foo
663
- @foo #bar "baz"
664
-
665
- bar: baz
666
- SASS
667
- foo {
668
- @foo #bar "baz";
669
-
670
- bar: baz;
671
- }
672
- SCSS
673
- end
674
-
675
- def test_directive_with_prop_children
676
- assert_renders <<SASS, <<SCSS
677
- foo
678
- @foo #bar "baz"
679
- a: b
680
- c: d
681
-
682
- bar: baz
683
- SASS
684
- foo {
685
- @foo #bar "baz" {
686
- a: b;
687
- c: d;
688
- }
689
-
690
- bar: baz;
691
- }
692
- SCSS
693
- end
694
-
695
- def test_directive_with_rule_children
696
- assert_renders <<SASS, <<SCSS
697
- foo
698
- @foo #bar "baz"
699
- #blat
700
- a: b
701
-
702
- .bang
703
- c: d
704
- e: f
705
-
706
- bar: baz
707
- SASS
708
- foo {
709
- @foo #bar "baz" {
710
- #blat {
711
- a: b;
712
- }
713
-
714
- .bang {
715
- c: d;
716
- e: f;
717
- }
718
- }
719
-
720
- bar: baz;
721
- }
722
- SCSS
723
- end
724
-
725
- def test_directive_with_rule_and_prop_children
726
- assert_renders <<SASS, <<SCSS
727
- foo
728
- @foo #bar "baz"
729
- g: h
730
-
731
- #blat
732
- a: b
733
-
734
- .bang
735
- c: d
736
- e: f
737
-
738
- i: j
739
-
740
- bar: baz
741
- SASS
742
- foo {
743
- @foo #bar "baz" {
744
- g: h;
745
-
746
- #blat {
747
- a: b;
748
- }
749
-
750
- .bang {
751
- c: d;
752
- e: f;
753
- }
754
-
755
- i: j;
756
- }
757
-
758
- bar: baz;
759
- }
760
- SCSS
761
- end
762
-
763
- def test_charset
764
- assert_renders <<SASS, <<SCSS
765
- @charset "utf-8"
766
- SASS
767
- @charset "utf-8";
768
- SCSS
769
- end
770
-
771
- def test_for
772
- assert_renders <<SASS, <<SCSS
773
- foo
774
- @for $a from $b to $c
775
- a: b
776
-
777
- @for $c from 1 to 16
778
- d: e
779
- f: g
780
- SASS
781
- foo {
782
- @for $a from $b to $c {
783
- a: b;
784
- }
785
-
786
- @for $c from 1 to 16 {
787
- d: e;
788
- f: g;
789
- }
790
- }
791
- SCSS
792
- end
793
-
794
- def test_while
795
- assert_renders <<SASS, <<SCSS
796
- foo
797
- @while flaz($a + $b)
798
- a: b
799
-
800
- @while 1
801
- d: e
802
- f: g
803
- SASS
804
- foo {
805
- @while flaz($a + $b) {
806
- a: b;
807
- }
808
-
809
- @while 1 {
810
- d: e;
811
- f: g;
812
- }
813
- }
814
- SCSS
815
- end
816
-
817
- def test_if
818
- assert_renders <<SASS, <<SCSS
819
- foo
820
- @if $foo or $bar
821
- a: b
822
-
823
- @if $baz
824
- d: e
825
- @else if $bang
826
- f: g
827
- @else
828
- h: i
829
- SASS
830
- foo {
831
- @if $foo or $bar {
832
- a: b;
833
- }
834
-
835
- @if $baz {
836
- d: e;
837
- }
838
- @else if $bang {
839
- f: g;
840
- }
841
- @else {
842
- h: i;
843
- }
844
- }
845
- SCSS
846
- end
847
-
848
- def test_each
849
- assert_renders <<SASS, <<SCSS
850
- a
851
- @each $number in 1px 2px 3px 4px
852
- b: $number
853
-
854
- c
855
- @each $str in foo, bar, baz, bang
856
- d: $str
857
-
858
- c
859
- @each $key, $value in (foo: 1, bar: 2, baz: 3)
860
- \#{$key}: $value
861
- SASS
862
- a {
863
- @each $number in 1px 2px 3px 4px {
864
- b: $number;
865
- }
866
- }
867
-
868
- c {
869
- @each $str in foo, bar, baz, bang {
870
- d: $str;
871
- }
872
- }
873
-
874
- c {
875
- @each $key, $value in (foo: 1, bar: 2, baz: 3) {
876
- \#{$key}: $value;
877
- }
878
- }
879
- SCSS
880
- end
881
-
882
- def test_import
883
- assert_renders <<SASS, <<SCSS
884
- @import foo
885
-
886
- @import url(bar.css)
887
-
888
- foo
889
- bar: baz
890
- SASS
891
- @import "foo";
892
-
893
- @import url(bar.css);
894
-
895
- foo {
896
- bar: baz;
897
- }
898
- SCSS
899
-
900
- assert_renders <<SASS, <<SCSS
901
- @import foo.css
902
-
903
- @import url(bar.css)
904
-
905
- foo
906
- bar: baz
907
- SASS
908
- @import "foo.css";
909
-
910
- @import url(bar.css);
911
-
912
- foo {
913
- bar: baz;
914
- }
915
- SCSS
916
- end
917
-
918
- def test_import_as_directive_in_sass
919
- assert_equal "@import foo.css\n", to_sass('@import "foo.css"')
920
- end
921
-
922
- def test_import_as_directive_in_scss
923
- assert_renders <<SASS, <<SCSS
924
- @import "foo.css" print
925
- SASS
926
- @import "foo.css" print;
927
- SCSS
928
-
929
- assert_renders <<SASS, <<SCSS
930
- @import url(foo.css) screen, print
931
- SASS
932
- @import url(foo.css) screen, print;
933
- SCSS
934
- end
935
-
936
- def test_adjacent_imports
937
- assert_renders <<SASS, <<SCSS
938
- @import foo.sass
939
- @import bar.scss
940
- @import baz
941
- SASS
942
- @import "foo.sass";
943
- @import "bar.scss";
944
- @import "baz";
945
- SCSS
946
- end
947
-
948
- def test_non_adjacent_imports
949
- assert_renders <<SASS, <<SCSS
950
- @import foo.sass
951
-
952
- @import bar.scss
953
-
954
- @import baz
955
- SASS
956
- @import "foo.sass";
957
-
958
- @import "bar.scss";
959
-
960
- @import "baz";
961
- SCSS
962
- end
963
-
964
- def test_import_with_interpolation
965
- assert_renders <<SASS, <<SCSS
966
- $family: unquote("Droid+Sans")
967
-
968
- @import url("http://fonts.googleapis.com/css?family=\#{$family}")
969
- SASS
970
- $family: unquote("Droid+Sans");
971
-
972
- @import url("http://fonts.googleapis.com/css?family=\#{$family}");
973
- SCSS
974
- end
975
-
976
- def test_extend
977
- assert_renders <<SASS, <<SCSS
978
- .foo
979
- @extend .bar
980
-
981
- @extend .baz:bang
982
- SASS
983
- .foo {
984
- @extend .bar;
985
-
986
- @extend .baz:bang;
987
- }
988
- SCSS
989
- end
990
-
991
- def test_comma_extendee
992
- assert_renders <<SASS, <<SCSS
993
- .baz
994
- @extend .foo, .bar
995
- SASS
996
- .baz {
997
- @extend .foo, .bar;
998
- }
999
- SCSS
1000
- end
1001
-
1002
- def test_argless_mixin_definition
1003
- assert_renders <<SASS, <<SCSS
1004
- =foo-bar
1005
- baz
1006
- a: b
1007
- SASS
1008
- @mixin foo-bar {
1009
- baz {
1010
- a: b;
1011
- }
1012
- }
1013
- SCSS
1014
-
1015
- assert_scss_to_sass <<SASS, <<SCSS
1016
- =foo-bar
1017
- baz
1018
- a: b
1019
- SASS
1020
- @mixin foo-bar() {
1021
- baz {
1022
- a: b;
1023
- }
1024
- }
1025
- SCSS
1026
-
1027
- assert_sass_to_scss <<SCSS, <<SASS
1028
- @mixin foo-bar {
1029
- baz {
1030
- a: b;
1031
- }
1032
- }
1033
- SCSS
1034
- =foo-bar()
1035
- baz
1036
- a: b
1037
- SASS
1038
- end
1039
-
1040
- def test_mixin_definition_without_defaults
1041
- assert_renders <<SASS, <<SCSS
1042
- =foo-bar($baz, $bang)
1043
- baz
1044
- a: $baz $bang
1045
- SASS
1046
- @mixin foo-bar($baz, $bang) {
1047
- baz {
1048
- a: $baz $bang;
1049
- }
1050
- }
1051
- SCSS
1052
- end
1053
-
1054
- def test_mixin_definition_with_defaults
1055
- assert_renders <<SASS, <<SCSS
1056
- =foo-bar($baz, $bang: 12px)
1057
- baz
1058
- a: $baz $bang
1059
- SASS
1060
- @mixin foo-bar($baz, $bang: 12px) {
1061
- baz {
1062
- a: $baz $bang;
1063
- }
1064
- }
1065
- SCSS
1066
-
1067
- assert_sass_to_scss <<SCSS, <<SASS
1068
- @mixin foo-bar($baz, $bang: foo) {
1069
- baz {
1070
- a: $baz $bang;
1071
- }
1072
- }
1073
- SCSS
1074
- =foo-bar($baz, $bang: foo)
1075
- baz
1076
- a: $baz $bang
1077
- SASS
1078
- end
1079
-
1080
- def test_argless_mixin_include
1081
- assert_renders <<SASS, <<SCSS
1082
- foo
1083
- +foo-bar
1084
-
1085
- a: blip
1086
- SASS
1087
- foo {
1088
- @include foo-bar;
1089
-
1090
- a: blip;
1091
- }
1092
- SCSS
1093
- end
1094
-
1095
- def test_mixin_include
1096
- assert_renders <<SASS, <<SCSS
1097
- foo
1098
- +foo-bar(12px, "blaz")
1099
-
1100
- a: blip
1101
- SASS
1102
- foo {
1103
- @include foo-bar(12px, "blaz");
1104
-
1105
- a: blip;
1106
- }
1107
- SCSS
1108
- end
1109
-
1110
- def test_mixin_include_with_keyword_args
1111
- assert_renders <<SASS, <<SCSS
1112
- foo
1113
- +foo-bar(12px, "blaz", $blip: blap, $bloop: blop)
1114
-
1115
- +foo-bar($blip: blap, $bloop: blop)
1116
-
1117
- a: blip
1118
- SASS
1119
- foo {
1120
- @include foo-bar(12px, "blaz", $blip: blap, $bloop: blop);
1121
-
1122
- @include foo-bar($blip: blap, $bloop: blop);
1123
-
1124
- a: blip;
1125
- }
1126
- SCSS
1127
- end
1128
-
1129
- def test_consecutive_mixin_includes
1130
- assert_renders <<SASS, <<SCSS
1131
- foo
1132
- +foo-bar
1133
- +foo-bar
1134
-
1135
- a: blip
1136
- SASS
1137
- foo {
1138
- @include foo-bar;
1139
- @include foo-bar;
1140
-
1141
- a: blip;
1142
- }
1143
- SCSS
1144
- end
1145
-
1146
- def test_mixin_include_with_hyphen_conversion_keyword_arg
1147
- assert_renders <<SASS, <<SCSS
1148
- foo
1149
- +foo-bar($a-b_c: val)
1150
-
1151
- a: blip
1152
- SASS
1153
- foo {
1154
- @include foo-bar($a-b_c: val);
1155
-
1156
- a: blip;
1157
- }
1158
- SCSS
1159
- end
1160
-
1161
- def test_argless_function_definition
1162
- assert_renders <<SASS, <<SCSS
1163
- @function foo()
1164
- $var: 1 + 1
1165
-
1166
- @return $var
1167
- SASS
1168
- @function foo() {
1169
- $var: 1 + 1;
1170
-
1171
- @return $var;
1172
- }
1173
- SCSS
1174
- end
1175
-
1176
- def test_function_definition_without_defaults
1177
- assert_renders <<SASS, <<SCSS
1178
- @function foo($var1, $var2)
1179
- @if $var1
1180
- @return $var1 + $var2
1181
- SASS
1182
- @function foo($var1, $var2) {
1183
- @if $var1 {
1184
- @return $var1 + $var2;
1185
- }
1186
- }
1187
- SCSS
1188
- end
1189
-
1190
- def test_function_definition_with_defaults
1191
- assert_renders <<SASS, <<SCSS
1192
- @function foo($var1, $var2: foo)
1193
- @if $var1
1194
- @return $var1 + $var2
1195
- SASS
1196
- @function foo($var1, $var2: foo) {
1197
- @if $var1 {
1198
- @return $var1 + $var2;
1199
- }
1200
- }
1201
- SCSS
1202
- end
1203
-
1204
- def test_variable_definition
1205
- assert_renders <<SASS, <<SCSS
1206
- $var1: 12px + 15px
1207
-
1208
- foo
1209
- $var2: flaz(#abcdef)
1210
-
1211
- val: $var1 $var2
1212
- SASS
1213
- $var1: 12px + 15px;
1214
-
1215
- foo {
1216
- $var2: flaz(#abcdef);
1217
-
1218
- val: $var1 $var2;
1219
- }
1220
- SCSS
1221
- end
1222
-
1223
- def test_guarded_variable_definition
1224
- assert_renders <<SASS, <<SCSS
1225
- $var1: 12px + 15px !default
1226
-
1227
- foo
1228
- $var2: flaz(#abcdef) !default
1229
-
1230
- val: $var1 $var2
1231
- SASS
1232
- $var1: 12px + 15px !default;
1233
-
1234
- foo {
1235
- $var2: flaz(#abcdef) !default;
1236
-
1237
- val: $var1 $var2;
1238
- }
1239
- SCSS
1240
- end
1241
-
1242
- def test_multiple_variable_definitions
1243
- assert_renders <<SASS, <<SCSS
1244
- $var1: foo
1245
- $var2: bar
1246
- $var3: baz
1247
-
1248
- $var4: bip
1249
- $var5: bap
1250
- SASS
1251
- $var1: foo;
1252
- $var2: bar;
1253
- $var3: baz;
1254
-
1255
- $var4: bip;
1256
- $var5: bap;
1257
- SCSS
1258
- end
1259
-
1260
- def test_division_asserted_with_parens
1261
- assert_renders <<SASS, <<SCSS
1262
- foo
1263
- a: (1px / 2px)
1264
- SASS
1265
- foo {
1266
- a: (1px / 2px);
1267
- }
1268
- SCSS
1269
- end
1270
-
1271
- def test_division_not_asserted_when_unnecessary
1272
- assert_renders <<SASS, <<SCSS
1273
- $var: 1px / 2px
1274
-
1275
- foo
1276
- a: $var
1277
- SASS
1278
- $var: 1px / 2px;
1279
-
1280
- foo {
1281
- a: $var;
1282
- }
1283
- SCSS
1284
-
1285
- assert_renders <<SASS, <<SCSS
1286
- $var: 1px
1287
-
1288
- foo
1289
- a: $var / 2px
1290
- SASS
1291
- $var: 1px;
1292
-
1293
- foo {
1294
- a: $var / 2px;
1295
- }
1296
- SCSS
1297
-
1298
- assert_renders <<SASS, <<SCSS
1299
- foo
1300
- a: 1 + 1px / 2px
1301
- SASS
1302
- foo {
1303
- a: 1 + 1px / 2px;
1304
- }
1305
- SCSS
1306
- end
1307
-
1308
- def test_literal_slash
1309
- assert_renders <<SASS, <<SCSS
1310
- foo
1311
- a: 1px / 2px
1312
- SASS
1313
- foo {
1314
- a: 1px / 2px;
1315
- }
1316
- SCSS
1317
-
1318
- # Regression test for issue 1787
1319
- assert_renders <<SASS, <<SCSS
1320
- foo
1321
- a: 1px / 2px 3px
1322
- SASS
1323
- foo {
1324
- a: 1px / 2px 3px;
1325
- }
1326
- SCSS
1327
- end
1328
-
1329
- def test_directive_with_interpolation
1330
- assert_renders <<SASS, <<SCSS
1331
- $baz: 12
1332
-
1333
- @foo bar\#{$baz} qux
1334
- a: b
1335
- SASS
1336
- $baz: 12;
1337
-
1338
- @foo bar\#{$baz} qux {
1339
- a: b;
1340
- }
1341
- SCSS
1342
- end
1343
-
1344
- def test_media_with_interpolation
1345
- assert_renders <<SASS, <<SCSS
1346
- $baz: 12
1347
-
1348
- @media bar\#{$baz}
1349
- a: b
1350
- SASS
1351
- $baz: 12;
1352
-
1353
- @media bar\#{$baz} {
1354
- a: b;
1355
- }
1356
- SCSS
1357
- end
1358
-
1359
- def test_media_with_expressions
1360
- assert_renders <<SASS, <<SCSS
1361
- $media1: screen
1362
- $media2: print
1363
- $var: -webkit-min-device-pixel-ratio
1364
- $val: 20
1365
-
1366
- @media \#{$media1} and ($var + "-foo": $val + 5), only \#{$media2}
1367
- a: b
1368
- SASS
1369
- $media1: screen;
1370
- $media2: print;
1371
- $var: -webkit-min-device-pixel-ratio;
1372
- $val: 20;
1373
-
1374
- @media \#{$media1} and ($var + "-foo": $val + 5), only \#{$media2} {
1375
- a: b;
1376
- }
1377
- SCSS
1378
- end
1379
-
1380
- def test_media_with_feature
1381
- assert_renders <<SASS, <<SCSS
1382
- @media screen and (-webkit-transform-3d)
1383
- a: b
1384
- SASS
1385
- @media screen and (-webkit-transform-3d) {
1386
- a: b;
1387
- }
1388
- SCSS
1389
- end
1390
-
1391
- def test_supports_with_expressions
1392
- assert_renders <<SASS, <<SCSS
1393
- $query: "(feature1: val)"
1394
- $feature: feature2
1395
- $val: val
1396
-
1397
- @supports (\#{$query} and ($feature: $val)) or (not ($feature + 3: $val + 4))
1398
- foo
1399
- a: b
1400
- SASS
1401
- $query: "(feature1: val)";
1402
- $feature: feature2;
1403
- $val: val;
1404
-
1405
- @supports (\#{$query} and ($feature: $val)) or (not ($feature + 3: $val + 4)) {
1406
- foo {
1407
- a: b;
1408
- }
1409
- }
1410
- SCSS
1411
- end
1412
-
1413
- # Hacks
1414
-
1415
- def test_declaration_hacks
1416
- assert_renders <<SASS, <<SCSS
1417
- foo
1418
- _name: val
1419
- *name: val
1420
- #name: val
1421
- .name: val
1422
- name/**/: val
1423
- name/*\\**/: val
1424
- name: val
1425
- SASS
1426
- foo {
1427
- _name: val;
1428
- *name: val;
1429
- #name: val;
1430
- .name: val;
1431
- name/**/: val;
1432
- name/*\\**/: val;
1433
- name: val;
1434
- }
1435
- SCSS
1436
- end
1437
-
1438
- def test_old_declaration_hacks
1439
- silence_warnings {assert_renders <<SASS, <<SCSS, :old => true}
1440
- foo
1441
- :_name val
1442
- :*name val
1443
- :#name val
1444
- :.name val
1445
- :name val
1446
- SASS
1447
- foo {
1448
- _name: val;
1449
- *name: val;
1450
- #name: val;
1451
- .name: val;
1452
- name: val;
1453
- }
1454
- SCSS
1455
- end
1456
-
1457
- def test_selector_hacks
1458
- assert_selector_renders = lambda do |s|
1459
- assert_renders <<SASS, <<SCSS
1460
- #{s}
1461
- a: b
1462
- SASS
1463
- #{s} {
1464
- a: b;
1465
- }
1466
- SCSS
1467
- end
1468
-
1469
- assert_selector_renders['> E']
1470
- assert_selector_renders['+ E']
1471
- assert_selector_renders['~ E']
1472
- assert_selector_renders['> > E']
1473
-
1474
- assert_selector_renders['E*']
1475
- assert_selector_renders['E*.foo']
1476
- assert_selector_renders['E*:hover']
1477
- end
1478
-
1479
- def test_disallowed_colon_hack
1480
- assert_raise_message(Sass::SyntaxError, 'The ":name: val" hack is not allowed in the Sass indented syntax') do
1481
- to_sass("foo {:name: val;}", :syntax => :scss)
1482
- end
1483
- end
1484
-
1485
- def test_nested_properties
1486
- assert_renders <<SASS, <<SCSS
1487
- div
1488
- before: before
1489
- background:
1490
- color: blue
1491
- repeat: no-repeat
1492
- after: after
1493
- SASS
1494
- div {
1495
- before: before;
1496
- background: {
1497
- color: blue;
1498
- repeat: no-repeat;
1499
- };
1500
- after: after;
1501
- }
1502
-
1503
- SCSS
1504
- end
1505
-
1506
- def test_dasherize
1507
- assert_sass_to_scss(<<SCSS, <<SASS, :dasherize => true)
1508
- @mixin under-scored-mixin($under-scored-arg: $under-scored-default) {
1509
- bar: $under-scored-arg;
1510
- }
1511
-
1512
- div {
1513
- foo: under-scored-fn($under-scored-var + "before\#{$another-under-scored-var}after");
1514
-
1515
- @include under-scored-mixin($passed-arg);
1516
-
1517
- selector-\#{$under-scored-interp}: bold;
1518
- }
1519
-
1520
- @if $under-scored {
1521
- @for $for-var from $from-var to $to-var {
1522
- @while $while-var == true {
1523
- $while-var: false;
1524
- }
1525
- }
1526
- }
1527
- SCSS
1528
- =under_scored_mixin($under_scored_arg: $under_scored_default)
1529
- bar: $under_scored_arg
1530
- div
1531
- foo: under_scored_fn($under_scored_var + "before\#{$another_under_scored_var}after")
1532
- +under_scored_mixin($passed_arg)
1533
- selector-\#{$under_scored_interp}: bold
1534
- @if $under_scored
1535
- @for $for_var from $from_var to $to_var
1536
- @while $while_var == true
1537
- $while_var : false
1538
- SASS
1539
- end
1540
-
1541
- def test_loud_comment_conversion
1542
- assert_renders(<<SASS, <<SCSS)
1543
- /*! \#{"interpolated"}
1544
- SASS
1545
- /*! \#{"interpolated"} */
1546
- SCSS
1547
- end
1548
-
1549
- def test_content_conversion
1550
- assert_renders(<<SASS, <<SCSS)
1551
- $color: blue
1552
-
1553
- =context($class, $color: red)
1554
- .\#{$class}
1555
- background-color: $color
1556
-
1557
- @content
1558
-
1559
- border-color: $color
1560
-
1561
- +context(parent)
1562
- +context(child, $color: yellow)
1563
- color: $color
1564
- SASS
1565
- $color: blue;
1566
-
1567
- @mixin context($class, $color: red) {
1568
- .\#{$class} {
1569
- background-color: $color;
1570
-
1571
- @content;
1572
-
1573
- border-color: $color;
1574
- }
1575
- }
1576
-
1577
- @include context(parent) {
1578
- @include context(child, $color: yellow) {
1579
- color: $color;
1580
- }
1581
- }
1582
- SCSS
1583
-
1584
- end
1585
-
1586
- def test_empty_content
1587
- assert_scss_to_scss(<<SCSS)
1588
- @mixin foo {
1589
- @content;
1590
- }
1591
-
1592
- @include foo {}
1593
- SCSS
1594
- end
1595
-
1596
- def test_placeholder_conversion
1597
- assert_renders(<<SASS, <<SCSS)
1598
- #content a%foo.bar
1599
- color: blue
1600
- SASS
1601
- #content a%foo.bar {
1602
- color: blue;
1603
- }
1604
- SCSS
1605
- end
1606
-
1607
- def test_reference_selector
1608
- assert_renders(<<SASS, <<SCSS)
1609
- foo /bar|baz/ bang
1610
- a: b
1611
- SASS
1612
- foo /bar|baz/ bang {
1613
- a: b;
1614
- }
1615
- SCSS
1616
- end
1617
-
1618
- def test_subject
1619
- assert_renders(<<SASS, <<SCSS)
1620
- foo bar! baz
1621
- a: b
1622
- SASS
1623
- foo bar! baz {
1624
- a: b;
1625
- }
1626
- SCSS
1627
- end
1628
-
1629
- def test_placeholder_interoplation_conversion
1630
- assert_renders(<<SASS, <<SCSS)
1631
- $foo: foo
1632
-
1633
- %\#{$foo}
1634
- color: blue
1635
-
1636
- .bar
1637
- @extend %foo
1638
- SASS
1639
- $foo: foo;
1640
-
1641
- %\#{$foo} {
1642
- color: blue;
1643
- }
1644
-
1645
- .bar {
1646
- @extend %foo;
1647
- }
1648
- SCSS
1649
- end
1650
-
1651
- def test_indent
1652
- assert_renders <<SASS, <<SCSS, :indent => " "
1653
- foo bar
1654
- baz bang
1655
- baz: bang
1656
- bip: bop
1657
-
1658
- blat: boo
1659
- SASS
1660
- foo bar {
1661
- baz bang {
1662
- baz: bang;
1663
- bip: bop;
1664
- }
1665
-
1666
- blat: boo;
1667
- }
1668
- SCSS
1669
-
1670
- assert_renders <<SASS, <<SCSS, :indent => "\t"
1671
- foo bar
1672
- baz bang
1673
- baz: bang
1674
- bip: bop
1675
-
1676
- blat: boo
1677
- SASS
1678
- foo bar {
1679
- baz bang {
1680
- baz: bang;
1681
- bip: bop;
1682
- }
1683
-
1684
- blat: boo;
1685
- }
1686
- SCSS
1687
-
1688
- assert_sass_to_scss <<SCSS, <<SASS, :indent => " "
1689
- foo bar {
1690
- baz bang {
1691
- baz: bang;
1692
- bip: bop;
1693
- }
1694
-
1695
- blat: boo;
1696
- }
1697
- SCSS
1698
- foo bar
1699
- baz bang
1700
- baz: bang
1701
- bip: bop
1702
-
1703
- blat: boo
1704
- SASS
1705
-
1706
- assert_sass_to_scss <<SCSS, <<SASS, :indent => "\t"
1707
- foo bar {
1708
- baz bang {
1709
- baz: bang;
1710
- bip: bop;
1711
- }
1712
-
1713
- blat: boo;
1714
- }
1715
- SCSS
1716
- foo bar
1717
- baz bang
1718
- baz: bang
1719
- bip: bop
1720
-
1721
- blat: boo
1722
- SASS
1723
-
1724
- assert_scss_to_sass <<SASS, <<SCSS, :indent => " "
1725
- foo bar
1726
- baz bang
1727
- baz: bang
1728
- bip: bop
1729
-
1730
- blat: boo
1731
- SASS
1732
- foo bar {
1733
- baz bang {
1734
- baz: bang;
1735
- bip: bop;
1736
- }
1737
-
1738
- blat: boo;
1739
- }
1740
- SCSS
1741
-
1742
- assert_scss_to_sass <<SASS, <<SCSS, :indent => "\t"
1743
- foo bar
1744
- baz bang
1745
- baz: bang
1746
- bip: bop
1747
-
1748
- blat: boo
1749
- SASS
1750
- foo bar {
1751
- baz bang {
1752
- baz: bang;
1753
- bip: bop;
1754
- }
1755
-
1756
- blat: boo;
1757
- }
1758
- SCSS
1759
- end
1760
-
1761
- def test_extend_with_optional
1762
- assert_renders <<SASS, <<SCSS
1763
- foo
1764
- @extend .bar !optional
1765
- SASS
1766
- foo {
1767
- @extend .bar !optional;
1768
- }
1769
- SCSS
1770
- end
1771
-
1772
- def test_mixin_var_args
1773
- assert_renders <<SASS, <<SCSS
1774
- =foo($args...)
1775
- a: b
1776
-
1777
- =bar($a, $args...)
1778
- a: b
1779
-
1780
- .foo
1781
- +foo($list...)
1782
-
1783
- +bar(1, $list...)
1784
- SASS
1785
- @mixin foo($args...) {
1786
- a: b;
1787
- }
1788
-
1789
- @mixin bar($a, $args...) {
1790
- a: b;
1791
- }
1792
-
1793
- .foo {
1794
- @include foo($list...);
1795
-
1796
- @include bar(1, $list...);
1797
- }
1798
- SCSS
1799
- end
1800
-
1801
- def test_mixin_var_kwargs
1802
- assert_renders <<SASS, <<SCSS
1803
- =foo($a: b, $c: d)
1804
- a: $a
1805
- c: $c
1806
-
1807
- .foo
1808
- +foo($list..., $map...)
1809
-
1810
- +foo(pos, $list..., $kwd: val, $map...)
1811
- SASS
1812
- @mixin foo($a: b, $c: d) {
1813
- a: $a;
1814
- c: $c;
1815
- }
1816
-
1817
- .foo {
1818
- @include foo($list..., $map...);
1819
-
1820
- @include foo(pos, $list..., $kwd: val, $map...);
1821
- }
1822
- SCSS
1823
- end
1824
-
1825
- def test_function_var_args
1826
- assert_renders <<SASS, <<SCSS
1827
- @function foo($args...)
1828
- @return foo
1829
-
1830
- @function bar($a, $args...)
1831
- @return bar
1832
-
1833
- .foo
1834
- a: foo($list...)
1835
- b: bar(1, $list...)
1836
- SASS
1837
- @function foo($args...) {
1838
- @return foo;
1839
- }
1840
-
1841
- @function bar($a, $args...) {
1842
- @return bar;
1843
- }
1844
-
1845
- .foo {
1846
- a: foo($list...);
1847
- b: bar(1, $list...);
1848
- }
1849
- SCSS
1850
- end
1851
-
1852
- def test_function_var_kwargs
1853
- assert_renders <<SASS, <<SCSS
1854
- @function foo($a: b, $c: d)
1855
- @return foo
1856
-
1857
- .foo
1858
- a: foo($list..., $map...)
1859
- b: foo(pos, $list..., $kwd: val, $map...)
1860
- SASS
1861
- @function foo($a: b, $c: d) {
1862
- @return foo;
1863
- }
1864
-
1865
- .foo {
1866
- a: foo($list..., $map...);
1867
- b: foo(pos, $list..., $kwd: val, $map...);
1868
- }
1869
- SCSS
1870
- end
1871
-
1872
- def test_at_root
1873
- assert_renders <<SASS, <<SCSS
1874
- .foo
1875
- @at-root
1876
- .bar
1877
- a: b
1878
-
1879
- .baz
1880
- c: d
1881
- SASS
1882
- .foo {
1883
- @at-root {
1884
- .bar {
1885
- a: b;
1886
- }
1887
-
1888
- .baz {
1889
- c: d;
1890
- }
1891
- }
1892
- }
1893
- SCSS
1894
- end
1895
-
1896
- def test_at_root_with_selector
1897
- assert_renders <<SASS, <<SCSS
1898
- .foo
1899
- @at-root .bar
1900
- a: b
1901
- SASS
1902
- .foo {
1903
- @at-root .bar {
1904
- a: b;
1905
- }
1906
- }
1907
- SCSS
1908
- end
1909
-
1910
- def test_at_root_without
1911
- assert_renders <<SASS, <<SCSS
1912
- .foo
1913
- @at-root (without: media rule)
1914
- a: b
1915
- SASS
1916
- .foo {
1917
- @at-root (without: media rule) {
1918
- a: b;
1919
- }
1920
- }
1921
- SCSS
1922
- end
1923
-
1924
- def test_at_root_with
1925
- assert_renders <<SASS, <<SCSS
1926
- .foo
1927
- @at-root (with: media rule)
1928
- a: b
1929
- SASS
1930
- .foo {
1931
- @at-root (with: media rule) {
1932
- a: b;
1933
- }
1934
- }
1935
- SCSS
1936
- end
1937
-
1938
- def test_function_var_kwargs_with_list
1939
- assert_renders <<SASS, <<SCSS
1940
- @function foo($a: b, $c: d)
1941
- @return $a, $c
1942
-
1943
- .foo
1944
- a: foo($list..., $map...)
1945
- SASS
1946
- @function foo($a: b, $c: d) {
1947
- @return $a, $c;
1948
- }
1949
-
1950
- .foo {
1951
- a: foo($list..., $map...);
1952
- }
1953
- SCSS
1954
- end
1955
-
1956
- def test_keyframes
1957
- assert_renders(<<SASS, <<SCSS)
1958
- @keyframes identifier
1959
- 0%
1960
- top: 0
1961
- left: 0
1962
-
1963
- 30%
1964
- top: 50px
1965
-
1966
- 68%, 72%
1967
- left: 50px
1968
-
1969
- 100%
1970
- top: 100px
1971
- left: 100%
1972
- SASS
1973
- @keyframes identifier {
1974
- 0% {
1975
- top: 0;
1976
- left: 0;
1977
- }
1978
-
1979
- 30% {
1980
- top: 50px;
1981
- }
1982
-
1983
- 68%, 72% {
1984
- left: 50px;
1985
- }
1986
-
1987
- 100% {
1988
- top: 100px;
1989
- left: 100%;
1990
- }
1991
- }
1992
- SCSS
1993
- end
1994
-
1995
- ## Regression Tests
1996
-
1997
- def test_list_in_args
1998
- assert_renders(<<SASS, <<SCSS)
1999
- +mixin((a, b, c))
2000
-
2001
- +mixin($arg: (a, b, c))
2002
-
2003
- +mixin(a, b, (c, d, e)...)
2004
- SASS
2005
- @include mixin((a, b, c));
2006
-
2007
- @include mixin($arg: (a, b, c));
2008
-
2009
- @include mixin(a, b, (c, d, e)...);
2010
- SCSS
2011
- end
2012
-
2013
- def test_media_query_with_expr
2014
- assert_renders <<SASS, <<SCSS
2015
- @media foo and (bar: baz)
2016
- a: b
2017
- SASS
2018
- @media foo and (bar: baz) {
2019
- a: b;
2020
- }
2021
- SCSS
2022
- end
2023
-
2024
- def test_nested_if_statements
2025
- assert_renders(<<SASS, <<SCSS)
2026
- @if $foo
2027
- one
2028
- a: b
2029
- @else
2030
- @if $bar
2031
- two
2032
- a: b
2033
- @else
2034
- three
2035
- a: b
2036
- SASS
2037
- @if $foo {
2038
- one {
2039
- a: b;
2040
- }
2041
- }
2042
- @else {
2043
- @if $bar {
2044
- two {
2045
- a: b;
2046
- }
2047
- }
2048
- @else {
2049
- three {
2050
- a: b;
2051
- }
2052
- }
2053
- }
2054
- SCSS
2055
- end
2056
-
2057
- def test_comment_indentation
2058
- assert_renders(<<SASS, <<SCSS, :indent => ' ')
2059
- foo
2060
- // bar
2061
- /* baz
2062
- a: b
2063
- SASS
2064
- foo {
2065
- // bar
2066
- /* baz */
2067
- a: b;
2068
- }
2069
- SCSS
2070
- end
2071
-
2072
- def test_keyword_arguments
2073
- assert_renders(<<SASS, <<SCSS, :dasherize => true)
2074
- $foo: foo($dash-ed: 2px)
2075
- SASS
2076
- $foo: foo($dash-ed: 2px);
2077
- SCSS
2078
- assert_scss_to_sass(<<SASS, <<SCSS, :dasherize => true)
2079
- $foo: foo($dash-ed: 2px)
2080
- SASS
2081
- $foo: foo($dash_ed: 2px);
2082
- SCSS
2083
- assert_sass_to_scss(<<SCSS, <<SASS, :dasherize => true)
2084
- $foo: foo($dash-ed: 2px);
2085
- SCSS
2086
- $foo: foo($dash_ed: 2px)
2087
- SASS
2088
- assert_renders(<<SASS, <<SCSS)
2089
- $foo: foo($under_scored: 1px)
2090
- SASS
2091
- $foo: foo($under_scored: 1px);
2092
- SCSS
2093
- assert_renders(<<SASS, <<SCSS)
2094
- $foo: foo($dash-ed: 2px, $under_scored: 1px)
2095
- SASS
2096
- $foo: foo($dash-ed: 2px, $under_scored: 1px);
2097
- SCSS
2098
- end
2099
-
2100
- def test_ambiguous_negation
2101
- assert_renders(<<SASS, <<SCSS, :indent => ' ')
2102
- foo
2103
- ok: -$foo
2104
- comma: 10px, -$foo
2105
- needs-parens: 10px (-$foo)
2106
- SASS
2107
- foo {
2108
- ok: -$foo;
2109
- comma: 10px, -$foo;
2110
- needs-parens: 10px (-$foo);
2111
- }
2112
- SCSS
2113
- end
2114
-
2115
- def test_variable_with_global
2116
- assert_renders(<<SASS, <<SCSS)
2117
- $var: 1
2118
-
2119
- foo
2120
- $var: 2 !global
2121
- $var: 3 !global !default
2122
- SASS
2123
- $var: 1;
2124
-
2125
- foo {
2126
- $var: 2 !global;
2127
- $var: 3 !global !default;
2128
- }
2129
- SCSS
2130
- end
2131
-
2132
- def test_import_with_supports_clause
2133
- assert_renders(<<'SASS', <<'SCSS')
2134
- @import url("fallback-layout.css") supports(not (display: #{$display-type}))
2135
- SASS
2136
- @import url("fallback-layout.css") supports(not (display: #{$display-type}));
2137
- SCSS
2138
- end
2139
-
2140
- private
2141
-
2142
- def assert_sass_to_sass(sass, options = {})
2143
- assert_equal(sass.rstrip, to_sass(sass, options).rstrip,
2144
- "Expected Sass to transform to itself")
2145
- end
2146
-
2147
- def assert_scss_to_sass(sass, scss, options = {})
2148
- assert_equal(sass.rstrip, to_sass(scss, options.merge(:syntax => :scss)).rstrip,
2149
- "Expected SCSS to transform to Sass")
2150
- end
2151
-
2152
- def assert_scss_to_scss(scss, in_scss = nil, options = nil)
2153
- if in_scss.is_a?(Hash)
2154
- options = in_scss
2155
- in_scss = nil
2156
- end
2157
-
2158
- in_scss ||= scss
2159
- options ||= {}
2160
-
2161
- assert_equal(scss.rstrip, to_scss(in_scss, options.merge(:syntax => :scss)).rstrip,
2162
- "Expected SCSS to transform to #{scss == in_scss ? 'itself' : 'SCSS'}")
2163
- end
2164
-
2165
- def assert_sass_to_scss(scss, sass, options = {})
2166
- assert_equal(scss.rstrip, to_scss(sass, options).rstrip,
2167
- "Expected Sass to transform to SCSS")
2168
- end
2169
-
2170
- def assert_renders(sass, scss, options = {})
2171
- assert_sass_to_sass(sass, options)
2172
- assert_scss_to_sass(sass, scss, options)
2173
- assert_scss_to_scss(scss, options)
2174
- assert_sass_to_scss(scss, sass, options)
2175
- end
2176
-
2177
- def to_sass(scss, options = {})
2178
- Sass::Util.silence_sass_warnings do
2179
- Sass::Engine.new(scss, options).to_tree.to_sass(options)
2180
- end
2181
- end
2182
-
2183
- def to_scss(sass, options = {})
2184
- Sass::Util.silence_sass_warnings do
2185
- Sass::Engine.new(sass, options).to_tree.to_scss(options)
2186
- end
2187
- end
2188
- end