lib/deas/test_runner.rb in deas-0.33.0 vs lib/deas/test_runner.rb in deas-0.34.0

- old
+ new

@@ -7,11 +7,11 @@ InvalidServiceHandlerError = Class.new(StandardError) class TestRunner < Runner - attr_reader :return_value + attr_reader :response_value def initialize(handler_class, args = nil) if !handler_class.include?(Deas::ViewHandler) raise InvalidServiceHandlerError, "#{handler_class.inspect} is not a"\ " Deas::ServiceHandler" @@ -27,15 +27,22 @@ :router => args.delete(:router), :template_source => args.delete(:template_source) }) args.each{|key, value| self.handler.send("#{key}=", value) } - @return_value = catch(:halt){ self.handler.init; nil } + @response_value = catch(:halt){ self.handler.init; nil } end + # TODO: remove eventually + def return_value + warn "calling `return_value` on a test runner is deprecated - " \ + "switch to `response_value` instead" + self.response_value + end + def run - @return_value ||= catch(:halt){ self.handler.run } + @response_value ||= catch(:halt){ self.handler.run } end # Helpers def halt(*args) @@ -58,21 +65,30 @@ class RedirectArgs < Struct.new(:path, :halt_args) def redirect?; true; end end - def content_type(value, opts={}) - ContentTypeArgs.new(value, opts) + def content_type(*args) + return @content_type if args.empty? + opts, value = [ + args.last.kind_of?(Hash) ? args.pop : {}, + args.last + ] + @content_type = ContentTypeArgs.new(value, opts) end ContentTypeArgs = Struct.new(:value, :opts) - def status(value) - StatusArgs.new(value) + def status(*args) + return @status if args.empty? + value = args.last + @status = StatusArgs.new(value) end StatusArgs = Struct.new(:value) - def headers(value) - HeadersArgs.new(value) + def headers(*args) + return @headers if args.empty? + value = args.last + @headers = HeadersArgs.new(value) end HeadersArgs = Struct.new(:value) def send_file(file_path, options = nil, &block) SendFileArgs.new(file_path, options, block)