Resetting a sequence

Skip to first unread message

Mohsen Qureshi

Jun 19, 2013, 12:54:00 PM6/19/13
Hi everyone,

I have tried to google up on this, and tried a few things my self i.e. trying to access value of a sequence and try resetting it to 0. However I'm not getting anywhere with it. I am using it with Cucumber, and my use case is that I write to the DB and call a web service, which reads the DB and returns a XML response. I have a sample XML which I compare it to.

However my problem begins when running the scenarios together. When running the scenarios one at a time, the sequences all start with 1, which is what the ID's are in the expected XML. When running the whole suite, the sequences increment and thus fail as the expected XML has ID's of 1.

Has anyone successfully been able to reset a sequence?


Keenan Brock

Jun 20, 2013, 12:35:31 PM6/20/13
Hello Mohsen,

I don't know how to do what you suggest.

But recently, when comparing objects and hashes, I've been just comparing the values I want to compare. So in rspec, I've been using include() rather than eq()

1. you may be able to use nokogiri and read the record and only compare the fields that interest you.
2. you can take the new data, and gsub(/<id>\d*<\/id>/,"") to get rid of the id field all together.
3. think about using external ids instead of internal ids. So instead of using your id, use a tag field as the externally facing unique id.

Best of luck,
Individuals over processes. Interactions over tools. Agile Rails training from thoughtbot, the makers of Clearance, Shoulda, & Factory Girl:
You received this message because you are subscribed to the "factory_girl" mailing list.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at
You received this message because you are subscribed to the Google Groups "factory_girl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Reply all
Reply to author
0 new messages