Skip to content

Instantly share code, notes, and snippets.

@alvinsng
Created May 2, 2018 23:12
Show Gist options
  • Select an option

  • Save alvinsng/675a9e3d3b0bf95465cc4d53af8e5bba to your computer and use it in GitHub Desktop.

Select an option

Save alvinsng/675a9e3d3b0bf95465cc4d53af8e5bba to your computer and use it in GitHub Desktop.
# In spec/factories/account.rb
FactoryBot.define do
sequence(:email) { |n| "test_email_#{n}@example.com" }
end
# In Spring parent
def seed_db
100.times { create(:account) }
end
seed_db # creates 100 accounts with sequences 1 to 100
MySpecHelper.factory_sequences = FactoryGirl.sequences
# In Spring fork's spec run
FactoryGirl.configuration.instance_variable_set(
:@sequences,
MySpecHelper.factory_sequences
)
let(:account) { create(:account) } # this now starts at 101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment