# Render :action and routes problem with cucumber scenario

**URL:** <https://www.ruby-forum.com/t/render-action-and-routes-problem-with-cucumber-scenario/178793>\
**Category:** Rails\
**Created:** [November 11, 2009, 12:41pm UTC](https://www.ruby-forum.com/t/render-action-and-routes-problem-with-cucumber-scenario/178793 "2009-11-11T12:41:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [November 11, 2009, 12:41pm UTC](https://www.ruby-forum.com/t/render-action-and-routes-problem-with-cucumber-scenario/178793/1 "2009-11-11T12:41:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [November 11, 2009, 10:22pm UTC](https://www.ruby-forum.com/t/render-action-and-routes-problem-with-cucumber-scenario/178793/2 "2009-11-11T22:22:16Z")

</div>

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.
