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 8256835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:59:47+00:00 2026-06-08T01:59:47+00:00

I had problems for ages in RSpec with my models not being reloaded between

  • 0

I had problems for ages in RSpec with my models not being reloaded between Spork runs.

I eventually fixed this by changing the following line in config/environments/test.rb:

config.cache_classes = true

became

config.cache_classes = false

HOWEVER… while this solved the issues for RSpec, Cucumber requires that cache_classes is set to true.
https://rspec.lighthouseapp.com/projects/16211/tickets/165

Is there a canonical solution to this that works for both RSpec and Cucumber and which reloads RSpec models successfully?

Footnote

* Other changes that I implemented to make RSpec reload models included adding the following lines to spec_helper.rb:

ActiveSupport::Dependencies.clear
FactoryGirl.reload

None of these lines solved the problem without also setting cache_classes=true line.

  • 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-06-08T01:59:49+00:00Added an answer on June 8, 2026 at 1:59 am

    I had this problem, and for me it was due to Rails’ threadsafe mode. Ensuring config.threadsafe! is not called in my test environment fixed it for me. This is because threadsafe mode prevents code from reloading on each request and disables automatic dependency loading, which I guess spork was relying on in each_run.

    I was calling config.threadsafe! in application.rb, so I removed that call from there, and put it in development.rb and production.rb instead. Now I can leave config.cache_classes set to true, and rspec and cucumber work happily under spork. Note that I was using Mongoid in my persistence layer and Machinist instead of FactoryGirl so YMMV.

    See also http://rickyrobinson.id.au/2012/07/20/when-spork-puts-a-fork-in-your-cucumber-and-a-spanner-in-your-specs

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

Sidebar

Related Questions

This is not the first time I've had problems with clock times in a
I've had problems with Internet Explorer not applying the last property in a list
Uhm, so I had problems with the title, but this was my best shot!
I've occasionally had problems with strings being subtly different, in some cases utf8::all changed
Has anyone else had problems with ckeditor and characters like this? I've just downloaded
The following code is not entering the i for loop. I have had problems
I had problems finding the answer to this so I am posting it for
I've had problems with this before but now it's somehow working. Now I've following
I've had this problem for ages, and it's SO ANNOYING. Suppose I want to
Been using this site for ages and have never had to go as far

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.