Module: GrapeApe::TestHelper
- Includes:
- Goliath::TestHelper
- Defined in:
- lib/grape_ape/test_helper.rb
Instance Method Summary collapse
-
#server(api, port, options = {}, &blk) ⇒ Goliath::Server
Launches an instance of a given API server.
-
#with_api(api, options = {}, &blk) ⇒ Object
Wrapper for launching API and executing given code block.
Instance Method Details
#server(api, port, options = {}, &blk) ⇒ Goliath::Server
Launches an instance of a given API server. The server will launch on the specified port.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/grape_ape/test_helper.rb', line 25 def server(api, port, = {}, &blk) op = OptionParser.new s = GrapeApe::Goliath::Server.new s.logger = setup_logger() s.api = api s.app = ::Goliath::Rack::Builder.build(api.class, s.api) s.api.(op, ) s. = s.port = port s.plugins = api.class.plugins @test_server_port = s.port if blk s.start(&blk) s end |
#with_api(api, options = {}, &blk) ⇒ Object
Note:
This will not return until stop is called.
Wrapper for launching API and executing given code block. This will start the EventMachine reactor running.
14 15 16 |
# File 'lib/grape_ape/test_helper.rb', line 14 def with_api(api, = {}, &blk) server(GrapeApe::Server.new(api: api), .delete(:port) || 9900, , &blk) end |