Created
May 2, 2018 23:12
-
-
Save alvinsng/814a20f3be73a5c97060a082fb8c6948 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # in config/environment.rb | |
| if ENV['SPRING_ENV'] == 'test' && ENV['RAILS_ENV'] == 'test' | |
| require File.expand_path('../../spec/spec_helper', __FILE__) | |
| end | |
| # in spec_helper.rb | |
| # runs in Spring parent | |
| unless MySpecHelper.factory_sequences | |
| DatabaseCleaner.clean_with(:truncation) | |
| RESEED_DB.call | |
| MySpecHelper.factory_sequences = FactoryGirl.sequences | |
| end | |
| config.around(:each) do |example| | |
| # runs in Spring fork | |
| FactoryGirl.configuration.instance_variable_set( | |
| :@sequences, | |
| MySpecHelper.factory_sequences | |
| ) | |
| DatabaseCleaner.cleaning do | |
| example.run | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment