visits() and respose.should be_redirect
Reported by Max Hawkins | September 7th, 2008 @ 11:29 AM
I'm using cucumber and webrat to test if a user is redirected to an login page when they visit a page they don't have permission to access.
Scenario: anonymous user edits group Given I log in And I create a group And I log out When i visit the first group Then I should redirect
Then /I should redirect/ do response.should be_redirect end
If I use the webrat visits() method, it throws an error:
When /I edit the first group/ do group = Group.first visits edit_group_path(group) end
Error: expected redirect? to return true, got false (Spec::Expectations::ExpectationNotMetError)
If I use a get() then it works fine:
When /I edit the first group/ do group = Group.first get(edit_group_path(group)) end
Comments and changes to this ticket
-
Bryan Helmkamp November 17th, 2008 @ 03:30 PM
- → State changed from new to invalid
Hey Max,
Webrat's behavior is to follow any redirects, so the resulting (last) request will be a success or failure, but never a redirect.
There's been some discussion on the mailing list ( http://groups.google.com/group/w... ) to allow this to be configurable. Please feel free to jump into that discussion or open a ticket for allowing this behavior to be configured.
Cheers,
-Bryan
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Ruby Acceptance Testing for Web applications
