4
votes

I am running rails 3.0.0, rspec-rails 2.0.0.beta.20, webrat 0.7.2.beta.1, cucumber-rails 0.3.2 I have this scenario:

Scenario:
  Given I am on the new account page
  And I fill in "Name" with "John Doe"
  When I press "Create"
  Then I should be on the access page

When I run it I get:

expected: "/access",
got: "/accounts"

Like its not following the redirect_to in the controller:

#accounts_controller.rb
def create
  @account = Account.new(params[:account])
  if @account.save
    flash[:notice] = "Saved!"
    redirect_to access_url  
  else
    flash[:alert] = "Error!"
    render :new
  end
end

Am I missing a step? I thought webrat followed all redirects. Thanks

Using launchy gem I get a page that says:

"You are being redirected" with a link to the access_path

?

3
Are you sure it's not following redirects? Maybe the form isn't valid and it renders the new action again? You can try the 'show me the page' step (you'll need the launchy gem for that) to see if it isn't showing any errors you missed? - Cimm
Thanks might try it. Can't see any reasons why it failing, even if I remove the render :new it still come up the same... - Cameron

3 Answers

2
votes

Not sure if this applies in Rails 3, but can you just try this method "follow_redirect!"