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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:26:19+00:00 2026-05-25T15:26:19+00:00

I am using Ruby on Rails 3.0.9 and RSpec 2. I would like to

  • 0

I am using Ruby on Rails 3.0.9 and RSpec 2. I would like to auto-load seed data in the test database before I tesst my application. That is, at the testing start up time (when I run tests) I would like to “auto-populate”\”auto-boot” the test database.

How can I populate the database with seed data?


P.S.: As I read around, (maybe) I should populate the test database by adding some code to the /spec/spec_helper.rb file… but what code and how?

In my task/custom.rake file I have:

namespace :test do
  desc "Boot database"
  task :boot => [:load, :seed] do
  end

  desc "Reboot database"
  task :reboot => [:purge, :boot] do
  end
end
  • 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-25T15:26:20+00:00Added an answer on May 25, 2026 at 3:26 pm

    If you’d like to just invoke the seed rake task, I’d do something like this:

    ENV['RAILS_ENV'] = 'test'
    Rake::Task["db:seed"].invoke
    

    But, I’d recommend using Fixtures (http://guides.rubyonrails.org/testing.html#the-low-down-on-fixtures).

    Or even better a fixture replacement like Factory Girl (https://github.com/thoughtbot/factory_girl), whereby you can load dummy data with all the associated data. This is a much less brittle approach.

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

Sidebar

Related Questions

I am using Ruby on Rails 3.0.9, RSpec-rails 2 and FactoryGirl. I would like
I am using Ruby on Rails 3.0.9 and RSpec 2. I would like to
I am using cucumber and RSpec for my new ruby on rails application and
I am using Ruby on Rails 3.1.0 and the rspec-rails 2 gem. I would
I am using Ruby on Rails 3.1.0 and the rspec-rails 2 gem. I would
Using ruby(1.8.7) , rails(2.3.8) , rspec(1.3.1) and rspec-rails(1.3.3) how do I test a method
I'm using Ruby on Rails to make an application where businesses can create accounts
I am using Ruby on Rails with Cucumber and Capybara. How would I go
I have created a blog application using Ruby on Rails which includes the ability
How can I start using Rspec with an existing Ruby on Rails 2.3.5 project

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.