Class: Sanford::TestRunner
Constant Summary
Constants inherited from Runner
Runner::DEFAULT_DATA, Runner::DEFAULT_STATUS_CODE, Runner::DEFAULT_STATUS_MSG
Instance Attribute Summary
Attributes inherited from Runner
#handler, #handler_class, #logger, #params, #request, #router, #template_source
Instance Method Summary collapse
-
#halt(*args) ⇒ Object
helpers.
- #halted? ⇒ Boolean
-
#initialize(handler_class, args = nil) ⇒ TestRunner
constructor
A new instance of TestRunner.
- #run ⇒ Object
-
#to_response ⇒ Object
attempt to encode (and then throw away) the response this will error on the developer if it can’t encode their response.
Methods inherited from Runner
Constructor Details
#initialize(handler_class, args = nil) ⇒ TestRunner
Returns a new instance of TestRunner.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sanford/test_runner.rb', line 11 def initialize(handler_class, args = nil) if !handler_class.include?(Sanford::ServiceHandler) raise InvalidServiceHandlerError, "#{handler_class.inspect} is not a " \ "Sanford::ServiceHandler" end a = (args || {}).dup super(handler_class, { :logger => a.delete(:logger), :router => a.delete(:router), :template_source => a.delete(:template_source), :request => a.delete(:request), :params => normalize_params(a.delete(:params) || {}) }) a.each{ |key, value| @handler.send("#{key}=", value) } @halted = false catch(:halt){ self.handler.sanford_init } end |
Instance Method Details
#halt(*args) ⇒ Object
helpers
48 49 50 51 |
# File 'lib/sanford/test_runner.rb', line 48 def halt(*args) @halted = true super end |
#halted? ⇒ Boolean
31 |
# File 'lib/sanford/test_runner.rb', line 31 def halted?; @halted; end |
#run ⇒ Object
33 34 35 36 |
# File 'lib/sanford/test_runner.rb', line 33 def run catch(:halt){ self.handler.sanford_run } if !self.halted? self.to_response end |
#to_response ⇒ Object
attempt to encode (and then throw away) the response this will error on the developer if it can’t encode their response
40 41 42 43 44 |
# File 'lib/sanford/test_runner.rb', line 40 def to_response super.tap do |response| Sanford::Protocol.msg_body.encode(response.to_hash) if response end end |