Question

Im using Cucumber + Capybara.

This is how one of my step definitions looks like.

When /^(?:|I )go to (.+)$/ do |page_name|
  visit path_to(page_name)
end

And here is my routing file:

  match "home" => "home#index"

  resources :searches

  root :to => 'firstpage#index'

What is the name of a path?

Was it helpful?

Solution

http://guides.rubyonrails.org/routing.html under "Singular Resources"

OTHER TIPS

Running rake routes will give you all of the route names along the left side. The output of this is generally the first thing to look at when you're unsure of the routes that exist in your application.

When you are using "resources :searches" for example, user paths are: new_search_path for /searches/new searches_path for /searches

For the "home", it is "home_path" etc...

You can get better information at rubyonrails guides as mentioned by weng.

But, if you are having issues in getting your path properly identified in your step definition, then checkout http://recallmycode.com/2010/10/28/fix-for-path_to-function-of-cucumber-and-webrat/

Also, the step you have written already exists in web_steps.rb file under step_definitions directory. So, you don't need to write it again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top