views:

55

answers:

1

hello coders and codetts

I am working with rails 3 and cucumber, all is going well except for this little problem

Given I am on the "edit automobile" page
  No route matches {:controller=>"automobiles", :action=>"edit"} (ActionController::RoutingError)

Now the path is set in paths.rb as edit_automobile_path

and in the routes.rb I have automobiles as a resource, I scaffolded it

so please tell me what I am missing, clearly the route is defined and matches, because I ran rake routes and saw the route.

please point me in the right direction

+1  A: 

In your features/support/paths.rb file for a path like this that specifies a unique resource you need to pass your edit_automobile_path an id,

in your rake routes it will look like automobiles/:id/edit

so you need to have edit_automobile_path(:id)

In order to do this in cucumber assume you have something like

Given I have an automobile
And I am on the 'edit automobile' page

In your given step def declare a variable @automobile = Automobile.create()

And then in your paths.rb file

when /edit automobile page/
  edit_automobile_path @automobile
...
Jed Schneider
Thank you so much for this, I am still learning, THANK YOU, THANK YOU, THANK YOU, ok back to work
iAm
no prob. dont forget, if this model becomes a nested resource, you will have to specify :automobile_id or whatever because it wont know what id to look for, so you will have to change the call in paths.rb to handle that.
Jed Schneider