R – Testing associations with cucumber

cucumberruby-on-rails

I'm new to rails and cucumber and I'm trying to test the following scenario

Background:
  Given I have a Group named Group 1
  And I go to the list of groups
  And I have the following users records
    | name    | description | group_id |
    | user 1   |            | 1        |
    | user 2   |            | 1        |
  When I follow Details for Group 1

Scenario: List users from group
  Then I should see "user 1"
  And I should see "user 2"

So, in the index action of my users controller I list all the users from the group_id, but I don't know how to test this using cucumber, because every time I run the test my group named Group 1 has a different id.

Does anyone know how to solve this?

Thanx

Best Answer

Avoid using the ID, instead list the name of the group as that will never change.

Related Topic