haml 4.1.0.beta.1 → 5.0.0.beta.2
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.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +36 -6
- data/FAQ.md +4 -14
- data/MIT-LICENSE +1 -1
- data/README.md +81 -48
- data/REFERENCE.md +86 -50
- data/Rakefile +28 -41
- data/lib/haml/attribute_builder.rb +163 -0
- data/lib/haml/attribute_compiler.rb +214 -0
- data/lib/haml/attribute_parser.rb +112 -0
- data/lib/haml/buffer.rb +24 -126
- data/lib/haml/compiler.rb +62 -281
- data/lib/haml/engine.rb +16 -23
- data/lib/haml/error.rb +2 -0
- data/lib/haml/escapable.rb +48 -0
- data/lib/haml/exec.rb +23 -12
- data/lib/haml/filters.rb +3 -4
- data/lib/haml/generator.rb +36 -0
- data/lib/haml/helpers.rb +61 -48
- data/lib/haml/helpers/action_view_extensions.rb +1 -1
- data/lib/haml/helpers/action_view_mods.rb +32 -50
- data/lib/haml/helpers/safe_erubi_template.rb +26 -0
- data/lib/haml/helpers/safe_erubis_template.rb +2 -0
- data/lib/haml/helpers/xss_mods.rb +17 -12
- data/lib/haml/options.rb +32 -36
- data/lib/haml/parser.rb +61 -38
- data/lib/haml/{template/plugin.rb → plugin.rb} +5 -2
- data/lib/haml/railtie.rb +14 -6
- data/lib/haml/template.rb +11 -6
- data/lib/haml/temple_engine.rb +119 -0
- data/lib/haml/temple_line_counter.rb +28 -0
- data/lib/haml/util.rb +17 -112
- data/lib/haml/version.rb +1 -1
- data/test/attribute_parser_test.rb +105 -0
- data/test/engine_test.rb +202 -106
- data/test/filters_test.rb +32 -19
- data/test/gemfiles/Gemfile.rails-4.0.x +7 -1
- data/test/gemfiles/Gemfile.rails-4.0.x.lock +57 -71
- data/test/gemfiles/Gemfile.rails-4.1.x +5 -0
- data/test/gemfiles/Gemfile.rails-4.2.x +5 -0
- data/test/gemfiles/Gemfile.rails-5.0.x +4 -0
- data/test/helper_test.rb +156 -109
- data/test/options_test.rb +21 -0
- data/test/parser_test.rb +49 -4
- data/test/results/eval_suppressed.xhtml +4 -4
- data/test/results/helpers.xhtml +43 -41
- data/test/results/helpful.xhtml +6 -3
- data/test/results/just_stuff.xhtml +21 -20
- data/test/results/list.xhtml +9 -9
- data/test/results/nuke_inner_whitespace.xhtml +22 -22
- data/test/results/nuke_outer_whitespace.xhtml +84 -92
- data/test/results/original_engine.xhtml +17 -17
- data/test/results/partial_layout.xhtml +4 -3
- data/test/results/partial_layout_erb.xhtml +4 -3
- data/test/results/partials.xhtml +11 -10
- data/test/results/silent_script.xhtml +63 -63
- data/test/results/standard.xhtml +156 -159
- data/test/results/tag_parsing.xhtml +19 -19
- data/test/results/very_basic.xhtml +2 -2
- data/test/results/whitespace_handling.xhtml +77 -76
- data/test/template_test.rb +21 -48
- data/test/template_test_helper.rb +38 -0
- data/test/templates/just_stuff.haml +1 -0
- data/test/templates/standard_ugly.haml +1 -0
- data/test/temple_line_counter_test.rb +40 -0
- data/test/test_helper.rb +10 -10
- data/test/util_test.rb +1 -48
- metadata +49 -35
- data/lib/haml/temple.rb +0 -85
- data/test/gemfiles/Gemfile.rails-3.2.x +0 -4
- data/test/templates/_av_partial_1_ugly.haml +0 -9
- data/test/templates/_av_partial_2_ugly.haml +0 -5
- data/test/templates/action_view_ugly.haml +0 -47
- data/test/templates/standard_ugly.haml +0 -43
@@ -1,23 +1,23 @@
|
|
1
1
|
<div class='tags'>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
<foo>1</foo>
|
3
|
+
<FOO>2</FOO>
|
4
|
+
<fooBAR>3</fooBAR>
|
5
|
+
<fooBar>4</fooBar>
|
6
|
+
<foo_bar>5</foo_bar>
|
7
|
+
<foo-bar>6</foo-bar>
|
8
|
+
<foo:bar>7</foo:bar>
|
9
|
+
<foo class='bar'>8</foo>
|
10
|
+
<fooBAr_baz:boom_bar>9</fooBAr_baz:boom_bar>
|
11
|
+
<foo13>10</foo13>
|
12
|
+
<foo2u>11</foo2u>
|
13
13
|
</div>
|
14
14
|
<div class='classes'>
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
<p class='foo bar' id='boom'></p>
|
16
|
+
<div class='fooBar'>a</div>
|
17
|
+
<div class='foo-bar'>b</div>
|
18
|
+
<div class='foo_bar'>c</div>
|
19
|
+
<div class='FOOBAR'>d</div>
|
20
|
+
<div class='foo16'>e</div>
|
21
|
+
<div class='123'>f</div>
|
22
|
+
<div class='foo2u'>g</div>
|
23
23
|
</div>
|
@@ -1,90 +1,91 @@
|
|
1
1
|
<div id='whitespace_test'>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
2
|
+
<div class='text_area_test_area'>
|
3
|
+
<textarea>Oneline</textarea>
|
4
|
+
</div>
|
5
|
+
<textarea>BLAH
|
6
|
+
</textarea>
|
7
|
+
|
8
|
+
<div class='text_area_test_area'>
|
9
|
+
<textarea>Two
lines</textarea>
|
10
|
+
</div>
|
11
|
+
<textarea>BLAH
|
12
|
+
</textarea>
|
13
|
+
|
14
|
+
<div class='text_area_test_area'>
|
15
|
+
<textarea>Oneline</textarea>
|
16
|
+
</div>
|
17
|
+
<textarea>BLAH</textarea>
|
18
|
+
|
19
|
+
<div class='text_area_test_area'>
|
20
|
+
<textarea>Two
lines</textarea>
|
21
|
+
</div>
|
22
|
+
<textarea>BLAH</textarea>
|
23
|
+
|
24
|
+
<div id='flattened'><div class='text_area_test_area'>
|
25
|
+
<textarea>Two
lines</textarea>
|
26
|
+
</div>
|
27
|
+
<textarea>BLAH</textarea>
|
28
|
+
</div>
|
26
29
|
</div>
|
27
30
|
<div class='hithere'>
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
bar
|
35
|
-
</p>
|
31
|
+
Foo bar
|
32
|
+
<pre>foo bar</pre>
|
33
|
+
<pre>foo
bar</pre>
|
34
|
+
<p><pre>foo
bar</pre></p>
|
35
|
+
<p>foo
|
36
|
+
bar</p>
|
36
37
|
</div>
|
37
38
|
<div class='foo'>
|
38
|
-
|
39
|
-
<textarea>
|
40
|
-
a
|
41
|
-
</textarea>
|
39
|
+
13
|
42
40
|
<textarea>
|
43
|
-
a
|
44
|
-
</
|
41
|
+
a
|
42
|
+
</textarea>
|
43
|
+
<textarea>
|
44
|
+
a</textarea></div>
|
45
45
|
<div id='whitespace_test'>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
46
|
+
<div class='text_area_test_area'>
|
47
|
+
<textarea>Oneline</textarea>
|
48
|
+
</div>
|
49
|
+
<textarea>BLAH
|
50
|
+
</textarea>
|
51
|
+
|
52
|
+
<div class='text_area_test_area'>
|
53
|
+
<textarea>Two
lines</textarea>
|
54
|
+
</div>
|
55
|
+
<textarea>BLAH
|
56
|
+
</textarea>
|
57
|
+
|
58
|
+
<div class='text_area_test_area'>
|
59
|
+
<textarea>Oneline</textarea>
|
60
|
+
</div>
|
61
|
+
<textarea>BLAH</textarea>
|
62
|
+
|
63
|
+
<div class='text_area_test_area'>
|
64
|
+
<textarea>Two
lines</textarea>
|
65
|
+
</div>
|
66
|
+
<textarea>BLAH</textarea>
|
67
|
+
|
68
|
+
<div id='flattened'><div class='text_area_test_area'>
|
69
|
+
<textarea>Two
lines</textarea>
|
70
|
+
</div>
|
71
|
+
<textarea>BLAH</textarea>
|
72
|
+
</div>
|
70
73
|
</div>
|
71
74
|
<div class='hithere'>
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
<textarea> ___ ___ ___ ___ 
 /\__\ /\ \ /\__\ /\__\
 /:/ / /::\ \ /::| | /:/ /
 /:/__/ /:/\:\ \ /:|:| | /:/ / 
 /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / 
 /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ 
 \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ 
 \::/ / \::/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\__\
 \/__/ \/__/ \/__/ \/__/
 
 Many
 thanks
 to
 http://www.network-science.de/ascii/
