Adding Pathname support to compass configs

This commit is contained in:
Jacques Crocker 2010-02-20 13:06:29 -08:00
parent 2b985fd191
commit 5fc52baa02
2 changed files with 31 additions and 0 deletions

View File

@ -41,6 +41,7 @@ module Compass
eval(contents, bind, filename)
ATTRIBUTES.each do |prop|
value = eval(prop.to_s, bind) rescue nil
value = value.to_s if value.is_a?(Pathname)
self.send("#{prop}=", value) unless value.nil?
end
if @added_import_paths

View File

@ -93,6 +93,36 @@ css_dir = "css"
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
additional_import_paths = ["../foo", "/path/to/my/framework"]
EXPECTED
assert_equal "/", Compass.configuration.http_path
assert_equal expected_serialization.split("\n"), Compass.configuration.serialize.split("\n")
end
def test_config_with_pathname
contents = StringIO.new(<<-CONFIG)
http_path = "/"
project_path = Pathname.new("/home/chris/my_compass_project")
css_dir = "css"
additional_import_paths = ["../foo"]
add_import_path "/path/to/my/framework"
CONFIG
Compass.add_configuration(contents, "test_additional_import_paths")
assert Compass.configuration.to_sass_engine_options[:load_paths].include?("/home/chris/my_compass_project/../foo")
assert Compass.configuration.to_sass_engine_options[:load_paths].include?("/path/to/my/framework"), Compass.configuration.to_sass_engine_options[:load_paths].inspect
assert_equal "/home/chris/my_compass_project/css/framework", Compass.configuration.to_sass_plugin_options[:template_location]["/path/to/my/framework"]
assert_equal "/home/chris/my_compass_project/css/foo", Compass.configuration.to_sass_plugin_options[:template_location]["/home/chris/my_compass_project/../foo"]
expected_serialization = <<EXPECTED
# Require any additional compass plugins here.
project_path = "/home/chris/my_compass_project"
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
additional_import_paths = ["../foo", "/path/to/my/framework"]
EXPECTED
assert_equal "/", Compass.configuration.http_path
assert_equal expected_serialization.split("\n"), Compass.configuration.serialize.split("\n")