How to replace Rspec ENV ["RAILS_ENV"] || = 'test' deprecated in Rails 3.0?

I use rails (3.0.4)and rspec-rails (2.5.0). When I runrails rspec the generate: the install it producesspec_helper.rb`, which contains this line:

ENV["RAILS_ENV"] ||= 'test'

When I run rake spec, I get this warning in the terminal:

DEPRECATION WARNING: RAILS_ENV is deprecated. Please use ::Rails.env.

This is not so annoying, as it is done only once inside mine Spork.prefork, but I would like, if possible, to overcome this condemnation. I am new to Rails and have not mentioned this in rspec-rails problems or anywhere else.

+3
source share
2 answers

Dup my answer to the github problem :

, RAILS_ENV , ENV["RAILS_ENV"]. Rails v3.0.4 RAILS_ENV, , Rails ENV["RAILS_ENV"] .

.

+6

Rails 3.0.4. :

ENV["RAILS_ENV"] || = 'test' spec/spec_helper.rb

require rspec/rails.

::Rails.env ||= 'test' .

rspec-rails, .

+2

Source: https://habr.com/ru/post/1791339/


All Articles