test/sass/importer_test.rb in sass-3.3.14 vs test/sass/importer_test.rb in sass-3.4.0.rc.1
- old
+ new
@@ -2,11 +2,11 @@
require File.dirname(__FILE__) + '/../test_helper'
require File.dirname(__FILE__) + '/test_helper'
require 'mock_importer'
require 'sass/plugin'
-class ImporterTest < Test::Unit::TestCase
+class ImporterTest < MiniTest::Test
class FruitImporter < Sass::Importers::Base
def find(name, context = nil)
fruit = parse(name)
return unless fruit
@@ -223,15 +223,15 @@
"file": "css_uri"
}
JSON
end
- def test_source_map_with_only_css_uri_can_have_no_public_url_without_warning
+ def test_source_map_with_only_css_uri_can_have_no_public_url
ephemeral_importer = NoPublicUrlImporter.new
mock_importer = MockImporter.new
def mock_importer.public_url(name, sourcemap_directory = nil)
- "css_uri"
+ "source_uri"
end
options = {
:filename => filename_for_test,
:sourcemap_filename => sourcemap_filename_for_test,
@@ -246,32 +246,30 @@
.orange {
@include orange;
}
SCSS
- assert_warning("") do
- css_output, sourcemap = engine.render_with_sourcemap('sourcemap_uri')
- assert_equal <<CSS.strip, css_output.strip
+ css_output, sourcemap = engine.render_with_sourcemap('sourcemap_uri')
+ assert_equal <<CSS.strip, css_output.strip
.orange {
color: orange; }
/*# sourceMappingURL=sourcemap_uri */
CSS
- map = sourcemap.to_json(:css_uri => 'css_uri')
- assert_equal <<JSON.strip, map
+ map = sourcemap.to_json(:css_uri => 'css_uri')
+ assert_equal <<JSON.strip, map
{
"version": 3,
"mappings": "AACA,OAAQ",
-"sources": ["css_uri"],
+"sources": ["source_uri"],
"names": [],
"file": "css_uri"
}
JSON
- end
end
- def test_source_map_with_only_css_uri_doesnt_support_filesystem_importer
+ def test_source_map_with_only_css_uri_falls_back_to_file_uris
file_system_importer = Sass::Importers::Filesystem.new('.')
options = {
:filename => filename_for_test(:scss),
:sourcemap_filename => sourcemap_filename_for_test,
:importer => file_system_importer,
@@ -282,17 +280,23 @@
.foo {a: b}
SCSS
_, sourcemap = engine.render_with_sourcemap('http://1.example.com/style.map')
- assert_warning(<<WARNING) {sourcemap.to_json(:css_uri => 'css_uri')}
-WARNING: Couldn't determine public URL for "#{filename_for_test(:scss)}" while generating sourcemap.
- Without a public URL, there's nothing for the source map to link to.
-WARNING
+ uri = Sass::Util.file_uri_from_path(Sass::Util.absolute_path(filename_for_test(:scss)))
+ assert_equal <<JSON.strip, sourcemap.to_json(:css_uri => 'css_uri')
+{
+"version": 3,
+"mappings": "AAAA,IAAK;EAAC,CAAC,EAAE,CAAC",
+"sources": ["#{uri}"],
+"names": [],
+"file": "css_uri"
+}
+JSON
end
- def test_source_map_with_css_uri_and_css_path_doesnt_support_filesystem_importer
+ def test_source_map_with_css_uri_and_css_path_falls_back_to_file_uris
file_system_importer = Sass::Importers::Filesystem.new('.')
options = {
:filename => filename_for_test(:scss),
:sourcemap_filename => sourcemap_filename_for_test,
:importer => file_system_importer,
@@ -303,14 +307,20 @@
.foo {a: b}
SCSS
_, sourcemap = engine.render_with_sourcemap('http://1.example.com/style.map')
- assert_warning(<<WARNING) {sourcemap.to_json(:css_uri => 'css_uri', :css_path => 'css_path')}
-WARNING: Couldn't determine public URL for "#{filename_for_test(:scss)}" while generating sourcemap.
- Without a public URL, there's nothing for the source map to link to.
-WARNING
+ uri = Sass::Util.file_uri_from_path(Sass::Util.absolute_path(filename_for_test(:scss)))
+ assert_equal <<JSON.strip, sourcemap.to_json(:css_uri => 'css_uri', :css_path => 'css_path')
+{
+"version": 3,
+"mappings": "AAAA,IAAK;EAAC,CAAC,EAAE,CAAC",
+"sources": ["#{uri}"],
+"names": [],
+"file": "css_uri"
+}
+JSON
end
def test_source_map_with_css_uri_and_sourcemap_path_supports_filesystem_importer
file_system_importer = Sass::Importers::Filesystem.new('.')
css_uri = 'css_uri'
@@ -395,8 +405,8 @@
File.join(fixture_dir, path)
end
def test_absolute_files_across_template_locations
importer = Sass::Importers::Filesystem.new(absolutize 'templates')
- assert_not_nil importer.mtime(absolutize('more_templates/more1.sass'), {})
+ refute_nil importer.mtime(absolutize('more_templates/more1.sass'), {})
end
end