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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:50:58+00:00 2026-06-14T11:50:58+00:00

namespace :fixtures do namespace :load do task :prepare => :environment do ENV[‘FIXTURES_PATH’] = spec/fixtures

  • 0
  namespace :fixtures do
    namespace :load do 
      task :prepare => :environment do
        ENV['FIXTURES_PATH'] = "spec/fixtures"
        ENV['RAILS_ENV'] ||= "test"
        puts ENV.inspect
        Rake::Task["db:fixtures:load"].invoke
      end
    end
  end

I have added this to a special.rake file in ./lib/tasks in order to cause the rake db:fixtures:load command to apply to fixtures in the spec/fixtures directory, and to apply to the test environment.

It’s not working. Where have I gone wrong?

  • 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-14T11:51:00+00:00Added an answer on June 14, 2026 at 11:51 am

    You need to reconnect to the database. Something like

    ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations["test"])
    

    Changing ENV[‘RAILS_ENV’] after environment is already loaded doesn’t do anything.

    Perhaps it would also work if you load the environment task after you change ENV, but not sure about that:

      task :prepare do
        ENV['RAILS_ENV'] ||= "test"
        Rake::Task["environment"].invoke
        Rake::Task["db:fixtures:load"].invoke
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given something like: namespace :my_tasks do task :foo do do_something end task :bar do
API: namespace ClassLibrary1 { public class Class1 { public static string Test(string input) {
namespace MoqSample.Test { [TestFixture] public class GivenCustomerServiceTest { private ICustomerService customerService; private CustomerModel customer;
namespace :baseline do INDEX_DIR = index(:baseline) # context task(:foo) ... end How do I
I have the following task: namespace :db do desc Drop, create, migrate, seed the
I've created a test suite in NUnit that references several distinct unit test fixtures
namespace Test { #region Not my code public interface IAdditional { } public interface
I have a test for testing data model: <?php namespace Tests\Model\SQL; /** * @group
namespace ValueType { enum Enum { Boolean = 0, Float = 1, Double, SInt
namespace MyOldService { public MyNewService.AddressList ToPrivateAddressList() { MyNewService.AddressList privAddrList = new MyNewService.AddressList(); privAddrList.creator =

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.