deas 0.30.0 → 0.31.0
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.
- data/lib/deas/deas_runner.rb +0 -16
- data/lib/deas/runner.rb +19 -4
- data/lib/deas/test_helpers.rb +8 -4
- data/lib/deas/test_runner.rb +8 -17
- data/lib/deas/version.rb +1 -1
- data/test/support/view_handlers.rb +0 -34
- data/test/unit/deas_runner_tests.rb +0 -86
- data/test/unit/runner_tests.rb +87 -5
- data/test/unit/test_helpers_tests.rb +53 -0
- data/test/unit/test_runner_tests.rb +46 -45
- data/test/unit/view_handler_tests.rb +36 -25
- metadata +6 -4
data/lib/deas/deas_runner.rb
CHANGED
@@ -18,22 +18,6 @@ module Deas
|
|
18
18
|
response_data
|
19
19
|
end
|
20
20
|
|
21
|
-
def render(template_name, locals = nil)
|
22
|
-
source_render(self.template_source, template_name, locals)
|
23
|
-
end
|
24
|
-
|
25
|
-
def source_render(source, template_name, locals = nil)
|
26
|
-
source.render(template_name, self.handler, locals || {})
|
27
|
-
end
|
28
|
-
|
29
|
-
def partial(template_name, locals = nil)
|
30
|
-
source_partial(self.template_source, template_name, locals)
|
31
|
-
end
|
32
|
-
|
33
|
-
def source_partial(source, template_name, locals = nil)
|
34
|
-
source.partial(template_name, locals || {})
|
35
|
-
end
|
36
|
-
|
37
21
|
private
|
38
22
|
|
39
23
|
def run_callbacks(callbacks)
|
data/lib/deas/runner.rb
CHANGED
@@ -35,12 +35,27 @@ module Deas
|
|
35
35
|
def content_type(*args); raise NotImplementedError; end
|
36
36
|
def status(*args); raise NotImplementedError; end
|
37
37
|
def headers(*args); raise NotImplementedError; end
|
38
|
-
def render(*args); raise NotImplementedError; end
|
39
|
-
def source_render(*args); raise NotImplementedError; end
|
40
|
-
def partial(*args); raise NotImplementedError; end
|
41
|
-
def source_partial(*args); raise NotImplementedError; end
|
42
38
|
def send_file(*args); raise NotImplementedError; end
|
43
39
|
|
40
|
+
# the render methods are used by both the deas and test runners
|
41
|
+
# so we implement here
|
42
|
+
|
43
|
+
def render(template_name, locals = nil)
|
44
|
+
source_render(self.template_source, template_name, locals)
|
45
|
+
end
|
46
|
+
|
47
|
+
def source_render(source, template_name, locals = nil)
|
48
|
+
source.render(template_name, self.handler, locals || {})
|
49
|
+
end
|
50
|
+
|
51
|
+
def partial(template_name, locals = nil)
|
52
|
+
source_partial(self.template_source, template_name, locals)
|
53
|
+
end
|
54
|
+
|
55
|
+
def source_partial(source, template_name, locals = nil)
|
56
|
+
source.partial(template_name, locals || {})
|
57
|
+
end
|
58
|
+
|
44
59
|
class NormalizedParams
|
45
60
|
|
46
61
|
attr_reader :value
|
data/lib/deas/test_helpers.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
+
require 'rack/request'
|
2
|
+
require 'rack/response'
|
1
3
|
require 'deas/test_runner'
|
2
4
|
|
3
5
|
module Deas
|
4
6
|
|
5
7
|
module TestHelpers
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
def test_runner(handler_class, args = nil)
|
10
|
+
args ||= {}
|
11
|
+
args[:request] ||= Rack::Request.new({})
|
12
|
+
args[:response] ||= Rack::Response.new
|
13
|
+
args[:session] ||= args[:request].session
|
10
14
|
TestRunner.new(handler_class, args)
|
11
15
|
end
|
12
16
|
|
13
|
-
def test_handler(handler_class, args=nil)
|
17
|
+
def test_handler(handler_class, args = nil)
|
14
18
|
test_runner(handler_class, args).handler
|
15
19
|
end
|
16
20
|
|
data/lib/deas/test_runner.rb
CHANGED
@@ -75,30 +75,21 @@ module Deas
|
|
75
75
|
end
|
76
76
|
HeadersArgs = Struct.new(:value)
|
77
77
|
|
78
|
-
def
|
79
|
-
|
78
|
+
def send_file(file_path, options = nil, &block)
|
79
|
+
SendFileArgs.new(file_path, options, block)
|
80
80
|
end
|
81
|
-
|
81
|
+
SendFileArgs = Struct.new(:file_path, :options, :block)
|
82
82
|
|
83
83
|
def source_render(source, template_name, locals = nil)
|
84
|
-
|
85
|
-
|
86
|
-
SourceRenderArgs = Struct.new(:source, :template_name, :locals)
|
87
|
-
|
88
|
-
def partial(template_name, locals = nil)
|
89
|
-
PartialArgs.new(template_name, locals)
|
84
|
+
super # render the markup and discard it
|
85
|
+
RenderArgs.new(source, template_name, locals)
|
90
86
|
end
|
91
|
-
|
87
|
+
RenderArgs = Struct.new(:source, :template_name, :locals)
|
92
88
|
|
93
89
|
def source_partial(source, template_name, locals = nil)
|
94
|
-
|
90
|
+
super # render the markup and discard it
|
91
|
+
RenderArgs.new(source, template_name, locals)
|
95
92
|
end
|
96
|
-
SourcePartialArgs = SourceRenderArgs
|
97
|
-
|
98
|
-
def send_file(file_path, options = nil, &block)
|
99
|
-
SendFileArgs.new(file_path, options, block)
|
100
|
-
end
|
101
|
-
SendFileArgs = Struct.new(:file_path, :options, :block)
|
102
93
|
|
103
94
|
class NormalizedParams < Deas::Runner::NormalizedParams
|
104
95
|
def file_type?(value)
|
data/lib/deas/version.rb
CHANGED
@@ -35,40 +35,6 @@ class DeasRunnerViewHandler
|
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
-
class RenderViewHandler
|
39
|
-
include Deas::ViewHandler
|
40
|
-
|
41
|
-
def run!
|
42
|
-
render "my_template", :some => 'local'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
class SourceRenderViewHandler
|
47
|
-
include Deas::ViewHandler
|
48
|
-
|
49
|
-
def run!
|
50
|
-
source = Deas::TemplateSource.new(Factory.path)
|
51
|
-
source_render source, "my_template", :some => 'local'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
class PartialViewHandler
|
56
|
-
include Deas::ViewHandler
|
57
|
-
|
58
|
-
def run!
|
59
|
-
partial "my_partial", :some => 'local'
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class SourcePartialViewHandler
|
64
|
-
include Deas::ViewHandler
|
65
|
-
|
66
|
-
def run!
|
67
|
-
source = Deas::TemplateSource.new(Factory.path)
|
68
|
-
source_partial source, "my_partial", :some => 'local'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
38
|
class SendFileViewHandler
|
73
39
|
include Deas::ViewHandler
|
74
40
|
|
@@ -95,90 +95,4 @@ class Deas::DeasRunner
|
|
95
95
|
|
96
96
|
end
|
97
97
|
|
98
|
-
class RenderSetupTests < InitTests
|
99
|
-
setup do
|
100
|
-
@template_name = Factory.path
|
101
|
-
@locals = { Factory.string => Factory.string }
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
class RenderTests < RenderSetupTests
|
107
|
-
desc "render method"
|
108
|
-
setup do
|
109
|
-
@render_args = nil
|
110
|
-
Assert.stub(@runner.template_source, :render){ |*args| @render_args = args }
|
111
|
-
end
|
112
|
-
|
113
|
-
should "call to its template source render method" do
|
114
|
-
subject.render(@template_name, @locals)
|
115
|
-
exp = [@template_name, subject.handler, @locals]
|
116
|
-
assert_equal exp, @render_args
|
117
|
-
|
118
|
-
subject.render(@template_name)
|
119
|
-
exp = [@template_name, subject.handler, {}]
|
120
|
-
assert_equal exp, @render_args
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
class SourceRenderTests < RenderSetupTests
|
126
|
-
desc "source render method"
|
127
|
-
setup do
|
128
|
-
@source_render_args = nil
|
129
|
-
@source = Deas::TemplateSource.new(Factory.path)
|
130
|
-
Assert.stub(@source, :render){ |*args| @source_render_args = args }
|
131
|
-
end
|
132
|
-
|
133
|
-
should "call to the given source's render method" do
|
134
|
-
subject.source_render(@source, @template_name, @locals)
|
135
|
-
exp = [@template_name, subject.handler, @locals]
|
136
|
-
assert_equal exp, @source_render_args
|
137
|
-
|
138
|
-
subject.source_render(@source, @template_name)
|
139
|
-
exp = [@template_name, subject.handler, {}]
|
140
|
-
assert_equal exp, @source_render_args
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
class PartialTests < RenderSetupTests
|
146
|
-
desc "partial method"
|
147
|
-
setup do
|
148
|
-
@partial_args = nil
|
149
|
-
Assert.stub(@runner.template_source, :partial){ |*args| @partial_args = args }
|
150
|
-
end
|
151
|
-
|
152
|
-
should "call to its template source partial method" do
|
153
|
-
subject.partial(@template_name, @locals)
|
154
|
-
exp = [@template_name, @locals]
|
155
|
-
assert_equal exp, @partial_args
|
156
|
-
|
157
|
-
subject.partial(@template_name)
|
158
|
-
exp = [@template_name, {}]
|
159
|
-
assert_equal exp, @partial_args
|
160
|
-
end
|
161
|
-
|
162
|
-
end
|
163
|
-
|
164
|
-
class SourcePartialTests < RenderSetupTests
|
165
|
-
desc "source partial method"
|
166
|
-
setup do
|
167
|
-
@source_partial_args = nil
|
168
|
-
@source = Deas::TemplateSource.new(Factory.path)
|
169
|
-
Assert.stub(@source, :partial){ |*args| @source_partial_args = args }
|
170
|
-
end
|
171
|
-
|
172
|
-
should "call to the given source's partial method" do
|
173
|
-
subject.source_partial(@source, @template_name, @locals)
|
174
|
-
exp = [@template_name, @locals]
|
175
|
-
assert_equal exp, @source_partial_args
|
176
|
-
|
177
|
-
subject.source_partial(@source, @template_name)
|
178
|
-
exp = [@template_name, {}]
|
179
|
-
assert_equal exp, @source_partial_args
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
98
|
end
|
data/test/unit/runner_tests.rb
CHANGED
@@ -45,16 +45,12 @@ class Deas::Runner
|
|
45
45
|
assert_kind_of Deas::NullTemplateSource, subject.template_source
|
46
46
|
end
|
47
47
|
|
48
|
-
should "not implement
|
48
|
+
should "not implement its non-rendering actions" do
|
49
49
|
assert_raises(NotImplementedError){ subject.halt }
|
50
50
|
assert_raises(NotImplementedError){ subject.redirect }
|
51
51
|
assert_raises(NotImplementedError){ subject.content_type }
|
52
52
|
assert_raises(NotImplementedError){ subject.status }
|
53
53
|
assert_raises(NotImplementedError){ subject.headers }
|
54
|
-
assert_raises(NotImplementedError){ subject.render }
|
55
|
-
assert_raises(NotImplementedError){ subject.source_render }
|
56
|
-
assert_raises(NotImplementedError){ subject.partial }
|
57
|
-
assert_raises(NotImplementedError){ subject.source_partial }
|
58
54
|
assert_raises(NotImplementedError){ subject.send_file }
|
59
55
|
end
|
60
56
|
|
@@ -125,4 +121,90 @@ class Deas::Runner
|
|
125
121
|
|
126
122
|
end
|
127
123
|
|
124
|
+
class RenderSetupTests < InitTests
|
125
|
+
setup do
|
126
|
+
@template_name = Factory.path
|
127
|
+
@locals = { Factory.string => Factory.string }
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
class RenderTests < RenderSetupTests
|
133
|
+
desc "render method"
|
134
|
+
setup do
|
135
|
+
@render_args = nil
|
136
|
+
Assert.stub(@runner.template_source, :render){ |*args| @render_args = args }
|
137
|
+
end
|
138
|
+
|
139
|
+
should "call to its template source render method" do
|
140
|
+
subject.render(@template_name, @locals)
|
141
|
+
exp = [@template_name, subject.handler, @locals]
|
142
|
+
assert_equal exp, @render_args
|
143
|
+
|
144
|
+
subject.render(@template_name)
|
145
|
+
exp = [@template_name, subject.handler, {}]
|
146
|
+
assert_equal exp, @render_args
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
class SourceRenderTests < RenderSetupTests
|
152
|
+
desc "source render method"
|
153
|
+
setup do
|
154
|
+
@source_render_args = nil
|
155
|
+
@source = Deas::TemplateSource.new(Factory.path)
|
156
|
+
Assert.stub(@source, :render){ |*args| @source_render_args = args }
|
157
|
+
end
|
158
|
+
|
159
|
+
should "call to the given source's render method" do
|
160
|
+
subject.source_render(@source, @template_name, @locals)
|
161
|
+
exp = [@template_name, subject.handler, @locals]
|
162
|
+
assert_equal exp, @source_render_args
|
163
|
+
|
164
|
+
subject.source_render(@source, @template_name)
|
165
|
+
exp = [@template_name, subject.handler, {}]
|
166
|
+
assert_equal exp, @source_render_args
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
class PartialTests < RenderSetupTests
|
172
|
+
desc "partial method"
|
173
|
+
setup do
|
174
|
+
@partial_args = nil
|
175
|
+
Assert.stub(@runner.template_source, :partial){ |*args| @partial_args = args }
|
176
|
+
end
|
177
|
+
|
178
|
+
should "call to its template source partial method" do
|
179
|
+
subject.partial(@template_name, @locals)
|
180
|
+
exp = [@template_name, @locals]
|
181
|
+
assert_equal exp, @partial_args
|
182
|
+
|
183
|
+
subject.partial(@template_name)
|
184
|
+
exp = [@template_name, {}]
|
185
|
+
assert_equal exp, @partial_args
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
class SourcePartialTests < RenderSetupTests
|
191
|
+
desc "source partial method"
|
192
|
+
setup do
|
193
|
+
@source_partial_args = nil
|
194
|
+
@source = Deas::TemplateSource.new(Factory.path)
|
195
|
+
Assert.stub(@source, :partial){ |*args| @source_partial_args = args }
|
196
|
+
end
|
197
|
+
|
198
|
+
should "call to the given source's partial method" do
|
199
|
+
subject.source_partial(@source, @template_name, @locals)
|
200
|
+
exp = [@template_name, @locals]
|
201
|
+
assert_equal exp, @source_partial_args
|
202
|
+
|
203
|
+
subject.source_partial(@source, @template_name)
|
204
|
+
exp = [@template_name, {}]
|
205
|
+
assert_equal exp, @source_partial_args
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
|
128
210
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'deas/test_helpers'
|
3
|
+
|
4
|
+
require 'rack/request'
|
5
|
+
require 'rack/response'
|
6
|
+
require 'deas/view_handler'
|
7
|
+
|
8
|
+
module Deas::TestHelpers
|
9
|
+
|
10
|
+
class UnitTests < Assert::Context
|
11
|
+
desc "Deas::TestHelpers"
|
12
|
+
setup do
|
13
|
+
@test_helpers = Deas::TestHelpers
|
14
|
+
end
|
15
|
+
subject{ @test_helpers }
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
class MixinTests < UnitTests
|
20
|
+
desc "as a mixin"
|
21
|
+
setup do
|
22
|
+
context_class = Class.new{ include Deas::TestHelpers }
|
23
|
+
@context = context_class.new
|
24
|
+
end
|
25
|
+
subject{ @context }
|
26
|
+
|
27
|
+
should have_imeths :test_runner, :test_handler
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
class HandlerTestRunnerTests < MixinTests
|
32
|
+
desc "for handler testing"
|
33
|
+
setup do
|
34
|
+
@handler_class = Class.new{ include Deas::ViewHandler }
|
35
|
+
@runner = @context.test_runner(@handler_class)
|
36
|
+
@handler = @context.test_handler(@handler_class)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "build a test runner for a given handler" do
|
40
|
+
assert_kind_of ::Deas::TestRunner, @runner
|
41
|
+
assert_kind_of Rack::Request, @runner.request
|
42
|
+
assert_kind_of Rack::Response, @runner.response
|
43
|
+
assert_equal @runner.request.session, @runner.session
|
44
|
+
end
|
45
|
+
|
46
|
+
should "return an initialized handler instance" do
|
47
|
+
assert_kind_of @handler_class, @handler
|
48
|
+
assert_equal @runner.handler, @handler
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -133,71 +133,72 @@ class Deas::TestRunner
|
|
133
133
|
assert_equal exp_val, value.value
|
134
134
|
end
|
135
135
|
|
136
|
-
should "build
|
137
|
-
|
138
|
-
|
139
|
-
args = subject.render template_name, locals
|
136
|
+
should "build send file args if send file is called" do
|
137
|
+
path = Factory.path
|
138
|
+
args = subject.send_file path
|
140
139
|
|
141
|
-
assert_kind_of
|
142
|
-
[:
|
140
|
+
assert_kind_of SendFileArgs, args
|
141
|
+
[:file_path, :options, :block].each do |meth|
|
143
142
|
assert_respond_to meth, args
|
144
143
|
end
|
145
|
-
assert_equal
|
146
|
-
assert_equal locals, args.locals
|
144
|
+
assert_equal path, args.file_path
|
147
145
|
end
|
148
146
|
|
149
|
-
|
150
|
-
source = Deas::TemplateSource.new(Factory.path)
|
151
|
-
template_name = Factory.path
|
152
|
-
locals = { Factory.string => Factory.string }
|
153
|
-
args = subject.source_render source, template_name, locals
|
147
|
+
end
|
154
148
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
assert_equal template_name, args.template_name
|
161
|
-
assert_equal locals, args.locals
|
149
|
+
class RenderSetupTests < InitTests
|
150
|
+
setup do
|
151
|
+
@template_name = Factory.path
|
152
|
+
@locals = { Factory.string => Factory.string }
|
153
|
+
@source = Deas::TemplateSource.new(Factory.path)
|
162
154
|
end
|
163
155
|
|
164
|
-
|
165
|
-
template_name = Factory.path
|
166
|
-
locals = { Factory.string => Factory.string }
|
167
|
-
args = subject.partial template_name, locals
|
156
|
+
end
|
168
157
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
assert_equal locals, args.locals
|
158
|
+
class SourceRenderTests < RenderSetupTests
|
159
|
+
desc "source render method"
|
160
|
+
setup do
|
161
|
+
@source_render_args = nil
|
162
|
+
Assert.stub(@source, :render){ |*args| @source_render_args = args }
|
175
163
|
end
|
176
164
|
|
177
|
-
should "
|
178
|
-
|
179
|
-
template_name = Factory.path
|
180
|
-
locals = { Factory.string => Factory.string }
|
181
|
-
args = subject.source_partial source, template_name, locals
|
165
|
+
should "render the template, discard its output and build render args" do
|
166
|
+
args = subject.source_render(@source, @template_name, @locals)
|
182
167
|
|
183
|
-
|
168
|
+
exp = [@template_name, subject.handler, @locals]
|
169
|
+
assert_equal exp, @source_render_args
|
170
|
+
|
171
|
+
assert_kind_of RenderArgs, args
|
184
172
|
[:source, :template_name, :locals].each do |meth|
|
185
173
|
assert_respond_to meth, args
|
186
174
|
end
|
187
|
-
assert_equal source, args.source
|
188
|
-
assert_equal template_name, args.template_name
|
189
|
-
assert_equal locals, args.locals
|
175
|
+
assert_equal @source, args.source
|
176
|
+
assert_equal @template_name, args.template_name
|
177
|
+
assert_equal @locals, args.locals
|
190
178
|
end
|
191
179
|
|
192
|
-
|
193
|
-
path = Factory.path
|
194
|
-
args = subject.send_file path
|
180
|
+
end
|
195
181
|
|
196
|
-
|
197
|
-
|
182
|
+
class SourcePartialTests < RenderSetupTests
|
183
|
+
desc "source partial method"
|
184
|
+
setup do
|
185
|
+
@source_partial_args = nil
|
186
|
+
Assert.stub(@source, :partial){ |*args| @source_partial_args = args }
|
187
|
+
end
|
188
|
+
|
189
|
+
should "render the template, discard its output build render args" do
|
190
|
+
args = subject.source_partial(@source, @template_name, @locals)
|
191
|
+
|
192
|
+
exp = [@template_name, @locals]
|
193
|
+
assert_equal exp, @source_partial_args
|
194
|
+
|
195
|
+
assert_kind_of RenderArgs, args
|
196
|
+
[:source, :template_name, :locals].each do |meth|
|
198
197
|
assert_respond_to meth, args
|
199
198
|
end
|
200
|
-
assert_equal
|
199
|
+
assert_equal @source, args.source
|
200
|
+
assert_equal @template_name, args.template_name
|
201
|
+
assert_equal @locals, args.locals
|
201
202
|
end
|
202
203
|
|
203
204
|
end
|
@@ -37,7 +37,8 @@ module Deas::ViewHandler
|
|
37
37
|
class InitTests < UnitTests
|
38
38
|
desc "when init"
|
39
39
|
setup do
|
40
|
-
@
|
40
|
+
@runner = test_runner(@handler_class)
|
41
|
+
@handler = @runner.handler
|
41
42
|
end
|
42
43
|
subject{ @handler }
|
43
44
|
|
@@ -72,36 +73,46 @@ module Deas::ViewHandler
|
|
72
73
|
assert_raises(NotImplementedError){ test_runner(EmptyViewHandler).run }
|
73
74
|
end
|
74
75
|
|
75
|
-
should "
|
76
|
-
|
77
|
-
assert_equal "
|
78
|
-
assert_equal({:some =>
|
76
|
+
should "send files" do
|
77
|
+
send_file_args = test_runner(SendFileViewHandler).run
|
78
|
+
assert_equal "my_file.txt", send_file_args.file_path
|
79
|
+
assert_equal({:some => :option}, send_file_args.options)
|
79
80
|
end
|
80
81
|
|
81
|
-
|
82
|
-
render_args = test_runner(SourceRenderViewHandler).run
|
83
|
-
assert_kind_of Deas::TemplateSource, render_args.source
|
84
|
-
assert_equal "my_template", render_args.template_name
|
85
|
-
assert_equal({:some => 'local'}, render_args.locals)
|
86
|
-
end
|
82
|
+
end
|
87
83
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
class RenderTests < RunTests
|
85
|
+
setup do
|
86
|
+
@template_name = Factory.path
|
87
|
+
@locals = { Factory.string => Factory.string }
|
88
|
+
@source = Deas::TemplateSource.new(Factory.path)
|
89
|
+
|
90
|
+
@render_args = nil
|
91
|
+
Assert.stub(@runner.template_source, :render){ |*args| @render_args = args }
|
92
|
+
@source_render_args = nil
|
93
|
+
Assert.stub(@source, :render){ |*args| @source_render_args = args }
|
94
|
+
@partial_args = nil
|
95
|
+
Assert.stub(@runner.template_source, :partial){ |*args| @partial_args = args }
|
96
|
+
@source_partial_args = nil
|
97
|
+
Assert.stub(@source, :partial){ |*args| @source_partial_args = args }
|
92
98
|
end
|
93
99
|
|
94
|
-
should "render
|
95
|
-
|
96
|
-
|
97
|
-
assert_equal
|
98
|
-
assert_equal({:some => 'local'}, partial_args.locals)
|
99
|
-
end
|
100
|
+
should "render templates" do
|
101
|
+
subject.send(:render, @template_name, @locals)
|
102
|
+
exp = [@template_name, subject, @locals]
|
103
|
+
assert_equal exp, @render_args
|
100
104
|
|
101
|
-
|
102
|
-
|
103
|
-
assert_equal
|
104
|
-
|
105
|
+
subject.send(:source_render, @source, @template_name, @locals)
|
106
|
+
exp = [@template_name, subject, @locals]
|
107
|
+
assert_equal exp, @source_render_args
|
108
|
+
|
109
|
+
subject.send(:partial, @template_name, @locals)
|
110
|
+
exp = [@template_name, @locals]
|
111
|
+
assert_equal exp, @partial_args
|
112
|
+
|
113
|
+
subject.send(:source_partial, @source, @template_name, @locals)
|
114
|
+
exp = [@template_name, @locals]
|
115
|
+
assert_equal exp, @source_partial_args
|
105
116
|
end
|
106
117
|
|
107
118
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 99
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 31
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.31.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kelly Redding
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2015-02-
|
19
|
+
date: 2015-02-06 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
@@ -171,6 +171,7 @@ files:
|
|
171
171
|
- test/unit/sinatra_runner_tests.rb
|
172
172
|
- test/unit/template_engine_tests.rb
|
173
173
|
- test/unit/template_source_tests.rb
|
174
|
+
- test/unit/test_helpers_tests.rb
|
174
175
|
- test/unit/test_runner_tests.rb
|
175
176
|
- test/unit/url_tests.rb
|
176
177
|
- test/unit/view_handler_tests.rb
|
@@ -238,6 +239,7 @@ test_files:
|
|
238
239
|
- test/unit/sinatra_runner_tests.rb
|
239
240
|
- test/unit/template_engine_tests.rb
|
240
241
|
- test/unit/template_source_tests.rb
|
242
|
+
- test/unit/test_helpers_tests.rb
|
241
243
|
- test/unit/test_runner_tests.rb
|
242
244
|
- test/unit/url_tests.rb
|
243
245
|
- test/unit/view_handler_tests.rb
|