sass 3.6.0 → 3.7.0

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 (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
data/Rakefile DELETED
@@ -1,364 +0,0 @@
1
- require 'rubygems/package'
2
-
3
- # ----- Utility Functions -----
4
-
5
- def scope(path)
6
- File.join(File.dirname(__FILE__), path)
7
- end
8
-
9
- # ----- Default: Testing ------
10
-
11
- task :default => :test
12
-
13
- require 'rake/testtask'
14
-
15
- LINE_SIZE = 80
16
- DECORATION_CHAR = '#'
17
-
18
- def print_header(string)
19
- length = string.length
20
- puts DECORATION_CHAR * LINE_SIZE
21
- puts string.center(length + 2, ' ').center(LINE_SIZE, DECORATION_CHAR)
22
- puts DECORATION_CHAR * LINE_SIZE
23
- end
24
-
25
- desc "Run all tests"
26
- task :test do
27
- test_cases = [
28
- {
29
- 'env' => {'MATHN' => 'true'},
30
- 'tasks' => ['test:ruby', 'test:spec']
31
- },
32
- {
33
- 'env' => {'MATHN' => 'false'},
34
- 'tasks' => ['test:ruby']
35
- }
36
- ]
37
-
38
- test_cases.each do |test_case|
39
- env = test_case['env']
40
- tasks = test_case['tasks']
41
-
42
- env.each do |key, value|
43
- ENV[key] = value
44
- end
45
- tasks.each do |task|
46
- print_header("Running task: #{task}, env: #{env}")
47
- Rake::Task[task].execute
48
- end
49
- end
50
- end
51
-
52
- namespace :test do
53
- desc "Run the ruby tests (without sass-spec)"
54
- Rake::TestTask.new("ruby") do |t|
55
- t.libs << 'test'
56
- test_files = FileList[scope('test/**/*_test.rb')]
57
- test_files.exclude(scope('test/rails/*'))
58
- test_files.exclude(scope('test/plugins/*'))
59
- t.test_files = test_files
60
- t.warning = true
61
- t.verbose = true
62
- end
63
-
64
- desc "Run sass-spec tests against the local code."
65
- task :spec do
66
- require "yaml"
67
- sass_spec_options = YAML.load_file(scope("test/sass-spec.yml"))
68
- enabled = sass_spec_options.delete(:enabled)
69
- unless enabled
70
- puts "SassSpec tests are disabled."
71
- next
72
- end
73
- if ruby_version_at_least?("1.9.2")
74
- old_load_path = $:.dup
75
- begin
76
- $:.unshift(File.join(File.dirname(__FILE__), "lib"))
77
- begin
78
- require 'sass_spec'
79
- rescue LoadError
80
- puts "You probably forgot to run: bundle exec rake"
81
- raise
82
- end
83
- default_options = {
84
- :spec_directory => SassSpec::SPEC_DIR,
85
- :engine_adapter => SassEngineAdapter.new,
86
- :generate => false,
87
- :tap => false,
88
- :skip => false,
89
- :verbose => false,
90
- :filter => "",
91
- :limit => -1,
92
- :unexpected_pass => false,
93
- :nuke => false,
94
- }
95
- SassSpec::Runner.new(default_options.merge(sass_spec_options)).run || exit(1)
96
- ensure
97
- $:.replace(old_load_path)
98
- end
99
- else
100
- "Skipping sass-spec on ruby versions less than 1.9.2"
101
- end
102
- end
103
- end
104
-
105
- # ----- Code Style Enforcement -----
106
-
107
- def ruby_version_at_least?(version_string)
108
- ruby_version = Gem::Version.new(RUBY_VERSION.dup)
109
- version = Gem::Version.new(version_string)
110
- ruby_version >= version
111
- end
112
-
113
- # ----- Packaging -----
114
-
115
- # Don't use Rake::GemPackageTast because we want prerequisites to run
116
- # before we load the gemspec.
117
- desc "Build all the packages."
118
- task :package => [:revision_file, :date_file, :permissions] do
119
- version = get_version
120
- File.open(scope('VERSION'), 'w') {|f| f.puts(version)}
121
- load scope('sass.gemspec')
122
- Gem::Package.build(SASS_GEMSPEC)
123
- sh %{git checkout VERSION}
124
-
125
- pkg = "#{SASS_GEMSPEC.name}-#{SASS_GEMSPEC.version}"
126
- mkdir_p "pkg"
127
- verbose(true) {mv "#{pkg}.gem", "pkg/#{pkg}.gem"}
128
-
129
- sh %{rm -f pkg/#{pkg}.tar.gz}
130
- verbose(false) {SASS_GEMSPEC.files.each {|f| sh %{tar rf pkg/#{pkg}.tar #{f}}}}
131
- sh %{gzip pkg/#{pkg}.tar}
132
- end
133
-
134
- task :permissions do
135
- sh %{chmod -R a+rx bin}
136
- sh %{chmod -R a+r .}
137
- require 'shellwords'
138
- Dir.glob('test/**/*_test.rb') do |file|
139
- next if file =~ %r{^test/haml/spec/}
140
- sh %{chmod a+rx #{file}}
141
- end
142
- end
143
-
144
- task :revision_file do
145
- require scope('lib/sass')
146
-
147
- release = Rake.application.top_level_tasks.include?('release') || File.exist?(scope('EDGE_GEM_VERSION'))
148
- if Sass.version[:rev] && !release
149
- File.open(scope('REVISION'), 'w') { |f| f.puts Sass.version[:rev] }
150
- elsif release
151
- File.open(scope('REVISION'), 'w') { |f| f.puts "(release)" }
152
- else
153
- File.open(scope('REVISION'), 'w') { |f| f.puts "(unknown)" }
154
- end
155
- end
156
-
157
- task :date_file do
158
- File.open(scope('VERSION_DATE'), 'w') do |f|
159
- f.puts Time.now.utc.strftime('%d %B %Y %T %Z')
160
- end
161
- end
162
-
163
- # We also need to get rid of this file after packaging.
164
- at_exit do
165
- File.delete(scope('REVISION')) rescue nil
166
- File.delete(scope('VERSION_DATE')) rescue nil
167
- end
168
-
169
- desc "Install Sass as a gem. Use SUDO=1 to install with sudo."
170
- task :install => [:package] do
171
- gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem'
172
- sh %{#{'sudo ' if ENV["SUDO"]}#{gem} install --no-ri pkg/sass-#{get_version}}
173
- end
174
-
175
- desc "Release a new Sass package to RubyGems.org."
176
- task :release => [:check_release, :package] do
177
- version = File.read(scope("VERSION")).strip
178
- sh %{gem push pkg/sass-#{version}.gem}
179
- end
180
-
181
- # Ensures that the VERSION file has been updated for a new release.
182
- task :check_release do
183
- version = File.read(scope("VERSION")).strip
184
- raise "There have been changes since current version (#{version})" if changed_since?(version)
185
- raise "VERSION_NAME must not be 'Bleeding Edge'" if File.read(scope("VERSION_NAME")) == "Bleeding Edge"
186
- end
187
-
188
- # Reads a password from the command line.
189
- #
190
- # @param name [String] The prompt to use to read the password
191
- def read_password(prompt)
192
- require 'readline'
193
- system "stty -echo"
194
- Readline.readline("#{prompt}: ").strip
195
- ensure
196
- system "stty echo"
197
- puts
198
- end
199
-
200
- # Returns whether or not the repository, or specific files,
201
- # has/have changed since a given revision.
202
- #
203
- # @param rev [String] The revision to check against
204
- # @param files [Array<String>] The files to check.
205
- # If this is empty, checks the entire repository
206
- def changed_since?(rev, *files)
207
- IO.popen("git diff --exit-code #{rev} #{files.join(' ')}") {}
208
- return !$?.success?
209
- end
210
-
211
- # Get the version string. If this is being installed from Git,
212
- # this includes the proper prerelease version.
213
- def get_version
214
- File.read(scope('VERSION').strip)
215
- end
216
-
217
- task :watch_for_update do
218
- sh %{ruby extra/update_watch.rb}
219
- end
220
-
221
- # ----- Documentation -----
222
-
223
- task :rdoc do
224
- puts '=' * 100, <<END, '=' * 100
225
- Sass uses the YARD documentation system (http://github.com/lsegal/yard).
226
- Install the yard gem and then run "rake doc".
227
- END
228
- end
229
-
230
- begin
231
- require 'yard'
232
-
233
- namespace :doc do
234
- task :sass do
235
- require scope('lib/sass')
236
- Dir[scope("yard/default/**/*.sass")].each do |sass|
237
- File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
238
- f.write(Sass::Engine.new(File.read(sass)).render)
239
- end
240
- end
241
- end
242
-
243
- desc "List all undocumented methods and classes."
244
- task :undocumented do
245
- opts = ENV["YARD_OPTS"] || ""
246
- ENV["YARD_OPTS"] = opts.dup + <<OPTS
247
- --list --tag comment --hide-tag comment --query "
248
- object.docstring.blank? &&
249
- !(object.type == :method && object.is_alias?)"
250
- OPTS
251
- Rake::Task['yard'].execute
252
- end
253
-
254
- # Add IDs to the reference to match the old IDs generated by Maruku. This
255
- # ensures that old anchored links continue to work.
256
- task :add_ids do
257
- require 'nokogiri'
258
-
259
- doc = Nokogiri::HTML(File.read('doc/file.SASS_REFERENCE.html'))
260
-
261
- doc.css("#filecontents").css("h1, h2, h3, h4, h5, h6").each do |h|
262
- next if h.inner_text.empty?
263
- h['id'] =
264
- case h.inner_text
265
- when "Referencing Parent Selectors: &"; "parent-selector"
266
- when /^Comments:/; "comments"
267
- when "Strings"; "sass-script-strings"
268
- when "Division and /"; "division-and-slash"
269
- when /^Subtraction,/; "subtraction"
270
- when "& in SassScript"; "parent-script"
271
- when "@-Rules and Directives"; "directives"
272
- when "@extend-Only Selectors"; "placeholders"
273
- when "@extend-Only Selectors"; "placeholders"
274
- when "@each"; "each-directive"
275
- when "Multiple Assignment"; "each-multi-assign"
276
- when "Mixin Directives"; "mixins"
277
- when /^Defining a Mixin:/; "defining_a_mixin"
278
- when /^Including a Mixin:/; "including_a_mixin"
279
- when "Arguments"; "mixin-arguments"
280
- when "Passing Content Blocks to a Mixin"; "mixin-content"
281
- else
282
- h.inner_text.downcase.gsub(/[^a-z _-]/, '').gsub(' ', '_')
283
- end
284
- end
285
-
286
- # Give each option an anchor.
287
- doc.css("#filecontents li p strong code").each do |c|
288
- c['id'] = c.inner_text.gsub(/:/, '') + '-option'
289
- end
290
-
291
- File.write('doc/file.SASS_REFERENCE.html', doc.to_html)
292
- end
293
- end
294
-
295
- YARD::Rake::YardocTask.new do |t|
296
- t.files = FileList.new(scope('lib/**/*.rb')) do |list|
297
- list.exclude('lib/sass/plugin/merb.rb')
298
- list.exclude('lib/sass/plugin/rails.rb')
299
- end.to_a
300
- t.options << '--incremental' if Rake.application.top_level_tasks.include?('redoc')
301
- t.options += FileList.new(scope('yard/*.rb')).to_a.map {|f| ['-e', f]}.flatten
302
- files = FileList.new(scope('doc-src/*')).to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
303
- t.options << '--files' << files.join(',')
304
- t.options << '--template-path' << scope('yard')
305
- t.options << '--title' << ENV["YARD_TITLE"] if ENV["YARD_TITLE"]
306
-
307
- t.before = lambda do
308
- if ENV["YARD_OPTS"]
309
- require 'shellwords'
310
- t.options.concat(Shellwords.shellwords(ENV["YARD_OPTS"]))
311
- end
312
- end
313
- end
314
- Rake::Task['yard'].prerequisites.insert(0, 'doc:sass')
315
- Rake::Task['yard'].instance_variable_set('@comment', nil)
316
-
317
- desc "Generate Documentation"
318
- task :doc => [:yard, 'doc:add_ids']
319
- task :redoc => [:yard, 'doc:add_ids']
320
- rescue LoadError
321
- desc "Generate Documentation"
322
- task :doc => :rdoc
323
- task :yard => :rdoc
324
- end
325
-
326
- # ----- Coverage -----
327
-
328
- begin
329
- require 'rcov/rcovtask'
330
-
331
- Rcov::RcovTask.new do |t|
332
- t.test_files = FileList[scope('test/**/*_test.rb')]
333
- t.rcov_opts << '-x' << '"^\/"'
334
- if ENV['NON_NATIVE']
335
- t.rcov_opts << "--no-rcovrt"
336
- end
337
- t.verbose = true
338
- end
339
- rescue LoadError; end
340
-
341
- # ----- Profiling -----
342
-
343
- begin
344
- require 'ruby-prof'
345
-
346
- desc <<END
347
- Run a profile of sass.
348
- TIMES=n sets the number of runs. Defaults to 1000.
349
- FILE=str sets the file to profile. Defaults to 'complex'.
350
- OUTPUT=str sets the ruby-prof output format.
351
- Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
352
- END
353
- task :profile do
354
- times = (ENV['TIMES'] || '1000').to_i
355
- file = ENV['FILE']
356
-
357
- require 'lib/sass'
358
-
359
- file = File.read(scope("test/sass/templates/#{file || 'complex'}.sass"))
360
- result = RubyProf.profile { times.times { Sass::Engine.new(file).render } }
361
-
362
- RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
363
- end
364
- rescue LoadError; end
@@ -1,3 +0,0 @@
1
- ---
2
- :enabled: true
3
- :language_version: '3.5'
@@ -1,130 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
- require File.dirname(__FILE__) + '/test_helper'
3
- require 'sass/engine'
4
-
5
- class CacheTest < MiniTest::Test
6
- @@cache_dir = "tmp/file_cache"
7
-
8
- def setup
9
- FileUtils.mkdir_p @@cache_dir
10
- end
11
-
12
- def teardown
13
- FileUtils.rm_rf @@cache_dir
14
- clean_up_sassc
15
- end
16
-
17
- def test_file_cache_writes_a_file
18
- file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
19
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
20
- assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
21
- end
22
-
23
- def test_file_cache_reads_a_file
24
- file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
25
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
26
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
27
- assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
28
- assert_kind_of Sass::Tree::RootNode, file_store.retrieve("asdf/foo.scssc", "fakesha1")
29
- end
30
-
31
- def test_file_cache_miss_returns_nil
32
- file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
33
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
34
- assert_nil file_store.retrieve("asdf/foo.scssc", "fakesha1")
35
- end
36
-
37
- def test_sha_change_invalidates_cache_and_cleans_up
38
- file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
39
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
40
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
41
- assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
42
- assert_nil file_store.retrieve("asdf/foo.scssc", "differentsha1")
43
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
44
- end
45
-
46
- def test_version_change_invalidates_cache_and_cleans_up
47
- file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
48
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
49
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
50
- assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
51
- real_version = Sass::VERSION
52
- begin
53
- Sass::VERSION.replace("a different version")
54
- assert_nil file_store.retrieve("asdf/foo.scssc", "fakesha1")
55
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
56
- ensure
57
- Sass::VERSION.replace(real_version)
58
- end
59
- end
60
-
61
- def test_arbitrary_objects_can_go_into_cache
62
- cache = Sass::CacheStores::Memory.new
63
- an_object = {:foo => :bar}
64
- cache.store("an_object", "", an_object)
65
- assert_equal an_object, cache.retrieve("an_object", "")
66
- end
67
-
68
- def test_cache_node_with_unmarshalable_option
69
- engine_with_unmarshalable_options("foo {a: b + c}").to_tree
70
- end
71
-
72
- # Regression tests
73
-
74
- def test_cache_mixin_def_splat_sass_node_with_unmarshalable_option
75
- engine_with_unmarshalable_options(<<SASS, :syntax => :sass).to_tree
76
- =color($args...)
77
- color: red
78
- SASS
79
- end
80
-
81
- def test_cache_mixin_def_splat_scss_node_with_unmarshalable_option
82
- engine_with_unmarshalable_options(<<SCSS, :syntax => :scss).to_tree
83
- @mixin color($args...) {
84
- color: red;
85
- }
86
- SCSS
87
- end
88
-
89
- def test_cache_function_splat_sass_node_with_unmarshalable_option
90
- engine_with_unmarshalable_options(<<SASS, :syntax => :sass).to_tree
91
- @function color($args...)
92
- @return red
93
- SASS
94
- end
95
-
96
- def test_cache_function_splat_scss_node_with_unmarshalable_option
97
- engine_with_unmarshalable_options(<<SCSS, :syntax => :scss).to_tree
98
- @function color($args...) {
99
- @return red;
100
- }
101
- SCSS
102
- end
103
-
104
- def test_cache_include_splat_sass_node_with_unmarshalable_option
105
- engine_with_unmarshalable_options(<<SASS, :syntax => :sass).to_tree
106
- @include color($args..., $kwargs...)
107
- SASS
108
- end
109
-
110
- def test_cache_include_splat_scss_node_with_unmarshalable_option
111
- engine_with_unmarshalable_options(<<SCSS, :syntax => :scss).to_tree
112
- @include color($args..., $kwargs...);
113
- SCSS
114
- end
115
-
116
- private
117
- def root_node
118
- Sass::Engine.new(<<-SCSS, :syntax => :scss).to_tree
119
- @mixin color($c) { color: $c}
120
- div { @include color(red); }
121
- SCSS
122
- end
123
-
124
- def engine_with_unmarshalable_options(src, options={})
125
- Sass::Engine.new(src, {
126
- :syntax => :scss, :object => Class.new.new, :filename => 'file.scss',
127
- :importer => Sass::Importers::Filesystem.new(absolutize('templates'))
128
- }.merge(options))
129
- end
130
- end