I know the ideal thing to do would be to fill the login form and follow that flow. The thing is that I am not using devise for login in. I do login in my application the user after authenticating with Facebook and fb_graph gem.
So the devise sign_in view only has the link “connect with Facebook”, but I am able to see that route, and I assume that will try to sign_in a user if a post is made to that url.
I tried doing a post to the sign_in (which view is empty) directly with cucumber, and even though the response is ok, the user is not logged in.
Given /^I am a logged in user$/ do
@user = Factory(:user)
res = post("/users/sign_in", :email => @user.email, :password => "password")
p res
end
How can I test this?
Thanks,
UPDATE:
The scenario looks like this:
Scenario: Going to the index page
Given I am a logged in user
And there is a subject created
And there is 1 person for that subject
When I go to that subject persons index page
And show me the page
Then I should see "Back to Subjects list"
Instead of doing that, which I am not proud of I ended up doing the following:
Application controller
Routes
User Steps
Path
This Way in my scenarios I only have to type:
And the rest is just normal cucumber…