jnicklas/capybara — Issue #659: Correctly setting headers when using Rack::Test
Author: nmk
Created: 2012-03-05 14:29:33+00:00
State: open

If a `Rack::Test`-based driver is registered with custom headers like this:

```ruby
Capybara.register_driver(:rack_test_swedish) do |app|
Capybara::RackTest::Driver.new(app, headers: { 'Accept-Language' => 'sv' })
end
```

the `Accept-Language` header cannot be read on the server side in a Rack based app with the usual `request.env['HTTP_ACCEPT_LANGUAGE']`.

In order for the latter to work, the driver has to be registered like this:

```ruby
Capybara.register_driver(:rack_test_swedish) do |app|
Capybara::RackTest::Driver.new(app, headers: { 'HTTP_ACCEPT_LANGUAGE' => 'sv' })
end
```

It would be nice if we could provide headers with their intended names.

I am not sure if this is a pure Capybara (driver) issue or somehow tied into how `Rack::Test` works.

Here is a simple Sinatra based test: https://gist.github.com/1978140 .