PageRenderTime 394ms CodeModel.GetById 191ms app.highlight 4ms RepoModel.GetById 192ms app.codeStats 6ms

/features/steps/env.rb

http://github.com/jnunemaker/httparty
Ruby | 27 lines | 23 code | 4 blank | 0 comment | 2 complexity | a0d9904781113463c77f434d99a5ac11 MD5 | raw file
 1require 'mongrel'
 2require './lib/httparty'
 3require 'rspec/expectations'
 4require 'aruba/cucumber'
 5
 6def run_server(port)
 7  @host_and_port = "0.0.0.0:#{port}"
 8  @server = Mongrel::HttpServer.new("0.0.0.0", port)
 9  @server.run
10  @request_options = {}
11end
12
13def new_port
14  server = TCPServer.new('0.0.0.0', nil)
15  port = server.addr[1]
16ensure
17  server.close
18end
19
20Before('~@command_line') do
21  port = ENV["HTTPARTY_PORT"] || new_port
22  run_server(port)
23end
24
25After do
26  @server.stop if @server
27end