Skip to content

Instantly share code, notes, and snippets.

@jamiehodge
Created November 9, 2012 09:26
Show Gist options
  • Save jamiehodge/4044753 to your computer and use it in GitHub Desktop.
Save jamiehodge/4044753 to your computer and use it in GitHub Desktop.
Sinatra + Puma + Rubinius 2.0
require "sinatra/base"
require "puma"
require "rack/handler/puma"
require "minitest/autorun"
require "net/http"
require "slim"
class App < Sinatra::Base
post "/" do
params
end
end
builder = Rack::Builder.new { run App }
class AppTest < MiniTest::Unit::TestCase
def setup
@app = Rack::Lint.new(App)
@server = nil
@host = '127.0.0.1'
@port = 9292
@thread = Thread.new do
Rack::Handler::Puma.run(@app, :Host => @host, :Port => @port) do |server|
@server = server
end
end
Thread.pass until @server && @server.running
end
def teardown
@server.stop
@thread.kill
end
def post(path, formdata={})
Net::HTTP.start(@host, @port) { |http|
post = Net::HTTP::Post.new(path)
post.form_data = formdata
http.request(post)
}
end
def test_post_raises
assert_raises { post("/") }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment