Skip to content

Instantly share code, notes, and snippets.

@johnwook

johnwook/README.md

Last active Jun 21, 2018
Embed
What would you like to do?
Spree test environment setting with rspec, factory_girl_rails and spring

Environment

  • rspec-rails (3.3.3)
  • factory_girl_rails (4.5.0)
  • spring (1.4.0)
  • spring-commands-rspec (1.0.4)

Problem

  • spring rspec generates errors with spree-generated-factories when it is used the way like require 'spree/testing_support/factories')

Solution

...
require 'spec_helper'
require 'rspec/rails'
require 'ffaker' # important. spree-generated-factories require this.
...
load 'spree/testing_support/factories.rb'
@sunkibaek

This comment has been minimized.

Copy link

@sunkibaek sunkibaek commented Jan 22, 2016

If you find yourself with factories not defined error when using this technique with Spring, try to require factory_girl inside rails_helper.rb file.

# in Gemfile
gem 'factory_girl_rails', require: false

# in rails_helper.rb
require 'factory_girl_rails'

Thanks!

@yeonhoyoon

This comment has been minimized.

Copy link

@yeonhoyoon yeonhoyoon commented Aug 31, 2016

@sunkibaek 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.