gara 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/gara/delegator.rb +1 -10
- data/lib/gara/html5_emitter.rb +57 -10
- data/lib/gara/version.rb +1 -1
- data/test/dummy/app/views/layouts/application.html.gara +1 -1
- data/test/dummy/log/test.log +2889 -0
- data/test/gara_test.rb +5 -4
- data/test/handler_test.rb +23 -1
- metadata +1 -1
data/test/gara_test.rb
CHANGED
@@ -22,8 +22,8 @@ class GaraTest < ActiveSupport::TestCase
|
|
22
22
|
|
23
23
|
class TestEmitter
|
24
24
|
module DelegatedMethods
|
25
|
-
def component1 ; @
|
26
|
-
def component2 ; @
|
25
|
+
def component1 ; @delegate.component1 ; yield if block_given? ; end
|
26
|
+
def component2 ; @delegate.component2 ; yield if block_given? ; end
|
27
27
|
end
|
28
28
|
|
29
29
|
def initialize
|
@@ -32,8 +32,9 @@ class GaraTest < ActiveSupport::TestCase
|
|
32
32
|
def component1 ; @doc << "stuff " ; end
|
33
33
|
def component2 ; @doc << "and more stuff" ; end
|
34
34
|
|
35
|
-
def
|
36
|
-
|
35
|
+
def add_methods_to(context)
|
36
|
+
context.instance_variable_set(:@delegate, self)
|
37
|
+
context.extend(DelegatedMethods)
|
37
38
|
end
|
38
39
|
def emit
|
39
40
|
@doc
|
data/test/handler_test.rb
CHANGED
@@ -5,6 +5,7 @@ class HandlerTest < ActiveSupport::TestCase
|
|
5
5
|
GARAHandler = Gara::Template::Handler.new
|
6
6
|
|
7
7
|
DEFAULT_DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">"
|
8
|
+
A_LINK = %Q(<a href="#">link</a>)
|
8
9
|
|
9
10
|
class LookupContext
|
10
11
|
def disable_cache
|
@@ -26,6 +27,10 @@ class HandlerTest < ActiveSupport::TestCase
|
|
26
27
|
def lookup_context
|
27
28
|
@lookup_context ||= LookupContext.new
|
28
29
|
end
|
30
|
+
|
31
|
+
def link_helper
|
32
|
+
A_LINK
|
33
|
+
end
|
29
34
|
end
|
30
35
|
|
31
36
|
def new_template(body = " h1 'Hello' ", details = { format: :html })
|
@@ -73,7 +78,7 @@ class HandlerTest < ActiveSupport::TestCase
|
|
73
78
|
|
74
79
|
test "real document has doctype and newline" do
|
75
80
|
@template = new_template("html { body { h1 \"hello\" } }")
|
76
|
-
assert_equal with_doctype("<html
|
81
|
+
assert_equal with_doctype("<html><body><h1>hello</h1></body></html>\n"), render
|
77
82
|
end
|
78
83
|
|
79
84
|
test "locals work" do
|
@@ -82,4 +87,21 @@ class HandlerTest < ActiveSupport::TestCase
|
|
82
87
|
assert_equal "<h1>Foo</h1>", render(title: 'Foo')
|
83
88
|
end
|
84
89
|
|
90
|
+
test "string in block works" do
|
91
|
+
@template = new_template "h1 { 'foo' } "
|
92
|
+
assert_equal "<h1>foo</h1>", render
|
93
|
+
end
|
94
|
+
|
95
|
+
test "helpers returning html when alone in a block" do
|
96
|
+
@template = new_template("li { link_helper } ")
|
97
|
+
assert_equal "<li>#{A_LINK}</li>", render
|
98
|
+
end
|
99
|
+
|
100
|
+
test "helpers returning html work in sequence within a block" do
|
101
|
+
@template = new_template("li { link_helper ; link_helper } ")
|
102
|
+
without_self = render
|
103
|
+
assert_equal "<li>\n#{A_LINK}#{A_LINK}\n</li>", render
|
104
|
+
end
|
105
|
+
|
106
|
+
|
85
107
|
end
|