Skip to content

Instantly share code, notes, and snippets.

@kyamaguchi
Created May 22, 2012 02:38
Show Gist options
  • Save kyamaguchi/2766192 to your computer and use it in GitHub Desktop.
Save kyamaguchi/2766192 to your computer and use it in GitHub Desktop.
Rspec webrick
# spec/support/bindaddress.rb
# Equivalent to $ rails server -b 127.0.0.1
require 'webrick'
module Rack
module Handler
class WEBrick
def self.run(app, options={})
options[:BindAddress] = '127.0.0.1'
@server = ::WEBrick::HTTPServer.new(options)
@server.mount "/", Rack::Handler::WEBrick, app
yield @server if block_given?
@server.start
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment