Class: Sanford::TestRunner
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Attributes inherited from Runner
#handler, #handler_class, #logger, #params, #request, #router, #template_source
Instance Method Summary collapse
-
#initialize(handler_class, args = nil) ⇒ TestRunner
constructor
A new instance of TestRunner.
-
#run ⇒ Object
If ‘init` generated a response, we don’t want to ‘run` at all.
Methods inherited from Runner
Constructor Details
#initialize(handler_class, args = nil) ⇒ TestRunner
Returns a new instance of TestRunner.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sanford/test_runner.rb', line 13 def initialize(handler_class, args = nil) if !handler_class.include?(Sanford::ServiceHandler) raise InvalidServiceHandlerError, "#{handler_class.inspect} is not a"\ " Sanford::ServiceHandler" end args = (args || {}).dup super(handler_class, { :request => args.delete(:request), :params => normalize_params(args.delete(:params) || {}), :logger => args.delete(:logger), :router => args.delete(:router), :template_source => args.delete(:template_source) }) args.each{ |key, value| @handler.send("#{key}=", value) } return_value = catch(:halt){ @handler.init; nil } @response = build_and_serialize_response{ return_value } if return_value end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
11 12 13 |
# File 'lib/sanford/test_runner.rb', line 11 def response @response end |
Instance Method Details
#run ⇒ Object
If ‘init` generated a response, we don’t want to ‘run` at all. This makes the `TestRunner` behave similar to the `SanfordRunner`, i.e. `halt` in `init` stops processing where `halt` is called.
37 38 39 |
# File 'lib/sanford/test_runner.rb', line 37 def run @response ||= build_and_serialize_response{ self.handler.run } end |