sass 3.6.0 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +1 -1
  3. data/README.md +10 -0
  4. data/VERSION +1 -1
  5. data/VERSION_DATE +1 -1
  6. data/lib/sass/script/css_parser.rb +4 -1
  7. data/lib/sass/script/functions.rb +15 -25
  8. data/lib/sass/script/lexer.rb +45 -7
  9. data/lib/sass/script/parser.rb +259 -93
  10. data/lib/sass/scss/parser.rb +43 -16
  11. data/lib/sass/scss/static_parser.rb +15 -15
  12. data/lib/sass/util.rb +31 -0
  13. metadata +8 -156
  14. data/Rakefile +0 -364
  15. data/test/sass-spec.yml +0 -3
  16. data/test/sass/cache_test.rb +0 -130
  17. data/test/sass/callbacks_test.rb +0 -60
  18. data/test/sass/compiler_test.rb +0 -225
  19. data/test/sass/conversion_test.rb +0 -2138
  20. data/test/sass/css2sass_test.rb +0 -523
  21. data/test/sass/css_variable_test.rb +0 -237
  22. data/test/sass/data/hsl-rgb.txt +0 -319
  23. data/test/sass/encoding_test.rb +0 -188
  24. data/test/sass/engine_test.rb +0 -3499
  25. data/test/sass/exec_test.rb +0 -95
  26. data/test/sass/extend_test.rb +0 -1679
  27. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  28. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  29. data/test/sass/functions_test.rb +0 -2021
  30. data/test/sass/importer_test.rb +0 -420
  31. data/test/sass/logger_test.rb +0 -57
  32. data/test/sass/mock_importer.rb +0 -49
  33. data/test/sass/more_results/more1.css +0 -9
  34. data/test/sass/more_results/more1_with_line_comments.css +0 -26
  35. data/test/sass/more_results/more_import.css +0 -29
  36. data/test/sass/more_templates/_more_partial.sass +0 -2
  37. data/test/sass/more_templates/more1.sass +0 -23
  38. data/test/sass/more_templates/more_import.sass +0 -11
  39. data/test/sass/plugin_test.rb +0 -552
  40. data/test/sass/results/alt.css +0 -4
  41. data/test/sass/results/basic.css +0 -9
  42. data/test/sass/results/cached_import_option.css +0 -3
  43. data/test/sass/results/compact.css +0 -5
  44. data/test/sass/results/complex.css +0 -86
  45. data/test/sass/results/compressed.css +0 -1
  46. data/test/sass/results/expanded.css +0 -19
  47. data/test/sass/results/filename_fn.css +0 -3
  48. data/test/sass/results/if.css +0 -3
  49. data/test/sass/results/import.css +0 -31
  50. data/test/sass/results/import_charset.css +0 -5
  51. data/test/sass/results/import_charset_ibm866.css +0 -5
  52. data/test/sass/results/import_content.css +0 -1
  53. data/test/sass/results/line_numbers.css +0 -49
  54. data/test/sass/results/mixins.css +0 -95
  55. data/test/sass/results/multiline.css +0 -24
  56. data/test/sass/results/nested.css +0 -22
  57. data/test/sass/results/options.css +0 -1
  58. data/test/sass/results/parent_ref.css +0 -13
  59. data/test/sass/results/script.css +0 -16
  60. data/test/sass/results/scss_import.css +0 -31
  61. data/test/sass/results/scss_importee.css +0 -2
  62. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  63. data/test/sass/results/subdir/subdir.css +0 -3
  64. data/test/sass/results/units.css +0 -11
  65. data/test/sass/results/warn.css +0 -0
  66. data/test/sass/results/warn_imported.css +0 -0
  67. data/test/sass/script_conversion_test.rb +0 -365
  68. data/test/sass/script_test.rb +0 -1427
  69. data/test/sass/scss/css_test.rb +0 -1266
  70. data/test/sass/scss/rx_test.rb +0 -159
  71. data/test/sass/scss/scss_test.rb +0 -4238
  72. data/test/sass/scss/test_helper.rb +0 -37
  73. data/test/sass/source_map_test.rb +0 -1063
  74. data/test/sass/superselector_test.rb +0 -209
  75. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  76. data/test/sass/templates/_double_import_loop2.sass +0 -1
  77. data/test/sass/templates/_filename_fn_import.scss +0 -11
  78. data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  79. data/test/sass/templates/_imported_charset_utf8.sass +0 -4
  80. data/test/sass/templates/_imported_content.sass +0 -3
  81. data/test/sass/templates/_partial.sass +0 -2
  82. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  83. data/test/sass/templates/alt.sass +0 -16
  84. data/test/sass/templates/basic.sass +0 -23
  85. data/test/sass/templates/bork1.sass +0 -2
  86. data/test/sass/templates/bork2.sass +0 -2
  87. data/test/sass/templates/bork3.sass +0 -2
  88. data/test/sass/templates/bork4.sass +0 -2
  89. data/test/sass/templates/bork5.sass +0 -3
  90. data/test/sass/templates/cached_import_option.scss +0 -3
  91. data/test/sass/templates/compact.sass +0 -17
  92. data/test/sass/templates/complex.sass +0 -305
  93. data/test/sass/templates/compressed.sass +0 -15
  94. data/test/sass/templates/double_import_loop1.sass +0 -1
  95. data/test/sass/templates/expanded.sass +0 -17
  96. data/test/sass/templates/filename_fn.scss +0 -18
  97. data/test/sass/templates/if.sass +0 -11
  98. data/test/sass/templates/import.sass +0 -12
  99. data/test/sass/templates/import_charset.sass +0 -9
  100. data/test/sass/templates/import_charset_ibm866.sass +0 -11
  101. data/test/sass/templates/import_content.sass +0 -4
  102. data/test/sass/templates/importee.less +0 -2
  103. data/test/sass/templates/importee.sass +0 -19
  104. data/test/sass/templates/line_numbers.sass +0 -13
  105. data/test/sass/templates/mixin_bork.sass +0 -5
  106. data/test/sass/templates/mixins.sass +0 -76
  107. data/test/sass/templates/multiline.sass +0 -20
  108. data/test/sass/templates/nested.sass +0 -25
  109. data/test/sass/templates/nested_bork1.sass +0 -2
  110. data/test/sass/templates/nested_bork2.sass +0 -2
  111. data/test/sass/templates/nested_bork3.sass +0 -2
  112. data/test/sass/templates/nested_bork4.sass +0 -2
  113. data/test/sass/templates/nested_import.sass +0 -2
  114. data/test/sass/templates/nested_mixin_bork.sass +0 -6
  115. data/test/sass/templates/options.sass +0 -2
  116. data/test/sass/templates/parent_ref.sass +0 -25
  117. data/test/sass/templates/same_name_different_ext.sass +0 -2
  118. data/test/sass/templates/same_name_different_ext.scss +0 -1
  119. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  120. data/test/sass/templates/script.sass +0 -101
  121. data/test/sass/templates/scss_import.scss +0 -12
  122. data/test/sass/templates/scss_importee.scss +0 -1
  123. data/test/sass/templates/single_import_loop.sass +0 -1
  124. data/test/sass/templates/subdir/import_up1.scss +0 -1
  125. data/test/sass/templates/subdir/import_up2.scss +0 -1
  126. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  127. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  128. data/test/sass/templates/subdir/subdir.sass +0 -6
  129. data/test/sass/templates/units.sass +0 -11
  130. data/test/sass/templates/warn.sass +0 -3
  131. data/test/sass/templates/warn_imported.sass +0 -4
  132. data/test/sass/test_helper.rb +0 -8
  133. data/test/sass/util/multibyte_string_scanner_test.rb +0 -152
  134. data/test/sass/util/normalized_map_test.rb +0 -50
  135. data/test/sass/util/subset_map_test.rb +0 -90
  136. data/test/sass/util_test.rb +0 -393
  137. data/test/sass/value_helpers_test.rb +0 -178
  138. data/test/test_helper.rb +0 -149
@@ -1,420 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require File.dirname(__FILE__) + '/test_helper'
3
- require 'mock_importer'
4
- require 'sass/plugin'
5
-
6
- class ImporterTest < MiniTest::Test
7
-
8
- class FruitImporter < Sass::Importers::Base
9
- def find(name, context = nil)
10
- fruit = parse(name)
11
- return unless fruit
12
- color = case fruit
13
- when "apple"
14
- "red"
15
- when "orange"
16
- "orange"
17
- else
18
- "blue"
19
- end
20
- contents = %Q{
21
- $#{fruit}-color: #{color} !default;
22
- @mixin #{fruit} {
23
- color: $#{fruit}-color;
24
- }
25
- }
26
- Sass::Engine.new(contents, :filename => name, :syntax => :scss, :importer => self)
27
- end
28
-
29
- def key(name, context)
30
- [self.class.name, name]
31
- end
32
-
33
- def public_url(name, sourcemap_directory = nil)
34
- "http://#{parse(name)}.example.com/style.scss"
35
- end
36
-
37
- private
38
-
39
- def parse(name)
40
- name[%r{fruits/(\w+)(\.s[ac]ss)?}, 1]
41
- end
42
- end
43
-
44
- class NoPublicUrlImporter < FruitImporter
45
- def public_url(name, sourcemap_directory = nil)
46
- nil
47
- end
48
-
49
- private
50
-
51
- def parse(name)
52
- name[%r{ephemeral/(\w+)(\.s[ac]ss)?}, 1]
53
- end
54
- end
55
-
56
- # This class proves that you can override the extension scheme for importers
57
- class ReversedExtImporter < Sass::Importers::Filesystem
58
- def extensions
59
- {"sscs" => :scss, "ssas" => :sass}
60
- end
61
- end
62
-
63
- # This importer maps one import to another import
64
- # based on the mappings passed to importer's constructor.
65
- class IndirectImporter < Sass::Importers::Base
66
- def initialize(mappings, mtimes)
67
- @mappings = mappings
68
- @mtimes = mtimes
69
- end
70
- def find_relative(uri, base, options)
71
- nil
72
- end
73
- def find(name, options)
74
- if @mappings.has_key?(name)
75
- Sass::Engine.new(
76
- %Q[@import "#{@mappings[name]}";],
77
- options.merge(
78
- :filename => name,
79
- :syntax => :scss,
80
- :importer => self
81
- )
82
- )
83
- end
84
- end
85
- def mtime(uri, options)
86
- @mtimes.fetch(uri, @mtimes.has_key?(uri) ? Time.now : nil)
87
- end
88
- def key(uri, options)
89
- [self.class.name, uri]
90
- end
91
- def to_s
92
- "IndirectImporter(#{@mappings.keys.join(", ")})"
93
- end
94
- end
95
-
96
- # This importer maps the import to single class
97
- # based on the mappings passed to importer's constructor.
98
- class ClassImporter < Sass::Importers::Base
99
- def initialize(mappings, mtimes)
100
- @mappings = mappings
101
- @mtimes = mtimes
102
- end
103
- def find_relative(uri, base, options)
104
- nil
105
- end
106
- def find(name, options)
107
- if @mappings.has_key?(name)
108
- Sass::Engine.new(
109
- %Q[.#{name}{#{@mappings[name]}}],
110
- options.merge(
111
- :filename => name,
112
- :syntax => :scss,
113
- :importer => self
114
- )
115
- )
116
- end
117
- end
118
- def mtime(uri, options)
119
- @mtimes.fetch(uri, @mtimes.has_key?(uri) ? Time.now : nil)
120
- end
121
- def key(uri, options)
122
- [self.class.name, uri]
123
- end
124
- def to_s
125
- "ClassImporter(#{@mappings.keys.join(", ")})"
126
- end
127
- end
128
-
129
- def test_can_resolve_generated_imports
130
- scss_file = %Q{
131
- $pear-color: green;
132
- @import "fruits/apple"; @import "fruits/orange"; @import "fruits/pear";
133
- .apple { @include apple; }
134
- .orange { @include orange; }
135
- .pear { @include pear; }
136
- }
137
- css_file = <<CSS
138
- .apple { color: red; }
139
-
140
- .orange { color: orange; }
141
-
142
- .pear { color: green; }
143
- CSS
144
- options = {:style => :compact, :load_paths => [FruitImporter.new], :syntax => :scss}
145
- assert_equal css_file, Sass::Engine.new(scss_file, options).render
146
- end
147
-
148
- def test_extension_overrides
149
- FileUtils.mkdir_p(absolutize("tmp"))
150
- open(absolutize("tmp/foo.ssas"), "w") {|f| f.write(".foo\n reversed: true\n")}
151
- open(absolutize("tmp/bar.sscs"), "w") {|f| f.write(".bar {reversed: true}\n")}
152
- scss_file = %Q{
153
- @import "foo", "bar";
154
- @import "foo.ssas", "bar.sscs";
155
- }
156
- css_file = <<CSS
157
- .foo { reversed: true; }
158
-
159
- .bar { reversed: true; }
160
-
161
- .foo { reversed: true; }
162
-
163
- .bar { reversed: true; }
164
- CSS
165
- options = {:style => :compact, :load_paths => [ReversedExtImporter.new(absolutize("tmp"))], :syntax => :scss}
166
- assert_equal css_file, Sass::Engine.new(scss_file, options).render
167
- ensure
168
- FileUtils.rm_rf(absolutize("tmp"))
169
- end
170
-
171
- def test_staleness_check_across_importers
172
- file_system_importer = Sass::Importers::Filesystem.new(fixture_dir)
173
- # Make sure the first import is older
174
- indirect_importer = IndirectImporter.new({"apple" => "pear"}, {"apple" => Time.now - 1})
175
- # Make css file is newer so the dependencies are the only way for the css file to be out of date.
176
- FileUtils.touch(fixture_file("test_staleness_check_across_importers.css"))
177
- # Make sure the first import is older
178
- class_importer = ClassImporter.new({"pear" => %Q{color: green;}}, {"pear" => Time.now + 1})
179
-
180
- options = {
181
- :style => :compact,
182
- :filename => fixture_file("test_staleness_check_across_importers.scss"),
183
- :importer => file_system_importer,
184
- :load_paths => [file_system_importer, indirect_importer, class_importer],
185
- :syntax => :scss
186
- }
187
-
188
- assert_equal File.read(fixture_file("test_staleness_check_across_importers.css")),
189
- Sass::Engine.new(File.read(fixture_file("test_staleness_check_across_importers.scss")), options).render
190
-
191
- checker = Sass::Plugin::StalenessChecker.new(options)
192
-
193
- assert checker.stylesheet_needs_update?(
194
- fixture_file("test_staleness_check_across_importers.css"),
195
- fixture_file("test_staleness_check_across_importers.scss"),
196
- file_system_importer
197
- )
198
- end
199
-
200
- def test_source_map_with_only_css_uri_supports_public_url_imports
201
- fruit_importer = FruitImporter.new
202
-
203
- options = {
204
- :filename => 'fruits/orange',
205
- :importer => fruit_importer,
206
- :syntax => :scss
207
- }
208
-
209
- engine = Sass::Engine.new(<<SCSS, options)
210
- .orchard {
211
- color: blue;
212
- }
213
- SCSS
214
-
215
- _, sourcemap = engine.render_with_sourcemap('sourcemap_uri')
216
- assert_equal <<JSON.strip, sourcemap.to_json(:css_uri => 'css_uri')
217
- {
218
- "version": 3,
219
- "mappings": "AAAA,QAAS;EACP,KAAK,EAAE,IAAI",
220
- "sources": ["http://orange.example.com/style.scss"],
221
- "names": [],
222
- "file": "css_uri"
223
- }
224
- JSON
225
- end
226
-
227
- def test_source_map_with_only_css_uri_can_have_no_public_url
228
- ephemeral_importer = NoPublicUrlImporter.new
229
- mock_importer = MockImporter.new
230
- def mock_importer.public_url(name, sourcemap_directory = nil)
231
- "source_uri"
232
- end
233
-
234
- options = {
235
- :filename => filename_for_test,
236
- :sourcemap_filename => sourcemap_filename_for_test,
237
- :importer => mock_importer,
238
- :syntax => :scss,
239
- :load_paths => [ephemeral_importer],
240
- :cache => false
241
- }
242
-
243
- engine = Sass::Engine.new(<<SCSS, options)
244
- @import "ephemeral/orange";
245
- .orange {
246
- @include orange;
247
- }
248
- SCSS
249
-
250
- css_output, sourcemap = engine.render_with_sourcemap('sourcemap_uri')
251
- assert_equal <<CSS.strip, css_output.strip
252
- .orange {
253
- color: orange; }
254
-
255
- /*# sourceMappingURL=sourcemap_uri */
256
- CSS
257
- map = sourcemap.to_json(:css_uri => 'css_uri')
258
- assert_equal <<JSON.strip, map
259
- {
260
- "version": 3,
261
- "mappings": "AACA,OAAQ",
262
- "sources": ["source_uri"],
263
- "names": [],
264
- "file": "css_uri"
265
- }
266
- JSON
267
- end
268
-
269
- def test_source_map_with_only_css_uri_falls_back_to_file_uris
270
- file_system_importer = Sass::Importers::Filesystem.new('.')
271
- options = {
272
- :filename => filename_for_test(:scss),
273
- :sourcemap_filename => sourcemap_filename_for_test,
274
- :importer => file_system_importer,
275
- :syntax => :scss
276
- }
277
-
278
- engine = Sass::Engine.new(<<SCSS, options)
279
- .foo {a: b}
280
- SCSS
281
-
282
- _, sourcemap = engine.render_with_sourcemap('http://1.example.com/style.map')
283
-
284
- uri = Sass::Util.file_uri_from_path(File.absolute_path(filename_for_test(:scss)))
285
- assert_equal <<JSON.strip, sourcemap.to_json(:css_uri => 'css_uri')
286
- {
287
- "version": 3,
288
- "mappings": "AAAA,IAAK;EAAC,CAAC,EAAE,CAAC",
289
- "sources": ["#{uri}"],
290
- "names": [],
291
- "file": "css_uri"
292
- }
293
- JSON
294
- end
295
-
296
- def test_source_map_with_css_uri_and_css_path_falls_back_to_file_uris
297
- file_system_importer = Sass::Importers::Filesystem.new('.')
298
- options = {
299
- :filename => filename_for_test(:scss),
300
- :sourcemap_filename => sourcemap_filename_for_test,
301
- :importer => file_system_importer,
302
- :syntax => :scss
303
- }
304
-
305
- engine = Sass::Engine.new(<<SCSS, options)
306
- .foo {a: b}
307
- SCSS
308
-
309
- _, sourcemap = engine.render_with_sourcemap('http://1.example.com/style.map')
310
-
311
- uri = Sass::Util.file_uri_from_path(File.absolute_path(filename_for_test(:scss)))
312
- assert_equal <<JSON.strip, sourcemap.to_json(:css_uri => 'css_uri', :css_path => 'css_path')
313
- {
314
- "version": 3,
315
- "mappings": "AAAA,IAAK;EAAC,CAAC,EAAE,CAAC",
316
- "sources": ["#{uri}"],
317
- "names": [],
318
- "file": "css_uri"
319
- }
320
- JSON
321
- end
322
-
323
- def test_source_map_with_css_uri_and_sourcemap_path_supports_filesystem_importer
324
- file_system_importer = Sass::Importers::Filesystem.new('.')
325
- css_uri = 'css_uri'
326
- sourcemap_path = 'map/style.map'
327
- options = {
328
- :filename => 'sass/style.scss',
329
- :sourcemap_filename => sourcemap_path,
330
- :importer => file_system_importer,
331
- :syntax => :scss
332
- }
333
-
334
- engine = Sass::Engine.new(<<SCSS, options)
335
- .foo {a: b}
336
- SCSS
337
-
338
- rendered, sourcemap = engine.render_with_sourcemap('http://1.example.com/style.map')
339
-
340
-
341
- rendered, sourcemap = engine.render_with_sourcemap('http://map.example.com/map/style.map')
342
- assert_equal <<JSON.strip, sourcemap.to_json(:css_uri => css_uri, :sourcemap_path => sourcemap_path)
343
- {
344
- "version": 3,
345
- "mappings": "AAAA,IAAK;EAAC,CAAC,EAAE,CAAC",
346
- "sources": ["../sass/style.scss"],
347
- "names": [],
348
- "file": "css_uri"
349
- }
350
- JSON
351
- end
352
-
353
- def test_source_map_with_css_path_and_sourcemap_path_supports_file_system_importer
354
- file_system_importer = Sass::Importers::Filesystem.new('.')
355
- sass_path = 'sass/style.scss'
356
- css_path = 'static/style.css'
357
- sourcemap_path = 'map/style.map'
358
- options = {
359
- :filename => sass_path,
360
- :sourcemap_filename => sourcemap_path,
361
- :importer => file_system_importer,
362
- :syntax => :scss
363
- }
364
-
365
- engine = Sass::Engine.new(<<SCSS, options)
366
- .foo {a: b}
367
- SCSS
368
-
369
- _, sourcemap = engine.render_with_sourcemap('http://map.example.com/map/style.map')
370
- assert_equal <<JSON.strip, sourcemap.to_json(:css_path => css_path, :sourcemap_path => sourcemap_path)
371
- {
372
- "version": 3,
373
- "mappings": "AAAA,IAAK;EAAC,CAAC,EAAE,CAAC",
374
- "sources": ["../sass/style.scss"],
375
- "names": [],
376
- "file": "../static/style.css"
377
- }
378
- JSON
379
- end
380
-
381
- def test_render_with_sourcemap_requires_filename
382
- file_system_importer = Sass::Importers::Filesystem.new('.')
383
- engine = Sass::Engine.new(".foo {a: b}", :syntax => :scss, :importer => file_system_importer)
384
- assert_raise_message(Sass::SyntaxError, <<MESSAGE) {engine.render_with_sourcemap('sourcemap_url')}
385
- Error generating source map: couldn't determine public URL for the source stylesheet.
386
- No filename is available so there's nothing for the source map to link to.
387
- MESSAGE
388
- end
389
-
390
- def test_render_with_sourcemap_requires_importer_with_public_url
391
- class_importer = ClassImporter.new({"pear" => "color: green;"}, {"pear" => Time.now})
392
- assert_raise_message(Sass::SyntaxError, <<MESSAGE) {class_importer.find("pear", {}).render_with_sourcemap('sourcemap_url')}
393
- Error generating source map: couldn't determine public URL for "pear".
394
- Without a public URL, there's nothing for the source map to link to.
395
- Custom importers should define the #public_url method.
396
- MESSAGE
397
- end
398
-
399
- def fixture_dir
400
- File.join(File.dirname(__FILE__), "fixtures")
401
- end
402
-
403
- def fixture_file(path)
404
- File.join(fixture_dir, path)
405
- end
406
-
407
- def test_filesystem_importer_eql
408
- importer = Sass::Importers::Filesystem.new('.')
409
- assert importer.eql?(Sass::Importers::Filesystem.new('.'))
410
- assert importer.eql?(ReversedExtImporter.new('.'))
411
- assert !importer.eql?(Sass::Importers::Filesystem.new('foo'))
412
- assert !importer.eql?(nil)
413
- assert !importer.eql?('foo')
414
- end
415
-
416
- def test_absolute_files_across_template_locations
417
- importer = Sass::Importers::Filesystem.new(absolutize 'templates')
418
- refute_nil importer.mtime(absolutize('more_templates/more1.sass'), {})
419
- end
420
- end
@@ -1,57 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require 'pathname'
3
-
4
- class LoggerTest < MiniTest::Test
5
-
6
- class InterceptedLogger < Sass::Logger::Base
7
-
8
- attr_accessor :messages
9
-
10
- def initialize(*args)
11
- super
12
- self.messages = []
13
- end
14
-
15
- def reset!
16
- self.messages = []
17
- end
18
-
19
- def _log(*args)
20
- messages << [args]
21
- end
22
-
23
- end
24
-
25
- def test_global_sass_logger_instance_exists
26
- assert Sass.logger.respond_to?(:warn)
27
- end
28
-
29
- def test_log_level_orders
30
- logged_levels = {
31
- :trace => [ [], [:trace, :debug, :info, :warn, :error]],
32
- :debug => [ [:trace], [:debug, :info, :warn, :error]],
33
- :info => [ [:trace, :debug], [:info, :warn, :error]],
34
- :warn => [ [:trace, :debug, :info], [:warn, :error]],
35
- :error => [ [:trace, :debug, :info, :warn], [:error]]
36
- }
37
- logged_levels.each do |level, (should_not_be_logged, should_be_logged)|
38
- logger = Sass::Logger::Base.new(level)
39
- should_not_be_logged.each do |should_level|
40
- assert !logger.logging_level?(should_level)
41
- end
42
- should_be_logged.each do |should_level|
43
- assert logger.logging_level?(should_level)
44
- end
45
- end
46
- end
47
-
48
- def test_logging_can_be_disabled
49
- logger = InterceptedLogger.new
50
- logger.error("message #1")
51
- assert_equal 1, logger.messages.size
52
- logger.reset!
53
- logger.disabled = true
54
- logger.error("message #2")
55
- assert_equal 0, logger.messages.size
56
- end
57
- end