haml 2.0.10 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of haml might be problematic. Click here for more details.

Files changed (107) hide show
  1. data/.yardopts +5 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +347 -0
  4. data/Rakefile +124 -19
  5. data/VERSION +1 -1
  6. data/VERSION_NAME +1 -0
  7. data/extra/haml-mode.el +397 -78
  8. data/extra/sass-mode.el +148 -36
  9. data/extra/update_watch.rb +13 -0
  10. data/lib/haml.rb +15 -993
  11. data/lib/haml/buffer.rb +131 -84
  12. data/lib/haml/engine.rb +129 -97
  13. data/lib/haml/error.rb +7 -7
  14. data/lib/haml/exec.rb +127 -42
  15. data/lib/haml/filters.rb +107 -42
  16. data/lib/haml/helpers.rb +210 -156
  17. data/lib/haml/helpers/action_view_extensions.rb +34 -39
  18. data/lib/haml/helpers/action_view_mods.rb +132 -139
  19. data/lib/haml/html.rb +77 -65
  20. data/lib/haml/precompiler.rb +404 -213
  21. data/lib/haml/shared.rb +78 -0
  22. data/lib/haml/template.rb +14 -14
  23. data/lib/haml/template/patch.rb +2 -2
  24. data/lib/haml/template/plugin.rb +2 -3
  25. data/lib/haml/util.rb +211 -6
  26. data/lib/haml/version.rb +30 -13
  27. data/lib/sass.rb +7 -856
  28. data/lib/sass/css.rb +169 -161
  29. data/lib/sass/engine.rb +344 -328
  30. data/lib/sass/environment.rb +79 -0
  31. data/lib/sass/error.rb +33 -11
  32. data/lib/sass/files.rb +139 -0
  33. data/lib/sass/plugin.rb +160 -117
  34. data/lib/sass/plugin/merb.rb +7 -6
  35. data/lib/sass/plugin/rails.rb +5 -6
  36. data/lib/sass/repl.rb +58 -0
  37. data/lib/sass/script.rb +59 -0
  38. data/lib/sass/script/bool.rb +17 -0
  39. data/lib/sass/script/color.rb +183 -0
  40. data/lib/sass/script/funcall.rb +50 -0
  41. data/lib/sass/script/functions.rb +198 -0
  42. data/lib/sass/script/lexer.rb +178 -0
  43. data/lib/sass/script/literal.rb +177 -0
  44. data/lib/sass/script/node.rb +14 -0
  45. data/lib/sass/script/number.rb +381 -0
  46. data/lib/sass/script/operation.rb +45 -0
  47. data/lib/sass/script/parser.rb +172 -0
  48. data/lib/sass/script/string.rb +12 -0
  49. data/lib/sass/script/unary_operation.rb +34 -0
  50. data/lib/sass/script/variable.rb +31 -0
  51. data/lib/sass/tree/comment_node.rb +73 -10
  52. data/lib/sass/tree/debug_node.rb +30 -0
  53. data/lib/sass/tree/directive_node.rb +42 -17
  54. data/lib/sass/tree/file_node.rb +41 -0
  55. data/lib/sass/tree/for_node.rb +48 -0
  56. data/lib/sass/tree/if_node.rb +54 -0
  57. data/lib/sass/tree/mixin_def_node.rb +29 -0
  58. data/lib/sass/tree/mixin_node.rb +48 -0
  59. data/lib/sass/tree/node.rb +214 -11
  60. data/lib/sass/tree/prop_node.rb +109 -0
  61. data/lib/sass/tree/rule_node.rb +178 -51
  62. data/lib/sass/tree/variable_node.rb +34 -0
  63. data/lib/sass/tree/while_node.rb +31 -0
  64. data/test/haml/engine_test.rb +331 -36
  65. data/test/haml/helper_test.rb +12 -1
  66. data/test/haml/results/content_for_layout.xhtml +0 -3
  67. data/test/haml/results/filters.xhtml +2 -0
  68. data/test/haml/results/list.xhtml +1 -1
  69. data/test/haml/template_test.rb +7 -2
  70. data/test/haml/templates/content_for_layout.haml +0 -2
  71. data/test/haml/templates/list.haml +1 -1
  72. data/test/haml/util_test.rb +92 -0
  73. data/test/sass/css2sass_test.rb +69 -24
  74. data/test/sass/engine_test.rb +586 -64
  75. data/test/sass/functions_test.rb +125 -0
  76. data/test/sass/more_results/more1.css +9 -0
  77. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  78. data/test/sass/more_results/more_import.css +29 -0
  79. data/test/sass/more_templates/_more_partial.sass +2 -0
  80. data/test/sass/more_templates/more1.sass +23 -0
  81. data/test/sass/more_templates/more_import.sass +11 -0
  82. data/test/sass/plugin_test.rb +81 -28
  83. data/test/sass/results/line_numbers.css +49 -0
  84. data/test/sass/results/{constants.css → script.css} +4 -4
  85. data/test/sass/results/subdir/subdir.css +2 -0
  86. data/test/sass/results/units.css +11 -0
  87. data/test/sass/script_test.rb +258 -0
  88. data/test/sass/templates/import.sass +1 -1
  89. data/test/sass/templates/importee.sass +7 -2
  90. data/test/sass/templates/line_numbers.sass +13 -0
  91. data/test/sass/templates/{constants.sass → script.sass} +11 -10
  92. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  93. data/test/sass/templates/subdir/subdir.sass +2 -2
  94. data/test/sass/templates/units.sass +11 -0
  95. data/test/test_helper.rb +14 -0
  96. metadata +77 -19
  97. data/FAQ +0 -138
  98. data/README.rdoc +0 -319
  99. data/lib/sass/constant.rb +0 -216
  100. data/lib/sass/constant/color.rb +0 -101
  101. data/lib/sass/constant/literal.rb +0 -54
  102. data/lib/sass/constant/nil.rb +0 -9
  103. data/lib/sass/constant/number.rb +0 -87
  104. data/lib/sass/constant/operation.rb +0 -30
  105. data/lib/sass/constant/string.rb +0 -22
  106. data/lib/sass/tree/attr_node.rb +0 -57
  107. data/lib/sass/tree/value_node.rb +0 -20
