-
-
Save deadkarma/d7df2de54386560dba42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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