I'm learning to test with cucumber + capybara.
In one video tutorial I found that something like this should work:
...
When I go to the homepage
Then /do stuff/
I'm trying to do that but cucumber treats the word "homepage" as a part of regex.
So it gives me the suggestion to create a statement like so
When /^I go to homepage$/ do
#tasks
end
Tried "index page", "items page" (name of existing controller), "root path" - same thing. Cucumber doesn't actually go there - just asks to create a handler.
Where do I go from here?
Using a gem such as Capybara you could do something like so
In you test:
When I go to the homepage
In your step:
When /^I go to the homepage$/ do
visit root_path
end
Or to generalize:
When /^I go to the "(.*)"/ do |place|
visit "/#{place}"
end
where your step would pass in the location (url) where you would want to go.
For more info on visit
method checkout here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With