@@ -1,5 +1,5 @@
1
- #main { content: Hello!; qstr: Quo"ted"!; hstr: Hyph-en!; width: 30em; background-color: #000; color: #ffffaa; short-color: #112233; named-color: #808000; con: foo bar 9 hi there boom; con2: noquo quo; }
2
- #main #sidebar { background-color: #00ff98; num-normal: 10; num-dec: 10.2; num-dec0: 99; num-neg: -10; esc: 10+12; many: 6; order: 7; complex: #4c9db1hi16; }
1
+ #main { content: Hello!; qstr: Quo"ted"!; hstr: Hyph-en!; width: 30em; background-color: #000; color: #ffffaa; short-color: #112233; named-color: olive; con: foo bar(9 hi there boom); con2: noquo quo; }
2
+ #main #sidebar { background-color: #00ff98; num-normal: 10; num-dec: 10.2; num-dec0: 99; num-neg: -10; esc: 10 +12; many: 6; order: 7; complex: #4c9db1hi16; }
3
3
 
4
4
  #plus { num-num: 7; num-num-un: 25em; num-num-un2: 23em; num-num-neg: 9.87; num-str: 100px; num-col: #b7b7b7; num-perc: 31%; str-str: hi there; str-str2: hi there; str-col: 14em solid #112233; str-num: times: 13; col-num: #ff7b9d; col-col: #5173ff; }
5
5
 
@@ -7,10 +7,10 @@
7
7
 
8
8
  #times { num-num: 7; num-col: #7496b8; col-num: #092345; col-col: #243648; }
9
9
 
10
- #div { num-num: 3.33333333333333; num-num2: 3; col-num: #092345; col-col: #0b0d0f; }
10
+ #div { num-num: 3.333; num-num2: 3.333; col-num: #092345; col-col: #0b0d0f; comp: 1px; }
11
11
 
12
12
  #mod { num-num: 2; col-col: #0f0e05; col-num: #020001; }
13
13
 
14
- #const { escaped-quote: !foo; escaped-slash: !foo; default: Hello! !important; }
14
+ #const { escaped-quote: !foo; default: Hello! !important; }
15
15
 
16
16
  #regression { a: 4; }
@@ -1 +1,3 @@
1
+ #nested { relative: true; }
2
+
1
3
  #subdir { font-size: 20px; font-weight: bold; }
@@ -0,0 +1,11 @@
1
+ b {
2
+ foo: 5px;
3
+ bar: 24px;
4
+ baz: 66.667%;
5
+ many-units: 32em;
6
+ mm: 15mm;
7
+ pc: 2pc;
8
+ pt: -72pt;
9
+ inches: 2in;
10
+ more-inches: 3.5in;
11
+ mixed: 6px; }
@@ -0,0 +1,258 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+ require 'sass/engine'
4
+
5
+ class SassScriptTest < Test::Unit::TestCase
6
+ include Sass::Script
7
+
8
+ def test_color_checks_input
9
+ assert_raise(Sass::SyntaxError, "Color values must be between 0 and 255") {Color.new([1, 2, -1])}
10
+ assert_raise(Sass::SyntaxError, "Color values must be between 0 and 255") {Color.new([256, 2, 3])}
11
+ end
12
+
13
+ def test_string_escapes
14
+ assert_equal '"', resolve("\"\\\"\"")
15
+ assert_equal "\\", resolve("\"\\\\\"")
16
+ assert_equal "\\02fa", resolve("\"\\02fa\"")
17
+ end
18
+
19
+ def test_color_names
20
+ assert_equal "white", resolve("white")
21
+ assert_equal "white", resolve("#ffffff")
22
+ assert_equal "#fffffe", resolve("white - #000001")
23
+ end
24
+
25
+ def test_implicit_strings
26
+ silence_warnings do
27
+ assert_equal Sass::Script::String.new("foo"), eval("foo")
28
+ assert_equal Sass::Script::String.new("foo bar"), eval("foo bar")
29
+ assert_equal Sass::Script::String.new("foo/bar"), eval("foo/bar")
30
+ end
31
+ end
32
+
33
+ def test_interpolation
34
+ assert_equal "foo bar, baz bang", resolve('"foo #{"bar"}, #{"baz"} bang"')
35
+ assert_equal "foo bar baz bang", resolve('"foo #{"#{"ba" + "r"} baz"} bang"')
36
+ assert_equal 'foo #{bar baz} bang', resolve('"foo \#{#{"ba" + "r"} baz} bang"')
37
+ assert_equal 'foo #{baz bang', resolve('"foo #{"\#{" + "baz"} bang"')
38
+ end
39
+
40
+ def test_rule_interpolation
41
+ assert_equal(<<CSS, render(<<SASS))
42
+ foo bar baz bang {
43
+ a: b; }
44
+ CSS
45
+ foo \#{"\#{"ba" + "r"} baz"} bang
46
+ a: b
47
+ SASS
48
+ assert_equal(<<CSS, render(<<SASS))
49
+ foo \#{bar baz} bang {
50
+ a: b; }
51
+ CSS
52
+ foo \\\#{\#{"ba" + "r"} baz} bang
53
+ a: b
54
+ SASS
55
+ assert_equal(<<CSS, render(<<SASS))
56
+ foo \#{baz bang {
57
+ a: b; }
58
+ CSS
59
+ foo \#{"\\\#{" + "baz"} bang
60
+ a: b
61
+ SASS
62
+ end
63
+
64
+ def test_warning_reporting
65
+ assert_warning(<<WARN) {eval("foo")}
66
+ DEPRECATION WARNING:
67
+ On line 1, character 1 of 'test_warning_reporting_inline.sass'
68
+ Implicit strings have been deprecated and will be removed in version 2.4.
69
+ 'foo' was not quoted. Please add double quotes (e.g. "foo").
70
+ WARN
71
+ assert_warning(<<WARN) {eval("1 + foo")}
72
+ DEPRECATION WARNING:
73
+ On line 1, character 5 of 'test_warning_reporting_inline.sass'
74
+ Implicit strings have been deprecated and will be removed in version 2.4.
75
+ 'foo' was not quoted. Please add double quotes (e.g. "foo").
76
+ WARN
77
+ assert_warning(<<WARN) {render("@if 1 + foo")}
78
+ DEPRECATION WARNING:
79
+ On line 1, character 9 of 'test_warning_reporting_inline.sass'
80
+ Implicit strings have been deprecated and will be removed in version 2.4.
81
+ 'foo' was not quoted. Please add double quotes (e.g. "foo").
82
+ WARN
83
+
84
+ # Regression
85
+ assert_warning(<<WARN) {render("@if if")}
86
+ DEPRECATION WARNING:
87
+ On line 1, character 5 of 'test_warning_reporting_inline.sass'
88
+ Implicit strings have been deprecated and will be removed in version 2.4.
89
+ 'if' was not quoted. Please add double quotes (e.g. "if").
90
+ WARN
91
+ end
92
+
93
+ def test_inaccessible_functions
94
+ assert_warning <<WARN do
95
+ DEPRECATION WARNING:
96
+ On line 2, character 6 of 'test_inaccessible_functions_inline.sass'
97
+ Implicit strings have been deprecated and will be removed in version 2.4.
98
+ 'to_s' was not quoted. Please add double quotes (e.g. "to_s").
99
+ WARN
100
+ assert_equal "send(to_s)", resolve("send(to_s)", :line => 2)
101
+ end
102
+ assert_equal "public_instance_methods()", resolve("public_instance_methods()")
103
+ end
104
+
105
+ def test_ruby_equality
106
+ assert_equal eval('"foo"'), eval('"foo"')
107
+ assert_equal eval('1'), eval('1.0')
108
+ assert_not_equal eval('1'), eval('"1"')
109
+ end
110
+
111
+ def test_booleans
112
+ assert_equal "true", resolve("true")
113
+ assert_equal "false", resolve("false")
114
+ end
115
+
116
+ def test_boolean_ops
117
+ assert_equal "true", resolve("true and true")
118
+ assert_equal "true", resolve("false or true")
119
+ assert_equal "true", resolve("true or false")
120
+ assert_equal "true", resolve("true or true")
121
+ assert_equal "false", resolve("false or false")
122
+ assert_equal "false", resolve("false and true")
123
+ assert_equal "false", resolve("true and false")
124
+ assert_equal "false", resolve("false and false")
125
+
126
+ assert_equal "true", resolve("not false")
127
+ assert_equal "false", resolve("not true")
128
+ assert_equal "true", resolve("not not true")
129
+
130
+ assert_equal "1", resolve("false or 1")
131
+ assert_equal "false", resolve("false and 1")
132
+ assert_equal "2", resolve("2 or 3")
133
+ assert_equal "3", resolve("2 and 3")
134
+ end
135
+
136
+ def test_arithmetic_ops
137
+ assert_equal "2", resolve("1 + 1")
138
+ assert_equal "0", resolve("1 - 1")
139
+ assert_equal "8", resolve("2 * 4")
140
+ assert_equal "0.5", resolve("2 / 4")
141
+ assert_equal "2", resolve("4 / 2")
142
+
143
+ assert_equal "-1", resolve("-1")
144
+ end
145
+
146
+ def test_string_ops
147
+ assert_equal "foo bar", resolve('"foo" "bar"')
148
+ assert_equal "true 1", resolve('true 1')
149
+ assert_equal "foo, bar", resolve('"foo" , "bar"')
150
+ assert_equal "true, 1", resolve('true , 1')
151
+ assert_equal "foobar", resolve('"foo" + "bar"')
152
+ assert_equal "true1", resolve('true + 1')
153
+ assert_equal "foo-bar", resolve('"foo" - "bar"')
154
+ assert_equal "true-1", resolve('true - 1')
155
+ assert_equal "foo/bar", resolve('"foo" / "bar"')
156
+ assert_equal "true/1", resolve('true / 1')
157
+
158
+ assert_equal "-bar", resolve('- "bar"')
159
+ assert_equal "-true", resolve('- true')
160
+ assert_equal "/bar", resolve('/ "bar"')
161
+ assert_equal "/true", resolve('/ true')
162
+ end
163
+
164
+ def test_relational_ops
165
+ assert_equal "false", resolve("1 > 2")
166
+ assert_equal "false", resolve("2 > 2")
167
+ assert_equal "true", resolve("3 > 2")
168
+ assert_equal "false", resolve("1 >= 2")
169
+ assert_equal "true", resolve("2 >= 2")
170
+ assert_equal "true", resolve("3 >= 2")
171
+ assert_equal "true", resolve("1 < 2")
172
+ assert_equal "false", resolve("2 < 2")
173
+ assert_equal "false", resolve("3 < 2")
174
+ assert_equal "true", resolve("1 <= 2")
175
+ assert_equal "true", resolve("2 <= 2")
176
+ assert_equal "false", resolve("3 <= 2")
177
+ end
178
+
179
+ def test_equals
180
+ assert_equal("true", resolve('"foo" == !foo', {},
181
+ env("foo" => Sass::Script::String.new("foo"))))
182
+ assert_equal "true", resolve("1 == 1.0")
183
+ assert_equal "true", resolve("false != true")
184
+ assert_equal "false", resolve("1em == 1px")
185
+ assert_equal "false", resolve("12 != 12")
186
+ end
187
+
188
+ def test_operation_precedence
189
+ assert_equal "false true", resolve("true and false false or true")
190
+ assert_equal "true", resolve("false and true or true and true")
191
+ assert_equal "true", resolve("1 == 2 or 3 == 3")
192
+ assert_equal "true", resolve("1 < 2 == 3 >= 3")
193
+ assert_equal "true", resolve("1 + 3 > 4 - 2")
194
+ assert_equal "11", resolve("1 + 2 * 3 + 4")
195
+ end
196
+
197
+ def test_functions
198
+ assert_equal "#80ff80", resolve("hsl(120, 100%, 75%)")
199
+ assert_equal "#81ff81", resolve("hsl(120, 100%, 75%) + #010001")
200
+ end
201
+
202
+ def test_operator_unit_conversion
203
+ assert_equal "1.1cm", resolve("1cm + 1mm")
204
+ assert_equal "true", resolve("2mm < 1cm")
205
+ assert_equal "true", resolve("10mm == 1cm")
206
+ assert_equal "true", resolve("1 == 1cm")
207
+ assert_equal "true", resolve("1.1cm == 11mm")
208
+ end
209
+
210
+ private
211
+
212
+ def resolve(str, opts = {}, environment = env)
213
+ munge_filename opts
214
+ eval(str, opts, environment).to_s
215
+ end
216
+
217
+ def eval(str, opts = {}, environment = env)
218
+ munge_filename opts
219
+ Sass::Script.parse(str, opts[:line] || 1,
220
+ opts[:offset] || 0, opts[:filename]).perform(environment)
221
+ end
222
+
223
+ def render(sass, options = {})
224
+ munge_filename options
225
+ Sass::Engine.new(sass, options).render
226
+ end
227
+
228
+ def assert_warning(message)
229
+ the_real_stderr, $stderr = $stderr, StringIO.new
230
+ yield
231
+ assert_equal message.strip, $stderr.string.strip
232
+ ensure
233
+ $stderr = the_real_stderr
234
+ end
235
+
236
+ def silence_warnings
237
+ the_real_stderr, $stderr = $stderr, StringIO.new
238
+ yield
239
+ ensure
240
+ $stderr = the_real_stderr
241
+ end
242
+
243
+ def env(hash = {})
244
+ env = Sass::Environment.new
245
+ hash.each {|k, v| env.set_var(k, v)}
246
+ env
247
+ end
248
+
249
+ def test_number_printing
250
+ assert_equal "1", eval("1")
251
+ assert_equal "1", eval("1.0")
252
+ assert_equal "1.121", eval("1.1214")
253
+ assert_equal "1.122", eval("1.1215")
254
+ assert_equal "Infinity", eval("1.0/0.0")
255
+ assert_equal "-Infinity", eval("-1.0/0.0")
256
+ assert_equal "NaN", eval("0.0/0.0")
257
+ end
258
+ end
@@ -1,4 +1,4 @@
1
- !preconst = hello
1
+ !preconst = "hello"
2
2
 