|
83
|
-
<strong>indeed!</strong></textarea>
|
75
|
+
Foo bar
|
76
|
+
<pre>foo bar</pre>
|
77
|
+
<pre>foo
bar</pre>
|
78
|
+
<p><pre>foo
bar</pre></p>
|
79
|
+
<p>foo
|
80
|
+
bar</p>
|
81
|
+
<pre> ___
 ,o88888
 ,o8888888'
 ,:o:o:oooo. ,8O88Pd8888"
 ,.::.::o:ooooOoOoO. ,oO8O8Pd888'"
 ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"
 , ..:.::o:ooOoOOOO8OOOOo.FdO8O8"
 , ..:.::o:ooOoOO8O888O8O,COCOO"
 , . ..:.::o:ooOoOOOO8OOOOCOCO"
 . ..:.::o:ooOoOoOO8O8OCCCC"o
 . ..:.::o:ooooOoCoCCC"o:o
 . ..:.::o:o:,cooooCo"oo:o:
 ` . . ..:.:cocoooo"'o:o:::'
 .` . ..::ccccoc"'o:o:o:::'
 :.:. ,c:cccc"':.:.:.:.:.'
 ..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/
 ...:.'.:.::::"' . . . . .'
 .. . ....:."' ` . . . ''
 . . . ...."'
 .. . ."' -hrr-
 .


 It's a planet!
