gara 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/gara/delegator.rb +3 -3
- data/lib/gara/html5_emitter.rb +1 -1
- data/lib/gara/renderer.rb +7 -0
- data/lib/gara/template/handler.rb +1 -1
- data/lib/gara/version.rb +1 -1
- data/lib/gara.rb +3 -0
- data/test/dummy/app/controllers/hello_controller.rb +1 -0
- data/test/dummy/app/views/hello/show.html.gara +1 -1
- data/test/dummy/log/development.log +6 -0
- data/test/dummy/log/test.log +1905 -0
- data/test/dummy/test/controllers/hello_controller_test.rb +1 -0
- data/test/gara_test.rb +44 -0
- data/test/handler_test.rb +5 -0
- metadata +2 -1
data/test/gara_test.rb
CHANGED
@@ -4,4 +4,48 @@ class GaraTest < ActiveSupport::TestCase
|
|
4
4
|
test "we have a module" do
|
5
5
|
assert_kind_of Module, Gara
|
6
6
|
end
|
7
|
+
|
8
|
+
test "Gara.render renders a template" do
|
9
|
+
result = Gara.render(self) do
|
10
|
+
ul {
|
11
|
+
li 'one'
|
12
|
+
li 'two'
|
13
|
+
li 'three'
|
14
|
+
}
|
15
|
+
end
|
16
|
+
assert_equal "<ul>\n<li>one</li>\n<li>two</li>\n<li>three</li>\n</ul>", result
|
17
|
+
end
|
18
|
+
|
19
|
+
test "performance is okay" do
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class TestEmitter
|
24
|
+
module DelegatedMethods
|
25
|
+
def component1 ; @gara_delegate.component1 ; yield if block_given? ; end
|
26
|
+
def component2 ; @gara_delegate.component2 ; yield if block_given? ; end
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
@doc = ""
|
31
|
+
end
|
32
|
+
def component1 ; @doc << "stuff " ; end
|
33
|
+
def component2 ; @doc << "and more stuff" ; end
|
34
|
+
|
35
|
+
def registered_methods
|
36
|
+
return DelegatedMethods
|
37
|
+
end
|
38
|
+
def emit
|
39
|
+
@doc
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
test "another emitter may be supplied" do
|
44
|
+
result = Gara.render(self, TestEmitter.new) {
|
45
|
+
component1 {
|
46
|
+
component2
|
47
|
+
}
|
48
|
+
}
|
49
|
+
assert_equal "stuff and more stuff", result
|
50
|
+
end
|
7
51
|
end
|
data/test/handler_test.rb
CHANGED
@@ -76,5 +76,10 @@ class HandlerTest < ActiveSupport::TestCase
|
|
76
76
|
assert_equal with_doctype("<html><body><h1>hello</h1></body></html>\n"), render
|
77
77
|
end
|
78
78
|
|
79
|
+
test "locals work" do
|
80
|
+
@template = new_template "h1 title"
|
81
|
+
@template.locals = [:title]
|
82
|
+
assert_equal "<h1>Foo</h1>", render(title: 'Foo')
|
83
|
+
end
|
79
84
|
|
80
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Talcott Smith
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/gara.rb
|
66
66
|
- lib/gara/delegator.rb
|
67
67
|
- lib/gara/html5_emitter.rb
|
68
|
+
- lib/gara/renderer.rb
|
68
69
|
- lib/gara/template/handler.rb
|
69
70
|
- lib/gara/version.rb
|
70
71
|
- lib/tasks/gara_tasks.rake
|