lib/goliath/test_helper.rb in goliath-0.9.0 vs lib/goliath/test_helper.rb in goliath-0.9.1

- old
+ new

@@ -43,16 +43,21 @@ # Launches an instance of a given API server. The server # will launch on the default settings of localhost port 9000. # # @param api [Class] The API class to launch # @param port [Integer] The port to run the server on - # @return [Nil] - def server(api, port = 9000) + # @param options [Hash] The options hash to provide to the server + # @return [Goliath::Server] The executed server + def server(api, port = 9000, options = {}) + op = OptionParser.new + s = Goliath::Server.new s.logger = mock('log').as_null_object s.api = api.new s.app = build_app(api) + s.api.options_parser(op, options) + s.options = options s.port = port s.start s end @@ -65,14 +70,15 @@ # Wrapper for launching API and executing given code block. This # will start the EventMachine reactor running. # # @param api [Class] The API class to launch + # @param options [Hash] The options to pass to the server # @param blk [Proc] The code to execute after the server is launched. # @note This will not return until stop is called. - def with_api(api, &blk) + def with_api(api, options = {}, &blk) EM.synchrony do - @api_server = server(api) + @api_server = server(api, 9000, options) blk.call end end # Helper method to setup common callbacks for various request methods.