gara 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,7 @@ class HelloControllerTest < ActionController::TestCase
4
4
  test "should get show" do
5
5
  get :show
6
6
  assert_response :success
7
+ assert_match /Hi there/, @response.body
7
8
  end
8
9
 
9
10
  end
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.2
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