Class: Deas::TestRunner
Defined Under Namespace
Classes: ContentTypeArgs, HaltArgs, NormalizedParams, RedirectArgs, RenderArgs, SendFileArgs
Constant Summary
Constants inherited
from Runner
Runner::DEFAULT_CHARSET, Runner::DEFAULT_MIME_TYPE
Instance Attribute Summary collapse
Attributes inherited from Runner
#handler, #handler_class, #logger, #params, #request, #route_path, #router, #template_source
Instance Method Summary
collapse
Methods inherited from Runner
#body, body_value, #headers, #partial, #render, #set_cookie, #status, #to_rack
Constructor Details
#initialize(handler_class, args = nil) ⇒ TestRunner
Returns a new instance of TestRunner.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/deas/test_runner.rb', line 14
def initialize(handler_class, args = nil)
if !handler_class.include?(Deas::ViewHandler)
raise InvalidViewHandlerError, "#{handler_class.inspect} is not a " \
"Deas::ViewHandler"
end
@run_return_value = nil
@content_type_args = nil
@halted = false
a = (args || {}).dup
super(handler_class, {
:logger => a.delete(:logger),
:router => a.delete(:router),
:template_source => a.delete(:template_source),
:request => a.delete(:request),
:route_path => a.delete(:route_path),
:params => NormalizedParams.new(a.delete(:params) || {}).value
})
@splat = a.delete(:splat)
a.each{|key, value| self.handler.send("#{key}=", value) }
catch(:halt){ self.handler.deas_init }
end
|
Instance Attribute Details
#content_type_args ⇒ Object
Returns the value of attribute content_type_args.
12
13
14
|
# File 'lib/deas/test_runner.rb', line 12
def content_type_args
@content_type_args
end
|
Instance Method Details
#content_type(extname, params = nil) ⇒ Object
49
50
51
52
|
# File 'lib/deas/test_runner.rb', line 49
def content_type(extname, params = nil)
@content_type_args = ContentTypeArgs.new(extname, params)
super
end
|
#halt(*args) ⇒ Object
54
55
56
57
58
|
# File 'lib/deas/test_runner.rb', line 54
def halt(*args)
@halted = true
@run_return_value ||= HaltArgs.new(args)
super
end
|
#halted? ⇒ Boolean
40
|
# File 'lib/deas/test_runner.rb', line 40
def halted?; @halted; end
|
#redirect(location, *halt_args) ⇒ Object
60
61
62
63
|
# File 'lib/deas/test_runner.rb', line 60
def redirect(location, *halt_args)
@run_return_value ||= RedirectArgs.new(location, HaltArgs.new(halt_args))
super
end
|
#run ⇒ Object
42
43
44
45
|
# File 'lib/deas/test_runner.rb', line 42
def run
catch(:halt){ self.handler.deas_run } if !self.halted?
@run_return_value
end
|
#send_file(file_path, opts = nil) ⇒ Object
65
66
67
68
|
# File 'lib/deas/test_runner.rb', line 65
def send_file(file_path, opts = nil)
@run_return_value ||= SendFileArgs.new(file_path, opts)
super
end
|
#source_partial(source, template_name, locals = nil) ⇒ Object
75
76
77
78
79
80
81
82
|
# File 'lib/deas/test_runner.rb', line 75
def source_partial(source, template_name, locals = nil)
super
RenderArgs.new(source, template_name, locals)
end
|
#source_render(source, template_name, locals = nil) ⇒ Object
70
71
72
73
|
# File 'lib/deas/test_runner.rb', line 70
def source_render(source, template_name, locals = nil)
@run_return_value ||= RenderArgs.new(source, template_name, locals)
super
end
|
#splat ⇒ Object
39
|
# File 'lib/deas/test_runner.rb', line 39
def splat; @splat; end
|