I am new to rails and I am writing some tests using Capybara and cucumber.
Scenario: Successful login
Given a user "admin@adm.com" with password "admin123"
And I am on the sign in page
Given /^I am on the sign in page$/ do |page_name|
visit('/users/sign_in')
save_and_open_page
end
I am having trouble figuring out a way to write a named path instead of the ‘/users/sign_in’ url.
How can I figure it out?
The way to do this is,
Go to the project root directory and run
This will give a list of all the requests handled by rails as follows:
So looking at the first column above, we see the “new_user_session”
This can be written as new_user_session_path and placed in visit() as:
And (as far as I know) it works just fine 🙂