views:

628

answers:

3

I'd like to access the controller instance in my cucumber step definitions. The purpose of this is so I can manipulate http cookie and session values. I'm pretty sure there's a way to do this via World, but I'm not sure how.

In regards to Ryan's comment, I'm writing a feature for a page which requires a logged in user (via Authlogic). I know the cucumber way is to go to the login page and login a user before continuing. However, I'm using OpenID and have been having trouble orchestrating the process. Regardless, I'd like to avoid that step in writing my feature. The feature isn't that a user can go to the login page and login then do something; it's what the user can do once they're logged in.

Thanks,

Mike

+2  A: 

Generally it is discouraged to access controllers directly from within Cucumber features. The idea is that features test what your user sees. Your user's can't really access your controllers now, can they?

In lieu of this you should probably write specs that handle the controller-level checking.

Ryan Neufeld
A: 

You might be interested in seeing this question when it was asked before: http://stackoverflow.com/questions/382473/how-do-i-fake-openid-login-in-rspec-user-story-cucumber-when-using-openidauthen

Steve Klabnik
mhamrah
A: 

Just use @controller in your steps