sass 3.5.2 → 3.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) 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/extra/sass-spec-ref.sh +9 -1
  8. data/lib/sass/engine.rb +1 -9
  9. data/lib/sass/exec/base.rb +0 -2
  10. data/lib/sass/exec/sass_scss.rb +1 -5
  11. data/lib/sass/importers/filesystem.rb +4 -2
  12. data/lib/sass/logger/base.rb +11 -0
  13. data/lib/sass/script/css_parser.rb +4 -1
  14. data/lib/sass/script/functions.rb +76 -41
  15. data/lib/sass/script/lexer.rb +62 -19
  16. data/lib/sass/script/parser.rb +260 -93
  17. data/lib/sass/script/tree/funcall.rb +0 -4
  18. data/lib/sass/script/tree/interpolation.rb +0 -3
  19. data/lib/sass/script/tree/operation.rb +1 -1
  20. data/lib/sass/script/value/color.rb +3 -2
  21. data/lib/sass/script/value/helpers.rb +8 -2
  22. data/lib/sass/script/value/number.rb +2 -1
  23. data/lib/sass/scss/css_parser.rb +6 -1
  24. data/lib/sass/scss/parser.rb +48 -18
  25. data/lib/sass/scss/rx.rb +1 -1
  26. data/lib/sass/scss/static_parser.rb +15 -18
  27. data/lib/sass/selector/comma_sequence.rb +2 -1
  28. data/lib/sass/selector/pseudo.rb +1 -1
  29. data/lib/sass/selector/sequence.rb +0 -4
  30. data/lib/sass/source/map.rb +0 -4
  31. data/lib/sass/tree/rule_node.rb +3 -6
  32. data/lib/sass/tree/visitors/perform.rb +2 -6
  33. data/lib/sass/tree/visitors/to_css.rb +4 -11
  34. data/lib/sass/util.rb +60 -20
  35. data/lib/sass/version.rb +0 -2
  36. metadata +38 -162
  37. data/Rakefile +0 -338
  38. data/lib/test.css +0 -4
  39. data/lib/test.css.map +0 -7
  40. data/test/sass-spec.yml +0 -3
  41. data/test/sass/cache_test.rb +0 -130
  42. data/test/sass/callbacks_test.rb +0 -60
  43. data/test/sass/compiler_test.rb +0 -225
  44. data/test/sass/conversion_test.rb +0 -2138
  45. data/test/sass/css2sass_test.rb +0 -523
  46. data/test/sass/css_variable_test.rb +0 -237
  47. data/test/sass/data/hsl-rgb.txt +0 -319
  48. data/test/sass/encoding_test.rb +0 -188
  49. data/test/sass/engine_test.rb +0 -3499
  50. data/test/sass/exec_test.rb +0 -95
  51. data/test/sass/extend_test.rb +0 -1678
  52. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  53. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  54. data/test/sass/functions_test.rb +0 -2021
  55. data/test/sass/importer_test.rb +0 -420
  56. data/test/sass/logger_test.rb +0 -57
  57. data/test/sass/mock_importer.rb +0 -49
  58. data/test/sass/more_results/more1.css +0 -9
  59. data/test/sass/more_results/more1_with_line_comments.css +0 -26
  60. data/test/sass/more_results/more_import.css +0 -29
  61. data/test/sass/more_templates/_more_partial.sass +0 -2
  62. data/test/sass/more_templates/more1.sass +0 -23
  63. data/test/sass/more_templates/more_import.sass +0 -11
  64. data/test/sass/plugin_test.rb +0 -552
  65. data/test/sass/results/alt.css +0 -4
  66. data/test/sass/results/basic.css +0 -9
  67. data/test/sass/results/cached_import_option.css +0 -3
  68. data/test/sass/results/compact.css +0 -5
  69. data/test/sass/results/complex.css +0 -86
  70. data/test/sass/results/compressed.css +0 -1
  71. data/test/sass/results/expanded.css +0 -19
  72. data/test/sass/results/filename_fn.css +0 -3
  73. data/test/sass/results/if.css +0 -3
  74. data/test/sass/results/import.css +0 -31
  75. data/test/sass/results/import_charset.css +0 -5
  76. data/test/sass/results/import_charset_ibm866.css +0 -5
  77. data/test/sass/results/import_content.css +0 -1
  78. data/test/sass/results/line_numbers.css +0 -49
  79. data/test/sass/results/mixins.css +0 -95
  80. data/test/sass/results/multiline.css +0 -24
  81. data/test/sass/results/nested.css +0 -22
  82. data/test/sass/results/options.css +0 -1
  83. data/test/sass/results/parent_ref.css +0 -13
  84. data/test/sass/results/script.css +0 -16
  85. data/test/sass/results/scss_import.css +0 -31
  86. data/test/sass/results/scss_importee.css +0 -2
  87. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  88. data/test/sass/results/subdir/subdir.css +0 -3
  89. data/test/sass/results/units.css +0 -11
  90. data/test/sass/results/warn.css +0 -0
  91. data/test/sass/results/warn_imported.css +0 -0
  92. data/test/sass/script_conversion_test.rb +0 -365
  93. data/test/sass/script_test.rb +0 -1429
  94. data/test/sass/scss/css_test.rb +0 -1266
  95. data/test/sass/scss/rx_test.rb +0 -159
  96. data/test/sass/scss/scss_test.rb +0 -4238
  97. data/test/sass/scss/test_helper.rb +0 -37
  98. data/test/sass/source_map_test.rb +0 -1052
  99. data/test/sass/superselector_test.rb +0 -209
  100. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  101. data/test/sass/templates/_double_import_loop2.sass +0 -1
  102. data/test/sass/templates/_filename_fn_import.scss +0 -11
  103. data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  104. data/test/sass/templates/_imported_charset_utf8.sass +0 -4
  105. data/test/sass/templates/_imported_content.sass +0 -3
  106. data/test/sass/templates/_partial.sass +0 -2
  107. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  108. data/test/sass/templates/alt.sass +0 -16
  109. data/test/sass/templates/basic.sass +0 -23
  110. data/test/sass/templates/bork1.sass +0 -2
  111. data/test/sass/templates/bork2.sass +0 -2
  112. data/test/sass/templates/bork3.sass +0 -2
  113. data/test/sass/templates/bork4.sass +0 -2
  114. data/test/sass/templates/bork5.sass +0 -3
  115. data/test/sass/templates/cached_import_option.scss +0 -3
  116. data/test/sass/templates/compact.sass +0 -17
  117. data/test/sass/templates/complex.sass +0 -305
  118. data/test/sass/templates/compressed.sass +0 -15
  119. data/test/sass/templates/double_import_loop1.sass +0 -1
  120. data/test/sass/templates/expanded.sass +0 -17
  121. data/test/sass/templates/filename_fn.scss +0 -18
  122. data/test/sass/templates/if.sass +0 -11
  123. data/test/sass/templates/import.sass +0 -12
  124. data/test/sass/templates/import_charset.sass +0 -9
  125. data/test/sass/templates/import_charset_ibm866.sass +0 -11
  126. data/test/sass/templates/import_content.sass +0 -4
  127. data/test/sass/templates/importee.less +0 -2
  128. data/test/sass/templates/importee.sass +0 -19
  129. data/test/sass/templates/line_numbers.sass +0 -13
  130. data/test/sass/templates/mixin_bork.sass +0 -5
  131. data/test/sass/templates/mixins.sass +0 -76
  132. data/test/sass/templates/multiline.sass +0 -20
  133. data/test/sass/templates/nested.sass +0 -25
  134. data/test/sass/templates/nested_bork1.sass +0 -2
  135. data/test/sass/templates/nested_bork2.sass +0 -2
  136. data/test/sass/templates/nested_bork3.sass +0 -2
  137. data/test/sass/templates/nested_bork4.sass +0 -2
  138. data/test/sass/templates/nested_import.sass +0 -2
  139. data/test/sass/templates/nested_mixin_bork.sass +0 -6
  140. data/test/sass/templates/options.sass +0 -2
  141. data/test/sass/templates/parent_ref.sass +0 -25
  142. data/test/sass/templates/same_name_different_ext.sass +0 -2
  143. data/test/sass/templates/same_name_different_ext.scss +0 -1
  144. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  145. data/test/sass/templates/script.sass +0 -101
  146. data/test/sass/templates/scss_import.scss +0 -12
  147. data/test/sass/templates/scss_importee.scss +0 -1
  148. data/test/sass/templates/single_import_loop.sass +0 -1
  149. data/test/sass/templates/subdir/import_up1.scss +0 -1
  150. data/test/sass/templates/subdir/import_up2.scss +0 -1
  151. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  152. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  153. data/test/sass/templates/subdir/subdir.sass +0 -6
  154. data/test/sass/templates/units.sass +0 -11
  155. data/test/sass/templates/warn.sass +0 -3
  156. data/test/sass/templates/warn_imported.sass +0 -4
  157. data/test/sass/test_helper.rb +0 -8
  158. data/test/sass/util/multibyte_string_scanner_test.rb +0 -152
  159. data/test/sass/util/normalized_map_test.rb +0 -50
  160. data/test/sass/util/subset_map_test.rb +0 -90
  161. data/test/sass/util_test.rb +0 -403
  162. data/test/sass/value_helpers_test.rb +0 -178
  163. data/test/test_helper.rb +0 -149
