Error When Trying To Activate FactoryGirl Syntax

Hello all,

I’m still learning rails and trying to dive into TDD as early as possible, but I got a problem which I couldn’t solve. The deal is that I’m trying to activate the FactoryGirl Syntax and getting an “unitialized constant FactoryGirl (NameError)” when attempting to run my specs.

Would appreciate any help given!

Ps.: I’m reading Aaron Sumner’s Everyday Rails Specs book, but it uses an older version of the gems, I don’t know if the new RSpec has something to do with it, as now I got 2 files(rails_helper and spec_helper) differente from the old structure.

For more information here is the repository link if you need more specific information about gemfile/spec configurations and such:

https://github.com/diegodillenburg/codero/tree/dev

Thanks in advance!

Diego Dillenburg Bueno

I don't see Gemfile there. What is in that file?

Have a look at railstutorial.org (which is free to use online). It uses factorygirl and is up to date.

Colin

Here is my gemfile, it’s also located there on the main directory:

source '[https://rubygems.org](https://rubygems.org)'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'

gem 'rails', '4.1.0'

# Use sqlite3 as the database for Active Record

gem 'sqlite3'

# Use SCSS for stylesheets

gem 'sass-rails', '~> 4.0.3'

# Use Uglifier as compressor for JavaScript assets

gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views

gem 'coffee-rails', '~> 4.0.0'

# See [https://github.com/sstephenson/execjs#readme](https://github.com/sstephenson/execjs#readme) for more supported runtimes

# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library

gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: [https://github.com/rails/turbolinks](https://github.com/rails/turbolinks)

gem 'turbolinks'

# Build JSON APIs with ease. Read more: [https://github.com/rails/jbuilder](https://github.com/rails/jbuilder)

gem 'jbuilder', '~> 2.0'

# bundle exec rake doc:rails generates the API under doc/api.

gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: [https://github.com/rails/spring](https://github.com/rails/spring)

gem 'spring',        group: :development

# custom gems

gem 'devise'

group :development, :test do

gem 'rspec-rails', '~> 3.0.0'

gem 'factory_girl_rails', "~> 4.0"

gem 'guard-rspec', require: false

end

group :test do

gem 'shoulda-matchers', require: false

end

Have you done all the things in

Colin

Yeah, well I was re-reading their github documentation and realized that I was saving my configs in the wrong place, the new factory_girl requires that you save your definitions onto support/factory_girl.rb as it seems, and I was having them located at spec_helper.rb.

Anyway, thanks for the help.

Regards,

Diego Dillenburg Bueno