I am attempting to write a scenario outline in cucumber where I am passing the url location that I am either viewing or submitting data to. I have 2 issues that I have not been able to figure out. I am hoping someone can provide some suggestions on how to attack them.
Issue 1: Creating db data for use with example table.
In normal cucumber cases, I would have something like
Given at least 1 record is created
Which in that task I would use a factory to create that record. My question here is how do I use that created record inside of my example table where I need an ID for my route?
i.e. if I have a given example table:
| login | location | action | | email@example.com | admin/groups | not see "Listing groups" | | firstname.lastname@example.org | admin/groups/:id | not see "Comments for" |
On that second line where there is ':id' in the location how would I be able to use a record id that I would have created with factory girl? Currently, In my step that is processing this, I am creating the factory there and then going a sub in the location string for ':id' and replacing it with the id of the created record. This might be the right way to do it but I wanted to get a second opinion.
Issue 2: (and probably more important). Using the same example data above how could I replace that location data with actualy routes. Instead of using
This would make it a lot easier for me to be able to pass IDs of records in particular case of create where I can't seem to tell the current implementation of location that I am submitting a POST as oppose to it always using GET.
I tried using URI but I didn't have much luck at all.
bad URI(is not URI?): admin_groups_path(:id) (URI::InvalidURIError) ./features/step_definitions/unauthorized_access_steps.rb:14:in `/^"(.*?)" is visited$/' features/unauthorized_access.feature:10:in `When "<location>" is visited'
I am wondering if anyone else has tried to do this. If so, how you were able to get this to work.
Thanks in advance for any suggestions.