/
configuration_test.rb
92 lines (74 loc) · 3.06 KB
/
configuration_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
require File.dirname(__FILE__)+'/test_helper'
require 'compass'
class ConfigurationTest < Test::Unit::TestCase
def setup
Compass.configuration.reset!
end
def test_parse_and_serialize
contents = <<-CONFIG
require 'compass'
# Require any additional compass plugins here.
project_type = :stand_alone
css_dir = "css"
sass_dir = "sass"
images_dir = "img"
javascripts_dir = "js"
output_style = :nested
# To enable relative image paths using the images_url() function:
# http_images_path = :relative
http_images_path = "/images"
CONFIG
Compass.configuration.parse_string(contents, "test_parse")
assert_equal 'sass', Compass.configuration.sass_dir
assert_equal 'css', Compass.configuration.css_dir
assert_equal 'img', Compass.configuration.images_dir
assert_equal 'js', Compass.configuration.javascripts_dir
expected_lines = contents.split("\n").map{|l|l.strip}
actual_lines = Compass.configuration.serialize.split("\n").map{|l|l.strip}
assert_equal expected_lines, actual_lines
end
def test_serialization_fails_with_asset_host_set
contents = <<-CONFIG
asset_host do |path|
"http://example.com"
end
CONFIG
Compass.configuration.parse_string(contents, "test_serialization_fails_with_asset_host_set")
assert_raise Compass::Error do
Compass.configuration.serialize
end
end
def test_serialization_fails_with_asset_cache_buster_set
contents = <<-CONFIG
asset_cache_buster do |path|
"http://example.com"
end
CONFIG
Compass.configuration.parse_string(contents, "test_serialization_fails_with_asset_cache_buster_set")
assert_raise Compass::Error do
Compass.configuration.serialize
end
end
def test_additional_import_paths
contents = <<-CONFIG
project_path = "/home/chris/my_compass_project"
css_dir = "css"
additional_import_paths = ["../foo"]
add_import_path "/path/to/my/framework"
CONFIG
Compass.configuration.parse_string(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"
css_dir = "css"
# To enable relative image paths using the images_url() function:
# http_images_path = :relative
additional_import_paths = ["../foo", "/path/to/my/framework"]
EXPECTED
assert_equal expected_serialization, Compass.configuration.serialize
end
end