I’m having some trouble testing a Rack application I have setup with Rack::Rewrite.

Even though by tweaking the Rack::Rewrite code a tiny bit, I can get the tests to run properly, I don’t think that Rack::Rewrite is the problem.

Here are the details:

  • I’m using Rack::Rewrite to change a URL
  • It works flawlessly when accessed via the browser
  • The other Rack middleware I have setup is operating correctly
  • If I modify rack-rewrite/rule.rb changing the environment variable it uses on line 79, it runs as expected

The change in rack-rewrite/rule.rb:

path = rack_env['REQUEST_URI']
path = rack_env['PATH_INFO']

The change to rule.rb does not affect the application’s behavior when accessed from the browser. I should also note that some, but not all, of the rules I set for Rack::Rewrite are indeed processed.

More details:

Guesses as to what’s up:

  • Rack::Test isn’t setting the REQUEST URI env variable for some reason?