3
3
  =premixin
4
4
  pre-mixin: here
@@ -1,4 +1,4 @@
1
- !postconst = goodbye
1
+ !postconst = "goodbye"
2
2
 
3
3
  =postmixin
4
4
  post-mixin: here
@@ -11,4 +11,9 @@ imported
11
11
  @import basic
12
12
 
13
13
  midrule
14
- :inthe middle
14
+ :inthe middle
15
+
16
+ =crazymixin
17
+ foo: bar
18
+ baz
19
+ blat: bang
@@ -0,0 +1,13 @@
1
+ foo
2
+ bar: baz
3
+
4
+ =premixin
5
+ squggle
6
+ blat: bang
7
+
8
+ !preconst = 12
9
+
10
+ @import importee
11
+
12
+ umph
13
+ +crazymixin
@@ -5,12 +5,13 @@
5
5
  !dec = 10.2
6
6
  !dec_0 = 99.0
7
7
  !neg = -10
8
- !esc= 10\+12
8
+ !esc= 10"+12"
9
9
  !str= "Hello!"
10
10
  !qstr= "Quo\"ted\"!"
11
11
  !hstr= "Hyph-en!"
12
- !concat = (5 + 4) hi there
12
+ !concat = "#{5 + 4} hi there"
13
13
  !percent= 11%
