ruby on rails - Accessing controller in Cucumber to test sign-in -
first off - know horrible practice, because cucumber meant test outputs. want 1 veryveryvery specific case.
i have app handles user authentication using cookie set app maintain. i'd write simple integration test authentication:
given have logged "some_user" on sso server when visit page should logged in "some_user"
my current step definition follows:
then /^i should logged in "([^"]*)"$/ |username| user = user.find_by_username(username) assert_equal @controller.current_user, user end
obviously, failing "undefined method 'current_user' nil:nilclass".
in case it's not obvious - applicationcontroller#current_user returns either user logged in or nil.
you can visit page logged on user's name displayed.
like:
when go account page
then should see "welcome user" within "div#login"
Comments
Post a Comment