How can I reset a factory_girl sequence?

Just call FactoryGirl.reload in your before/after callback. This is defined in the FactoryGirl codebase as: module FactoryGirl def self.reload self.factories.clear self.sequences.clear self.traits.clear self.find_definitions end end Calling FactoryGirl.sequences.clear is not sufficient for some reason. Doing a full reload might have some overhead, but when I tried with/without the callback, my tests took around 30 seconds to … Read more

Setting roles through rolify in FactoryBot definition

I would rather use FactoryBot’s after(:create) callback to create roles (also see this issue for Rolify). Furthermore the method has_role? is used to check if a user has a specific role, to set a specific role you should use the add_role method. FactoryBot.define do factory :user do name ‘Test User’ email ‘[email protected]’ password ‘please’ password_confirmation … Read more

techhipbettruvabetnorabahisbahis forumueduseduseduseduedusedueduedusedusedu