%strong This shouldn't be bold!</pre>
|
82
|
+
<strong>This should!</strong>
|
83
|
+
<textarea> ___ ___ ___ ___ 
 /\__\ /\ \ /\__\ /\__\
 /:/ / /::\ \ /::| | /:/ /
 /:/__/ /:/\:\ \ /:|:| | /:/ / 
 /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / 
 /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ 
 \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ 
 \::/ / \::/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\__\
 \/__/ \/__/ \/__/ \/__/
 
 Many
 thanks
 to
 http://www.network-science.de/ascii/
|
84
|
+
<strong>indeed!</strong></textarea>
|
84
85
|
</div>
|
85
86
|
<div class='foo'>
|
86
|
-
|
87
|
+
13
|
87
88
|
</div>
|
88
89
|
<pre> __ ______ __ ______
.----.| |--.|__ |.----.| |--..--------.| __ |
| __|| ||__ || __|| < | || __ |
|____||__|__||______||____||__|__||__|__|__||______|</pre>
|
89
90
|
<pre>foo
|
90
|
-
bar</pre>
|
91
|
+
bar</pre>
|
data/test/template_test.rb
CHANGED
@@ -2,44 +2,9 @@ require 'test_helper'
|
|
2
2
|
require 'mocks/article'
|
3
3
|
|
4
4
|
require 'action_pack/version'
|
5
|
+
require 'template_test_helper'
|
5
6
|
|
6
|
-
|
7
|
-
include Haml::Filters::Base
|
8
|
-
|
9
|
-
def render(text)
|
10
|
-
"TESTING HAHAHAHA!"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module Haml::Helpers
|
15
|
-
def test_partial(name, locals = {})
|
16
|
-
Haml::Engine.new(File.read(File.join(TemplateTest::TEMPLATE_PATH, "_#{name}.haml"))).render(self, locals)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class Egocentic
|
21
|
-
def method_missing(*args)
|
22
|
-
self
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class DummyController
|
27
|
-
attr_accessor :logger
|
28
|
-
def initialize
|
29
|
-
@logger = Egocentic.new
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.controller_path
|
33
|
-
''
|
34
|
-
end
|
35
|
-
|
36
|
-
def controller_path
|
37
|
-
''
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class TemplateTest < MiniTest::Unit::TestCase
|
42
|
-
TEMPLATE_PATH = File.join(File.dirname(__FILE__), "templates")
|
7
|
+
class TemplateTest < Haml::TestCase
|
43
8
|
TEMPLATES = %w{ very_basic standard helpers
|
44
9
|
whitespace_handling original_engine list helpful
|
45
10
|
silent_script tag_parsing just_stuff partials
|
@@ -56,10 +21,10 @@ class TemplateTest < MiniTest::Unit::TestCase
|
|
56
21
|
def create_base
|
57
22
|
vars = { 'article' => Article.new, 'foo' => 'value one' }
|
58
23
|
|
59
|
-
base = ActionView::Base.new(TEMPLATE_PATH, vars)
|
24
|
+
base = ActionView::Base.new(TemplateTestHelper::TEMPLATE_PATH, vars)
|
60
25
|
|
61
26
|
# This is needed by RJS in (at least) Rails 3
|
62
|
-
base.instance_variable_set(
|
27
|
+
base.instance_variable_set(:@template, base)
|
63
28
|
|
64
29
|
# This is used by form_for.
|
65
30
|
# It's usually provided by ActionController::Base.
|
@@ -111,7 +76,7 @@ class TemplateTest < MiniTest::Unit::TestCase
|
|
111
76
|
end
|
112
77
|
end
|
113
78
|
|
114
|
-
def
|
79
|
+
def test_render_method_returning_null
|
115
80
|
@base.instance_eval do
|
116
81
|
def empty
|
117
82
|
nil
|
@@ -122,35 +87,35 @@ class TemplateTest < MiniTest::Unit::TestCase
|
|
122
87
|
end
|
123
88
|
|
124
89
|
content_to_render = "%h1 This is part of the broken view.\n= render_something do |thing|\n = thing.empty do\n = 'test'"
|
125
|
-
result = render(content_to_render
|
90
|
+
result = render(content_to_render)
|
126
91
|
expected_result = "<h1>This is part of the broken view.</h1>\n"
|
127
92
|
assert_equal(expected_result, result)
|
128
93
|
end
|
129
94
|
|
130
|
-
def
|
95
|
+
def test_simple_rendering
|
131
96
|
content_to_render = "%p test\n= capture { 'foo' }"
|
132
|
-
result = render(content_to_render
|
97
|
+
result = render(content_to_render)
|
133
98
|
expected_result = "<p>test</p>\nfoo\n"
|
134
99
|
assert_equal(expected_result, result)
|
135
100
|
end
|
136
101
|
|
137
102
|
def test_templates_should_render_correctly_with_render_proc
|
138
103
|
assert_renders_correctly("standard") do |name|
|
139
|
-
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"), :
|
104
|
+
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"), format: :xhtml)
|
140
105
|
engine.render_proc(@base).call
|
141
106
|
end
|
142
107
|
end
|
143
108
|
|
144
109
|
def test_templates_should_render_correctly_with_def_method
|
145
110
|
assert_renders_correctly("standard") do |name|
|
146
|
-
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"), :
|
111
|
+
engine = Haml::Engine.new(File.read(File.dirname(__FILE__) + "/templates/#{name}.haml"), format: :xhtml)
|
147
112
|
engine.def_method(@base, "render_standard")
|
148
113
|
@base.render_standard
|
149
114
|
end
|
150
115
|
end
|
151
116
|
|
152
117
|
def test_instance_variables_should_work_inside_templates
|
153
|
-
@base.instance_variable_set(
|
118
|
+
@base.instance_variable_set(:@content_for_layout, 'something')
|
154
119
|
assert_equal("<p>something</p>", render("%p= @content_for_layout").chomp)
|
155
120
|
|
156
121
|
@base.instance_eval("@author = 'Hampton Catlin'")
|
@@ -182,8 +147,8 @@ class TemplateTest < MiniTest::Unit::TestCase
|
|
182
147
|
Haml::Template.options = old_options
|
183
148
|
end
|
184
149
|
|
185
|
-
def
|
186
|
-
assert_equal(<<HTML, render(<<HAML
|
150
|
+
def test_with_output_buffer
|
151
|
+
assert_equal(<<HTML, render(<<HAML))
|
187
152
|
<p>
|
188
153
|
foo
|
189
154
|
baz
|
@@ -346,4 +311,12 @@ HTML
|
|
346
311
|
Test
|
347
312
|
HAML
|
348
313
|
end
|
314
|
+
|
315
|
+
class ::TosUnsafeObject; def to_s; '<hr>'; end; end
|
316
|
+
class ::TosSafeObject; def to_s; '<hr>'.html_safe; end; end
|
317
|
+
|
318
|
+
def test_object_that_returns_safe_buffer
|
319
|
+
assert_equal("<hr>\n", render('= ::TosSafeObject.new', escape_html: true))
|
320
|
+
assert_equal("<hr>\n", render('= ::TosUnsafeObject.new', escape_html: true))
|
321
|
+
end
|
349
322
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module TemplateTestHelper
|
2
|
+
TEMPLATE_PATH = File.join(__dir__, "templates")
|
3
|
+
end
|
4
|
+
|
5
|
+
module Haml::Filters::Test
|
6
|
+
include Haml::Filters::Base
|
7
|
+
|
8
|
+
def render(text)
|
9
|
+
"TESTING HAHAHAHA!"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Haml::Helpers
|
14
|
+
def test_partial(name, locals = {})
|
15
|
+
Haml::Engine.new(File.read(File.join(TemplateTestHelper::TEMPLATE_PATH, "_#{name}.haml")), Haml::Template.options).render(self, locals)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Egocentic
|
20
|
+
def method_missing(*args)
|
21
|
+
self
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class DummyController
|
26
|
+
attr_accessor :logger
|
27
|
+
def initialize
|
28
|
+
@logger = Egocentic.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.controller_path
|
32
|
+
''
|
33
|
+
end
|
34
|
+
|
35
|
+
def controller_path
|
36
|
+
''
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
test/templates/standard.haml
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TempleLineCounterTest < Haml::TestCase
|
4
|
+
TESTED_TEMPLES = [
|
5
|
+
[:multi,
|
6
|
+
[:code, "foo"],
|
7
|
+
[:static, "bar"],
|
8
|
+
[:dynamic, "baz"],
|
9
|
+
],
|
10
|
+
[:multi,
|
11
|
+
[:code, "foo\nbar\nbaz"],
|
12
|
+
[:static, "foo\nbar\nbaz"],
|
13
|
+
[:dynamic, "foo\nbar\nbaz"],
|
14
|
+
],
|
15
|
+
[:case,
|
16
|
+
["'a\nb', false", [:static, "hello\n"]],
|
17
|
+
[:else, [:code, "raise 'error\n'"]],
|
18
|
+
],
|
19
|
+
[:escape, true, [:dynamic, "foo\nbar"]],
|
20
|
+
[:escape, :once, [:dynamic, "foo\nbar"]],
|
21
|
+
[:escape, false, [:dynamic, "foo\nbar"]],
|
22
|
+
[:escape, true, [:static, "foo\nbar"]],
|
23
|
+
[:escape, :once, [:static, "foo\nbar"]],
|
24
|
+
[:escape, false, [:dynamic, "foo\nbar"]],
|
25
|
+
]
|
26
|
+
|
27
|
+
def test_count_lines
|
28
|
+
TESTED_TEMPLES.each do |temple|
|
29
|
+
code = Haml::TempleEngine.chain.inject(temple) do |exp, (symbol, filter)|
|
30
|
+
case symbol
|
31
|
+
when :Parser, :Compiler
|
32
|
+
exp
|
33
|
+
else
|
34
|
+
filter.call(Haml::TempleEngine).call(exp)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
assert_equal code.count("\n"), Haml::TempleLineCounter.count_lines(temple)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
begin
|
2
|
-
if RUBY_VERSION
|
2
|
+
if ENV['TRAVIS'] && RUBY_VERSION == '2.1.2' && !defined?(Rubinius)
|
3
3
|
require 'coveralls'
|
4
4
|
Coveralls.wear!
|
5
5
|
end
|
@@ -17,6 +17,7 @@ require 'minitest/autorun'
|
|
17
17
|
require 'action_pack'
|
18
18
|
require 'action_controller'
|
19
19
|
require 'action_view'
|
20
|
+
require 'action_view/base'
|
20
21
|
require 'nokogiri'
|
21
22
|
require 'rails'
|
22
23
|
|
@@ -38,17 +39,21 @@ $VERBOSE = true
|
|
38
39
|
require 'haml'
|
39
40
|
require 'haml/template'
|
40
41
|
|
41
|
-
Haml::Template.options[:ugly] = false
|
42
42
|
Haml::Template.options[:format] = :xhtml
|
43
43
|
|
44
|
+
BASE_TEST_CLASS = if defined?(Minitest::Test)
|
45
|
+
Minitest::Test
|
46
|
+
else
|
47
|
+
MiniTest::Unit::TestCase
|
48
|
+
end
|
49
|
+
|
44
50
|
module Declarative
|
45
51
|
def test(name, &block)
|
46
|
-
define_method("
|
52
|
+
define_method("test_ #{name}", &block)
|
47
53
|
end
|
48
54
|
end
|
49
55
|
|
50
|
-
class
|
51
|
-
|
56
|
+
class Haml::TestCase < BASE_TEST_CLASS
|
52
57
|
extend Declarative
|
53
58
|
|
54
59
|
def render(text, options = {}, base = nil, &block)
|
@@ -76,10 +81,6 @@ class MiniTest::Unit::TestCase
|
|
76
81
|
Haml::Util.silence_warnings(&block)
|
77
82
|
end
|
78
83
|
|
79
|
-
def rails_form_opener
|
80
|
-
'<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /></div>'
|
81
|
-
end
|
82
|
-
|
83
84
|
def assert_raises_message(klass, message)
|
84
85
|
yield
|
85
86
|
rescue Exception => e
|
@@ -92,5 +93,4 @@ class MiniTest::Unit::TestCase
|
|
92
93
|
def self.error(*args)
|
93
94
|
Haml::Error.message(*args)
|
94
95
|
end
|
95
|
-
|
96
96
|
end
|