Cyril Duchon-Doris Cyril Duchon-Doris - 6 months ago 6x
Ruby Question

Rspec - where is the extra configuration for test environment?

I am using the default

for different purposes and I have decided to make a specific
environment configuration for running the test suite.

However, I discovered that upon changing to
ENV["RAILS_ENV"] ||= rspec
in my
file, suddenly a LOT of things are going wrong, constants are not being loaded (FactoryGirl, DatabaseCleaner, etc. throw
uninitialized constant

My question is, where is the code that loads those guys in test environment ? Since I am planning to use this stage for other purposes than running automatic tests, I'm afraid this "out of nowhere" added configuration might not work well with what I am planning to do.


If you are getting uninitialized constant errors for FactoryGirl, DatabaseCleaner etc, you most likely included them to test group in your Gemfile.

You should move them to rspec group, eg:

# Gemfile

group :rspec do
  gem 'factory_girl_rails', '~> 4.0'
  gem 'faker'