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

  • Home
  • SEARCH
  • 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 8478671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:48:34+00:00 2026-06-10T18:48:34+00:00

When I run a task that should be running in the test environment, it

  • 0

When I run a task that should be running in the test environment, it is running in development. This includes rake test:(units/functionals/integration) and rake db:test:prepare. A side effect is that it is overwriting my database every time I run tests. I renamed the development database, and now it keeps complaining that it can’t find my old database (the one in database.yml). The environment is being set to development in require 'rails' at the top of my application.rb. Am I missing some sort of simple configuration?

Edit: If I run my tests appended with RAILS_ENV=test, they are run in the test environment. However, I can’t actually run them because I have pending migrations (all of them). Running rake db:test:prepare RAILS_ENV=test gives me the same pending-migrations error.

Update: The database is migrated, and my tests are going. I still feel like running my tests every time with RAILS_ENV=test isn’t the correct way to be doing it

Update: I found that if I change def env in railties to default to ‘test’, the environment becomes test. That is

def env
  @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
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-06-10T18:48:35+00:00Added an answer on June 10, 2026 at 6:48 pm

    The solution was to use ENV["RACK_ENV"] instead of the other options that I had tried. I’m still not sure why the other ones didn’t work, but I’m going to call this question solved.

    So simple…

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

Sidebar

Related Questions

I have a task that takes a rather long time and should run in
I am trying to implement a rake task that will run once a month
I have a process intensive task that I would like to run in the
I have a task in Python and i run this task for first time
I have managed to get a cron job to run a rake task by
How can I run a certain cleanup task after my Test target runs, regardless
I have a long-running process that must run every five minutes, but more than
I have an Android app, in which Activities fire long running operations that run
I have a long-running Task that I've implemented using the Task Parallel Library. When
I have a Rails 3 gem which has some rake tasks that should only

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.