Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7076767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:20:19+00:00 2026-05-28T06:20:19+00:00

I am trying to configure Spork to work with RSpec and Mongoid. The models

  • 0

I am trying to configure Spork to work with RSpec and Mongoid. The models are not reloading each time. I found a description suggesting the following spec_helper tweaks to get mongoid to reload, but now factory girl is unhappy. It is returning:

uninitialized constant Rails::VERSION (NameError)
/home/dev1173/.rvm/gems/ruby-1.9.2-p290@version-two/gems/factory_girl-2.3.2/lib/factory_girl.rb:23:in '<top (required)>'

Here is the contents of spec/spec_helper.rb

require 'rubygems'
require 'spork'

Spork.prefork do
  ENV["RAILS_ENV"] ||= 'test'
  require "rails/mongoid"
  Spork.trap_class_method(Rails::Mongoid, :load_models)

  require 'factory_girl_rails'
  Spork.trap_class_method(Factory, :find_definitions)

  require 'rspec/rails'
  require 'capybara/rspec'
  require 'capybara/rails'
  require "email_spec"
  require File.expand_path(File.dirname(__FILE__) + '/../config/environment')

  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

  RSpec.configure do |config|

    config.infer_base_class_for_anonymous_controllers = false  

    # Allows email magic
    config.include(EmailSpec::Helpers)
    config.include(EmailSpec::Matchers)

    require 'database_cleaner'
    config.before(:suite) do
      DatabaseCleaner.strategy = :truncation
      DatabaseCleaner.orm = "mongoid"
    end

    config.before(:each) do
      DatabaseCleaner.clean
    end

  end
end

Spork.each_run do
end

I’ve been banging my head on this for a while now. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:20:19+00:00Added an answer on May 28, 2026 at 6:20 am

    You should set cache_classes = false in your config/environments/test.rb and remove the following lines

    require 'factory_girl_rails'
    Spork.trap_class_method(Factory, :find_definitions)
    

    Or if you want to keep cache_classes to true follow my guide :

    Using spork and rails 3.1 with cache_classes true

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to configure an Apache webserver to work the following way: if /specialdir/
I am trying to configure maven I am getting the following error https\://maven.java.net/content/groups/public/.error=Could not
I am trying to configure logback-classic to handle the following situation: All messages originating
I'm trying to configure distributed search in Solr 1.4. It can work perfectly by
I'm using RSpec for my Rails 3 tests and trying to use Spork. I
Trying to configure Zend_Cache_Backend_Memcached via a config.ini or config.xml file. I'm not sure how
I am trying to configure Apache on my Linux system, but it does not
We are trying to configure Spring JavaMailSender to work with Amazon's SES service using
Trying to configure SQL Ce database, and get the following exception on BuildSessionFactory() .
I'm trying to configure Windows Powershell to work with Visual Studio. Nothing fancy, just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.