heavysixer/grape-on-rack — pull request #1 by dblock (2013-01-06 17:07:09+00:00)
Title: Mount warden in tests, too.

Adding warden to config.ru does configure Warden for when using `rackup`. But tests don't run `config.ru`. A simple solution is to include warden in the application, which I have done by creating a Rack app with `Rack::Builder`:

``` ruby
module Rackup
class << self
def app
@app ||= Rack::Builder.new do
use Rack::Session::Cookie
Warden::Manager.serialize_into_session { |user| user.id }
Warden::Manager.serialize_from_session { |id| User.get(id) }
use Warden::Manager do |manager|
manager.default_strategies :password, :basic
manager.failure_app = Acme::BadAuthentication
end
run Acme::App.new
end
end
end
end
```

The `config.ru` needs to use this app, and so do tests.