Sprite importer now passes the correct filename to the sass engine which was causeing unexpected uris to get returned

This fixes the 'to_tree' error that wasn't really a sass bug it was an error on the sprite importers part
This commit is contained in:
Scott Davis 2011-09-12 20:44:12 -04:00
parent f0f4ac9700
commit 35b9b60c7c
2 changed files with 10 additions and 4 deletions

View File

@ -19,7 +19,7 @@ module Compass
end end
def find_relative(uri, base, options) def find_relative(uri, base, options)
find(File.join(base, uri), options) nil
end end
def to_s def to_s
@ -85,13 +85,13 @@ module Compass
end end
# Returns the sass_options for this sprite # Returns the sass_options for this sprite
def self.sass_options(name, importer, options) def self.sass_options(uri, importer, options)
options.merge!(:filename => name, :syntax => :scss, :importer => importer) options.merge!(:filename => uri, :syntax => :scss, :importer => importer)
end end
# Returns a Sass::Engine for this sprite object # Returns a Sass::Engine for this sprite object
def self.sass_engine(uri, name, importer, options) def self.sass_engine(uri, name, importer, options)
Sass::Engine.new(content_for_images(uri, name, options[:skip_overrides]), sass_options(name, importer, options)) Sass::Engine.new(content_for_images(uri, name, options[:skip_overrides]), sass_options(uri, importer, options))
end end
# Generates the Sass for this sprite file # Generates the Sass for this sprite file

View File

@ -68,6 +68,12 @@ class ImporterTest < Test::Unit::TestCase
assert_equal 'bar', opts[:foo] assert_equal 'bar', opts[:foo]
end end
test "verify that the sass_engine passes the correct filename" do
importer = Compass::SpriteImporter.new
engine = Compass::SpriteImporter.sass_engine(URI, 'foo', importer, options)
assert_equal engine.options[:filename], URI
end
test "should fail given bad sprite extensions" do test "should fail given bad sprite extensions" do
@images_src_path = File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'sprites', 'public', 'images') @images_src_path = File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'sprites', 'public', 'images')
file = StringIO.new("images_path = #{@images_src_path.inspect}\n") file = StringIO.new("images_path = #{@images_src_path.inspect}\n")