views:

194

answers:

2

redirect_to is failing for me in my cucumber tests. The step_definition method is

Then /^I should be redirected to "(.*)"$/ do |url|
  response.should redirect_to(url)
end

In Rails 2.3.3 I'm doing:

redirect_to some_url, :status => 301 and return false

I'm running that from the application_controller.rb and returning false. When I tail the test.log I see it redirect yet the cucumber test still fails with a

expected redirect_to ..., got no redirect

The cucumber code looks like:

Given I go to "/blogs?page=1"
Then I should be redirected to "/blogs"

Any idea what I'm missing?

A: 

Maybe change 'response.should redirect_to(url)' to 'response.should redirect_to(url, :status => 301)', other than that I can't see anything wrong.

Vertis
+1  A: 

Sometimes you just have to save_and_open_page. I find that any time cucumber is giving me trouble it's because of something like sessions and I open the resultant page to find a nasty flash error or something telling me exactly why I'm being an idiot this time. :)

Not implying that you're being an idiot, only I do that I think. At least that's what rspec seems to think of me most of the time.

Chuck Vose