data/Rakefile DELETED
@@ -1,338 +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', :rubocop]
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
- begin
114
- require 'rubocop/rake_task'
115
- RuboCop = Rubocop unless defined?(RuboCop)
116
- RuboCop::RakeTask.new do |t|
117
- t.patterns = FileList["lib/**/*"]
118
- end
119
- rescue LoadError
120
- task :rubocop do
121
- puts "Rubocop is disabled."
122
- puts "Passing this check is required in order for your patch to be accepted."
123
- puts "Install Rubocop and then run the style check with: rake rubocop."
124
- end
125
- end
126
-
127
- # ----- Packaging -----
128
-
129
- # Don't use Rake::GemPackageTast because we want prerequisites to run
130
- # before we load the gemspec.
131
- desc "Build all the packages."
132
- task :package => [:revision_file, :date_file, :permissions] do
133
- version = get_version
134
- File.open(scope('VERSION'), 'w') {|f| f.puts(version)}
135
- load scope('sass.gemspec')
136
- Gem::Package.build(SASS_GEMSPEC)
137
- sh %{git checkout VERSION}
138
-
139
- pkg = "#{SASS_GEMSPEC.name}-#{SASS_GEMSPEC.version}"
140
- mkdir_p "pkg"
141
- verbose(true) {mv "#{pkg}.gem", "pkg/#{pkg}.gem"}
142
-
143
- sh %{rm -f pkg/#{pkg}.tar.gz}
144
- verbose(false) {SASS_GEMSPEC.files.each {|f| sh %{tar rf pkg/#{pkg}.tar #{f}}}}
145
- sh %{gzip pkg/#{pkg}.tar}
146
- end
147
-
148
- task :permissions do
149
- sh %{chmod -R a+rx bin}
150
- sh %{chmod -R a+r .}
151
- require 'shellwords'
152
- Dir.glob('test/**/*_test.rb') do |file|
153
- next if file =~ %r{^test/haml/spec/}
154
- sh %{chmod a+rx #{file}}
155
- end
156
- end
157
-
158
- task :revision_file do
159
- require scope('lib/sass')
160
-
161
- release = Rake.application.top_level_tasks.include?('release') || File.exist?(scope('EDGE_GEM_VERSION'))
162
- if Sass.version[:rev] && !release
163
- File.open(scope('REVISION'), 'w') { |f| f.puts Sass.version[:rev] }
164
- elsif release
165
- File.open(scope('REVISION'), 'w') { |f| f.puts "(release)" }
166
- else
167
- File.open(scope('REVISION'), 'w') { |f| f.puts "(unknown)" }
168
- end
169
- end
170
-
171
- task :date_file do
172
- File.open(scope('VERSION_DATE'), 'w') do |f|
173
- f.puts Time.now.utc.strftime('%d %B %Y %T %Z')
174
- end
175
- end
176
-
177
- # We also need to get rid of this file after packaging.
178
- at_exit do
179
- File.delete(scope('REVISION')) rescue nil
180
- File.delete(scope('VERSION_DATE')) rescue nil
181
- end
182
-
183
- desc "Install Sass as a gem. Use SUDO=1 to install with sudo."
184
- task :install => [:package] do
185
- gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem'
186
- sh %{#{'sudo ' if ENV["SUDO"]}#{gem} install --no-ri pkg/sass-#{get_version}}
187
- end
188
-
189
- desc "Release a new Sass package to RubyGems.org."
190
- task :release => [:check_release, :package] do
191
- version = File.read(scope("VERSION")).strip
192
- sh %{gem push pkg/sass-#{version}.gem}
193
- end
194
-
195
- # Ensures that the VERSION file has been updated for a new release.
196
- task :check_release do
197
- version = File.read(scope("VERSION")).strip
198
- raise "There have been changes since current version (#{version})" if changed_since?(version)
199
- raise "VERSION_NAME must not be 'Bleeding Edge'" if File.read(scope("VERSION_NAME")) == "Bleeding Edge"
200
- end
201
-
202
- # Reads a password from the command line.
203
- #
204
- # @param name [String] The prompt to use to read the password
205
- def read_password(prompt)
206
- require 'readline'
207
- system "stty -echo"
208
- Readline.readline("#{prompt}: ").strip
209
- ensure
210
- system "stty echo"
211
- puts
212
- end
213
-
214
- # Returns whether or not the repository, or specific files,
215
- # has/have changed since a given revision.
216
- #
217
- # @param rev [String] The revision to check against
218
- # @param files [Array<String>] The files to check.
219
- # If this is empty, checks the entire repository
220
- def changed_since?(rev, *files)
221
- IO.popen("git diff --exit-code #{rev} #{files.join(' ')}") {}
222
- return !$?.success?
223
- end
224
-
225
- # Get the version string. If this is being installed from Git,
226
- # this includes the proper prerelease version.
227
- def get_version
228
- File.read(scope('VERSION').strip)
229
- end
230
-
231
- task :watch_for_update do
232
- sh %{ruby extra/update_watch.rb}
233
- end
234
-
235
- # ----- Documentation -----
236
-
237
- task :rdoc do
238
- puts '=' * 100, <<END, '=' * 100
239
- Sass uses the YARD documentation system (http://github.com/lsegal/yard).
240
- Install the yard gem and then run "rake doc".
241
- END
242
- end
243
-
244
- begin
245
- require 'yard'
246
-
247
- namespace :doc do
248
- task :sass do
249
- require scope('lib/sass')
250
- Dir[scope("yard/default/**/*.sass")].each do |sass|
251
- File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
252
- f.write(Sass::Engine.new(File.read(sass)).render)
253
- end
254
- end
255
- end
256
-
257
- desc "List all undocumented methods and classes."
258
- task :undocumented do
259
- opts = ENV["YARD_OPTS"] || ""
260
- ENV["YARD_OPTS"] = opts.dup + <<OPTS
261
- --list --tag comment --hide-tag comment --query "
262
- object.docstring.blank? &&
263
- !(object.type == :method && object.is_alias?)"
264
- OPTS
265
- Rake::Task['yard'].execute
266
- end
267
- end
268
-
269
- YARD::Rake::YardocTask.new do |t|
270
- t.files = FileList.new(scope('lib/**/*.rb')) do |list|
271
- list.exclude('lib/sass/plugin/merb.rb')
272
- list.exclude('lib/sass/plugin/rails.rb')
273
- end.to_a
274
- t.options << '--incremental' if Rake.application.top_level_tasks.include?('redoc')
275
- t.options += FileList.new(scope('yard/*.rb')).to_a.map {|f| ['-e', f]}.flatten
276
- files = FileList.new(scope('doc-src/*')).to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
277
- t.options << '--files' << files.join(',')
278
- t.options << '--template-path' << scope('yard')
279
- t.options << '--title' << ENV["YARD_TITLE"] if ENV["YARD_TITLE"]
280
-
281
- t.before = lambda do
282
- if ENV["YARD_OPTS"]
283
- require 'shellwords'
284
- t.options.concat(Shellwords.shellwords(ENV["YARD_OPTS"]))
285
- end
286
- end
287
- end
288
- Rake::Task['yard'].prerequisites.insert(0, 'doc:sass')
289
- Rake::Task['yard'].instance_variable_set('@comment', nil)
290
-
291
- desc "Generate Documentation"
292
- task :doc => :yard
293
- task :redoc => :yard
294
- rescue LoadError
295
- desc "Generate Documentation"
296
- task :doc => :rdoc
297
- task :yard => :rdoc
298
- end
299
-
300
- # ----- Coverage -----
301
-
302
- begin
303
- require 'rcov/rcovtask'
304
-
305
- Rcov::RcovTask.new do |t|
306
- t.test_files = FileList[scope('test/**/*_test.rb')]
307
- t.rcov_opts << '-x' << '"^\/"'
308
- if ENV['NON_NATIVE']
309
- t.rcov_opts << "--no-rcovrt"
310
- end
311
- t.verbose = true
312
- end
313
- rescue LoadError; end
314
-
315
- # ----- Profiling -----
316
-
317
- begin
318
- require 'ruby-prof'
319
-
320
- desc <<END
321
- Run a profile of sass.
322
- TIMES=n sets the number of runs. Defaults to 1000.
323
- FILE=str sets the file to profile. Defaults to 'complex'.
324
- OUTPUT=str sets the ruby-prof output format.
325
- Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
326
- END
327
- task :profile do
328
- times = (ENV['TIMES'] || '1000').to_i
329
- file = ENV['FILE']
330
-
331
- require 'lib/sass'
332
-
333
- file = File.read(scope("test/sass/templates/#{file || 'complex'}.sass"))
334
- result = RubyProf.profile { times.times { Sass::Engine.new(file).render } }
335
-
336
- RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
337
- end
338
- rescue LoadError; end
@@ -1,4 +0,0 @@
1
- a {
2
- b: c; }
3
-
4
- /*# sourceMappingURL=test.css.map */
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "mappings": "AAAA,CAAE;EAAC,CAAC,EAAE,CAAC",
4
- "sources": ["test.scss"],
5
- "names": [],
6
- "file": "test.css"
7
- }
@@ -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