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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:24:52+00:00 2026-05-23T14:24:52+00:00

When I run my rspec tests, many fail due to stale data in my

  • 0

When I run my rspec tests, many fail due to stale data in my mongodb database. AFAIK it is far better to test with a clean database.

With mysql, I could run rake db:test:prepare to clean up the database. How can I clean nd/or re-seed the database before each test?

  • 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-23T14:24:52+00:00Added an answer on May 23, 2026 at 2:24 pm

    If you are using MongoID you can use Database Cleaner with Truncation strategy. E.g.:

    RSpec.configure do |config|
      config.use_transactional_fixtures = false
    
      config.before :each do
        DatabaseCleaner.strategy = :truncation
        DatabaseCleaner.start
      end
    
      config.after do
        DatabaseCleaner.clean
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I like to run my Rspec tests with Spork running in a separate tab.
I am a little new to RSpec tests and i am trying to run
I'd like to init the data base once everytime i run tests, rather than
Every time I run RSpec tests, it goes off executing everything. Which is fine,
I would like to run RSpec to test my code both when I'm connected
When I run rspec tests. I can't see details result of my tests. I
right now I use rspec for my tests. to run rspec all I have
I am trying to use rspec on my rails application I run spec path/to/spec/spec.rb
So I'm writing some rspec tests and I'm embarrassed at my lack of Ruby
I'm writing some automated tests using Capybara/RSpec, I choose/configure the driver by using this

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.