Help with pickle and namespace routes

27 views
Skip to first unread message

mix

unread,
Dec 5, 2010, 3:39:43 PM12/5/10
to pickle
Hi, I'm starting with cucumber+pickle and I've some problems with a
namespaced route:

devise_for :users
namespace 'admin' do
resources :posts
end

In my feature file I've this:

Background:
Given I am a new, authenticated user

Scenario: Create a new post
When I go to the new admin post page
[...]

Scenario: Show all posts
When I go to the admin posts page
[...]

Scenario: Edit a post
Given a post exists with user: the user, title: "Post title"
When I go to the admin post's edit page
[...]

When I run it, the create and index work, but the edit show this:

When I go to the admin post's edit page #
features/step_definitions/web_steps.rb:19
Can't find mapping from "the admin post's edit page" to a path.
Now, go and add a mapping in [...]/features/support/paths.rb
(RuntimeError)
./features/support/paths.rb:50:in
`path_to'
./features/step_definitions/web_steps.rb:20:in `/^(?:|I )go to (.
+)
$/'
features/admin/manage_posts.feature:38:in `When I go to the
admin post's edit page'



Googling around I've found this other post about namespaces:
http://groups.google.com/group/pickle-cucumber/browse_thread/thread/424ce641fcc3343f/fcee86559863f750?lnk=gst&q=namespace#fcee86559863f750

So I've added this to my paths.rb:

when /the (.+?) #{capture_model}(?:'s)? page/
polymorphic_path [$1.to_sym, model!($2)]

when /the (.+?) #{capture_model}(?:'s)? (.+?) page/
polymorphic_path [$3.to_sym, $1.to_sym, model!($2)]

when /the (.+?) (.+?) listing page/
polymorphic_path [$1.to_sym, $2.to_sym]



Run again and this time the index and update work, but not the create:

When I go to the new admin post
page # features/step_definitions/
web_steps.rb:19
The model: 'post' is not known in this scenario. Use
#create_model to create, or #find_model to find, and store a reference
in this scenario.
(Pickle::Session::ModelNotKnownError)
./features/support/paths.rb:29:in
`path_to'
./features/step_definitions/web_steps.rb:20:in `/^(?:|I )go to (.
+)
$/'
features/admin/manage_posts.feature:14:in `When I go to the new
admin post page'

I've tried with "When I go to the admin new post page", but I get the
same error

I've no "admin" model/controller/view, it's just to let the user
understand that it's under the admin area.. i tried with a "user"
namespace too, but I got errors there too (it took "_the user_ post
edit page" passing the user id as the params id instead of the one of
the post, which is wrong..)

Is there anyone who use pickle with routes&namespaces without
problems? How do you manage them?

Thanks
Reply all
Reply to author
Forward
0 new messages