I have a weird situation where I have a route that specifically
redirects (in the routes file itself, not a corresponding controller
action), but when using RSpec to test it, for some reason it's giving
me a 200 OK with an empty response body.
So, for example, take this route:
get "/search/users/:name(/:location)" => "search#users"
get "/search/users" => redirect(root_path)
The idea being that if you try to access /search/users, you'll just be
redirected to the index, because you didn't bother specifying criteria
for a search (such as a name or location parameter).
My corresponding spec looks like this:
context "a GET to /users (with no params)" do
it "should redirect to index" do
The response.should line fails because the response object isn't a
redirect, it's a 200 OK with a blank response body. However, if I try
it in my browser (under development mode) it seems to redirect exactly
as expected. This just presents a problem because I'm not sure how to
properly write a test for it.
Does anyone have any pointers on what I'm doing wrong here? Thanks
for any help you can provide