Skip to content

RSpec not setting environment to test #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
samflores opened this issue Jun 6, 2010 · 4 comments
Closed

RSpec not setting environment to test #70

samflores opened this issue Jun 6, 2010 · 4 comments

Comments

@samflores
Copy link

I'm trying Rspec-2.0.0.beta.10 with Rails-3.0.0.beta3 and Ruby-1.9.2-preview3 and my environment is not getting set to 'test' as it should. I tryed using the spec command, rake spec and autotest but both Rails.env and ENV['RAILS_ENV'] are always 'development'.

At first I thought it was an Mongoid issue, but I created a new project using ActiveRecord and sqlite3 and the problem still exists.

@dchelimsky
Copy link
Contributor

This is only w/ 1.9.2?

@samflores
Copy link
Author

I've just tested with 1.8.7-p248 and the problem is still there

@samflores
Copy link
Author

I've just changed
ENV["RAILS_ENV"] ||= 'test'
from the generated spec_helper.rb to
ENV["RAILS_ENV"] = 'test'
and it worked well.
I believe something is setting the env before RSpec but I cannot figure out what. Already looked at my dotfiles and the entire application code and did not found where it's being set.

@dchelimsky
Copy link
Contributor

I can't duplicate this in a fresh app or any of the apps I'm running using 'rspec' or 'rake spec'. I don't want to force it to 'test' because that ties everybody's hands.

I'm going to close this, but if you can find a way for me to reproduce it, please comment on this ticket and I'll reopen it.

rodrigobdz added a commit to rodrigobdz/rspec-rails that referenced this issue Jan 22, 2018
This is a solution to tests running in development environment as stated in issues rspec#70 and rspec#586.
Before Rails 3.2.7 ENV['RAILS_ENV'] ||= 'test' ran tests without issues in test env as discussed in rails/rails#7175 (comment).
nodanaonlyzuul added a commit to NYPL/fedora_ingest_rails that referenced this issue Nov 16, 2018
Similar to https://github.com/NYPL/mms/commit/d52745c43c88fd1979e23662d52a39ee71e03a9a

The fact that RSpec uses ||= is because they don't want to 'force'
people to use the 'test' Rails.env (source: rspec/rspec-rails#70 (comment))
I am happy to force us to use Rails.env `test`
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants