开发者

Record id with cucumber and pickle [Rails]

I am using Cucumber, Webrat, and Pickle in conjunction. When I write a scenario, I can do something like this:

Given a product exists with title: "Bread"
When I go to the edit page for that product
And I fill in "Title" with "Milk"
And I press "Save changes"
Then I should see "Successfully edited product."
And I should be on that car's page

Notice the for that product开发者_高级运维. This is something pickle provides which is very convenient for referencing the record for a product I'm checking the existence of. That last line, though, is not working.

Basically I am trying to make sure I am the show page for that record, but since I do not have an ID for it, I don't know how to reference it.

Any help? Thanks!


To have a reference to the created product or anything else you can use naming that's provided by pickle:

Given product: "bread" exists with title: "Bread"
...
Then I should be on the showing page for the product "bread"

To handle this url you will need to add couple lines into /features/support/paths.rb:

  when %r{^the showing page for the (.+)$}
    polymorphic_path(model($1))

Also it could be useful to handle edit path for the model like this:

Then I should be on the edit page for the product "bread"

paths.rb:

  when %r{^the edit page for the (.+)$}
    polymorphic_path(model($1), :action => 'edit')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