diff --git a/bin/rackup b/bin/rackup
index 91abe17..3a90327 100755
--- a/bin/rackup
+++ b/bin/rackup
@@ -9,7 +9,7 @@ automatic = false
 server = nil
 env = "development"
 daemonize = false
-pid = nil
+pid = File.expand_path("rack.pid")
 options = {:Port => 9292, :Host => "0.0.0.0", :AccessLog => []}
 
 # Don't evaluate CGI ISINDEX parameters.
diff --git a/test/rackup/config.ru b/test/rackup/config.ru
new file mode 100644
index 0000000..2490c6e
--- /dev/null
+++ b/test/rackup/config.ru
@@ -0,0 +1,25 @@
+require "#{File.dirname(__FILE__)}/../testrequest"
+
+$stderr = StringIO.new
+
+class EnvMiddleware
+  def initialize(app)
+    @app = app
+  end
+  
+  def call(env)
+    if env["PATH_INFO"] == "/broken_lint"
+      return [200, {}, ["Broken Lint"]]
+    end
+
+    env["test.$DEBUG"]      = $DEBUG
+    env["test.$EVAL"]       = BUKKIT if defined?(BUKKIT)
+    env["test.$VERBOSE"]    = $VERBOSE
+    env["test.$LOAD_PATH"]  = $LOAD_PATH
+    env["test.Ping"]        = defined?(Ping)
+    @app.call(env)
+  end
+end
+
+use EnvMiddleware
+run TestRequest.new
diff --git a/test/spec_rackup.rb b/test/spec_rackup.rb
new file mode 100644
index 0000000..c3e46a7
--- /dev/null
+++ b/test/spec_rackup.rb
@@ -0,0 +1,133 @@
+require 'test/spec'
+require 'rack/rackup'
+require 'testrequest'
+require 'open3'
+
+begin
+require "mongrel"
+
+context "rackup" do
+  include TestRequest::Helpers
+
+  def run_rackup(*args)
+    options = args.last.is_a?(Hash) ? args.pop : {}
+    flags   = args.first
+    @host = options[:host] || "0.0.0.0"
+    @port = options[:port] || 9292
+
+    Dir.chdir("#{root}/test/rackup") do
+      @rackup = IO.popen("#{Gem.ruby} -S #{rackup} #{flags}")
+    end
+
+    return if options[:port] == false
+
+    # Wait until the server is available
+    begin
+      GET("/")
+    rescue
+      sleep 0.05
+      retry
+    end
+  end
+
+  def output
+    @rackup.read
+  end
+
+  after do
+    Process.kill(9, @rackup.pid) if @rackup
+
+    Dir["#{root}/**/*.pid"].each do |file|
+      Process.kill(9, File.read(file).to_i)
+      File.delete(file)
+    end
+  end
+
+  specify "rackup" do
+    run_rackup
+    response["PATH_INFO"].should.equal '/'
+    response["test.$DEBUG"].should.be false
+    response["test.$EVAL"].should.be nil
+    response["test.$VERBOSE"].should.be false
+    response["test.Ping"].should.be nil
+    response["SERVER_SOFTWARE"].should.not =~ /webrick/
+  end
+
+  specify "rackup --help" do
+    run_rackup "--help", :port => false
+    output.should.match /--port/
+  end
+
+  specify "rackup --port" do
+    run_rackup "--port 9000", :port => 9000
+    response["SERVER_PORT"].should.equal "9000"
+  end
+
+  specify "rackup --debug" do
+    run_rackup "--debug"
+    response["test.$DEBUG"].should.be true
+  end
+
+  specify "rackup --eval" do
+    run_rackup %{--eval "BUKKIT = 'BUKKIT'"}
+    response["test.$EVAL"].should.equal "BUKKIT"
+  end
+
+  specify "rackup --warn" do
+    run_rackup %{--warn}
+    response["test.$VERBOSE"].should.be true
+  end
+
+  specify "rackup --include" do
+    run_rackup %{--include /foo/bar}
+    response["test.$LOAD_PATH"].should.include "/foo/bar"
+  end
+
+  specify "rackup --require" do
+    run_rackup %{--require ping}
+    response["test.Ping"].should.equal "constant"
+  end
+
+  specify "rackup --server" do
+    run_rackup %{--server webrick}
+    response["SERVER_SOFTWARE"].should =~ /webrick/i
+  end
+
+  specify "rackup --host" do
+    run_rackup %{--host 127.0.0.1}, :host => "127.0.0.1"
+    response["REMOTE_ADDR"].should.equal "127.0.0.1"
+  end
+
+  specify "rackup --daemonize" do
+    run_rackup %{--daemonize}
+    status.should.be 200
+    @rackup.should.be.eof?
+  end
+
+  specify "rackup --pid" do
+    run_rackup %{--daemonize --pid testing.pid}
+    status.should.be 200
+    @rackup.should.be.eof?
+    Dir["#{root}/**/testing.pid"].should.not.be.empty?
+  end
+
+  specify "rackup --version" do
+    run_rackup %{--version}, :port => false
+    output.should =~ /1.0/
+  end
+
+  specify "rackup --env development includes lint" do
+    run_rackup
+    GET("/broken_lint")
+    status.should.be 500
+  end
+
+  specify "rackup --env" do
+    run_rackup %{--env deployment}
+    GET("/broken_lint")
+    status.should.be 200
+  end
+end
+rescue LoadError
+  $stderr.puts "Skipping rackup --server tests (mongrel is required). `gem install thin` and try again."
+end
\ No newline at end of file
diff --git a/test/testrequest.rb b/test/testrequest.rb
index 7b7190c..0da2b12 100644
--- a/test/testrequest.rb
+++ b/test/testrequest.rb
@@ -13,6 +13,17 @@ class TestRequest
   module Helpers
     attr_reader :status, :response
 
+    ROOT = File.expand_path(File.dirname(__FILE__) + "/..")
+    ENV["RUBYOPT"] = "-I#{ROOT}/lib -rubygems"
+
+    def root
+      ROOT
+    end
+
+    def rackup
+      "#{ROOT}/bin/rackup"
+    end
+
     def GET(path, header={})
       Net::HTTP.start(@host, @port) { |http|
         user = header.delete(:user)
@@ -22,7 +33,11 @@ class TestRequest
         get.basic_auth user, passwd  if user && passwd
         http.request(get) { |response|
           @status = response.code.to_i
-          @response = YAML.load(response.body)
+          begin
+            @response = YAML.load(response.body)
+          rescue ArgumentError
+            @response = nil
+          end
         }
       }
     end