14
+ !complex = 1px/1em
14
15
 
15
16
  #main
16
17
  :content = !str
@@ -21,8 +22,8 @@
21
22
  :color= !main_text
22
23
  :short-color= #123
23
24
  :named-color= olive
24
- :con= foo bar (!concat boom)
25
- :con2= noquo "quo"
25
+ :con= "foo" bar (!concat "boom")
26
+ :con2= "noquo" "quo"
26
27
  #sidebar
27
28
  :background-color= !color
28
29
  :num
@@ -33,7 +34,7 @@
33
34
  :esc= !esc
34
35
  :many= 1 + 2 + 3
35
36
  :order= 1 + 2 * 3
36
- :complex= ((1 + 2) + 15)+#3a8b9f + (hi+(1 +1+ 2)* 4)
37
+ :complex= ((1 + 2) + 15)+#3a8b9f + ("hi"+(1 +1+ 2)* 4)
37
38
 
38
39
  #plus
39
40
  :num
@@ -41,14 +42,14 @@
41
42
  :num-un= 10em + 15em
42
43
  :num-un2= 10 + 13em
43
44
  :num-neg= 10 + -.13
44
- :str= 100 + px
45
+ :str= 100 * 1px
45
46
  :col= 13 + #aaa
46
47
  :perc = !percent + 20%
47
48
  :str
48
- :str= hi + \ there
49
- :str2= hi + " there"
49
+ :str= "hi" + "\ there"
50
+ :str2= "hi" + " there"
50
51
  :col= "14em solid " + #123
51
- :num= times:\ + 13
52
+ :num= "times: " + 13
52
53
  :col
53
54
  :num= #f02 + 123.5
54
55
  :col= #12A + #405162
@@ -82,6 +83,7 @@
82
83
  :col
83
84
  :num= #12468a / 2
84
85
  :col= #abcdef / #0f0f0f
86
+ :comp = !complex * 1em
85
87
 
86
88
  #mod
87
89
  :num
@@ -93,7 +95,6 @@
93
95
  #const
94
96
  :escaped
95
97
  :quote = "!foo"
96
- :slash = \!foo
97
98
  :default = !str !important
98
99
 
99
100
  #regression
@@ -0,0 +1,2 @@
1
+ #nested
2
+ :relative true
@@ -1,6 +1,6 @@
1
+ @import nested_subdir/nested_partial.sass
2
+
1
3
  #subdir
2
4
  :font
3
5
  :size 20px
4
6
  :weight bold
5
-
6
-
@@ -0,0 +1,11 @@
1
+ b
2
+ :foo= 0.5 * 10px
3
+ :bar= 10zzz * 12px / 5zzz
4
+ :baz= percentage(12.0px / 18px)
5
+ :many-units= 10.0zzz / 3yyy * 12px / 5zzz * 3yyy / 3px * 4em
6
+ :mm= 5mm + 1cm
7
+ :pc= 1pc + 12pt
8
+ :pt= 72pt - 2in
9
+ :inches= 1in + 2.54cm
10
+ :more-inches= 1in + ((72pt * 2in) + (36pt * 1in)) / 2.54cm
11
+ :mixed= (1 + (1em * 6px / 3in)) * 4in / 2em
@@ -2,6 +2,7 @@ lib_dir = File.dirname(__FILE__) + '/../lib'
2
2
  require File.dirname(__FILE__) + '/linked_rails'
3
3
 
4
4
  require 'test/unit'
5
+ require 'fileutils'
5
6
  $:.unshift lib_dir unless $:.include?(lib_dir)
6
7
  require 'haml'
7
8
  require 'sass'
@@ -11,3 +12,16 @@ unless defined? RAILS_ROOT
11
12
  RAILS_ROOT = '.'
12
13
  MERB_ENV = RAILS_ENV = 'testing'
13
14
  end
15
+
16
+ class Test::Unit::TestCase
17
+ def munge_filename(opts)
18
+ return if opts[:filename]
19
+ test_name = caller[1].gsub(/^.*`(?:\w+ )*(\w+)'.*$/, '\1')
20
+ opts[:filename] = "#{test_name}_inline.sass"
21
+ end
22
+
23
+ def clean_up_sassc
24
+ path = File.dirname(__FILE__) + "/../.sass-cache"
25
+ FileUtils.rm_r(path) if File.exist?(path)
26
+ end
27
+ end