Render :action and routes problem with cucumber scenario

Hi,

I have a cucumber scenario to verify what happens when an user account
is not active yet. In that situation it will display an error and keep
the user in the same login screen. The scenario includes:


And I press “Login”
Then I should be on the login page
And I should see “Your account has not been activated yet.”


In routes.rb I have:

map.login ‘/login’, :controller => ‘user_sessions’, :action => ‘new’


In paths.rb I have:

when /the login page/
login_path


In user_sessions_controller.rb I have:

if !@user.active?
@show_div = true
@error_note = “Your account has not been activated yet!”
@user_session = UserSession.new
render :action => :new
else


In new.html.erb a hidden div meant to show the errors:

<%= @error_note %>

My problem is that cucumber test fails with this:

And I press “Login”
Then I should be on the login page
expected: “/login”,
got: “/user_session” (using ==)

Which makes sense because paths.rb say one thing and render :action say
something else.

But I like to use the render :action so I can easily activate the error
message for the user.

What would be the best approach to solve this problem?
The thing works but not the cucumber test.

Thanks.

Hi, this is how I fixed it. Not sure if it is the best way but cucumber
passes and the “real” application also behaves as expected.

Scenario:


And I press “Login”
Then I must be on the login page <— this won’t use the webrat default
step
And I should see “Your account has not been activated yet.”

Then I have define a step where I actually tell the expected route:

Then /^I must be on (.+)$/ do |page_name|
URI.parse(current_url).path.should == “/user_session”
end

Cheers.