Note that there are some explanatory texts on larger screens.

plurals
  1. POFactory Girl in Rails 4 causes load error on rake db tasks
    text
    copied!<p>I have a very simple Rails 4 application and would like to write some example tests using Factory Girl. The app works fine with some simple rspec tests (that all pass), but when I add "factory_girl_rails" to the gemfile, 'rake db:migrate' gives me the following error:</p> <pre><code>MacBook-Pro-2:project-folder me$ rake db:migrate /Users/me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load': cannot load such file -- /Users/me/Code/project-folder/db:migrate (LoadError) from /Users/me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load' from /Users/me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency' from /Users/me/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load' from /Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files' from /Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each' from /Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files' from /Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run' from /Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run' from /Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun' </code></pre> <p>Here is my spec_helper.rb (with comments removed for brevity):</p> <pre><code># This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' require 'capybara/rspec' require 'factory_girl_rails' Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) RSpec.configure do |config| config.use_transactional_fixtures = true config.infer_base_class_for_anonymous_controllers = false config.order = "random" config.formatter = :documentation config.include Capybara::DSL config.include FactoryGirl::Syntax::Methods end </code></pre> <p>Also, the gemfile itself:</p> <pre><code>source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.0' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets gem 'sass-rails', '~&gt; 4.0.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '&gt;= 1.3.0' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~&gt; 4.0.0' # See 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 gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~&gt; 1.2' group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false end # To use debugger gem 'debugger' gem "devise", :git =&gt; "git://github.com/plataformatec/devise.git", :branch =&gt; "rails4" group :development, :test do gem "rb-fsevent", "~&gt; 0.9.1" gem "guard", "1.6.2" gem "guard-rspec", "2.5.1" gem "rspec-rails", "2.13.1" gem "shoulda-matchers", "2.1.0" gem "capybara", "2.1.0" gem "launchy", "2.2.0" gem 'factory_girl_rails', '4.2.1' end </code></pre> <p>I have made no other alterations to any part of the application. What am I missing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload