Cucumber Flashcards
When testing that you should be redirected to a page, what can you include in your step definition to make your life a little easier. Given you have the following cucumber step: Then I should be redirected to the “Landing” page
Step definition file:
Then(“I should be redirected to the {string} page”) do |page_name|
expect(page.current_path).to eq page_path_from(page_name)
end
def page_path_from(page_name) case page_name.downcase when 'landing' then root_path when 'login' then '/users/sign_in' end
How do you make a table with at least one row representing an instance into a hash in a step definition?
table.hashes.each do |user|
User.create(user)
end
How to test for a page to a button and a link, as a step definition?
expect(page).to have_button button
expect(page).to have_link link
Write out the difference between testing fora redirect and visiting a page.
expect(page.current_path).to eq page_path_from(page_name)
visit root_path