Yes, What prevents me is the following code.

```
  task :prepare do
    ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'test'
    if Rails.configuration.generators.options[:rails][:orm] ==
:active_record
      if Rake::Task.task_defined?("test:prepare")
        Rake::Task["test:prepare"].invoke
      end
    end
  end
```

That is located at
https://github.com/rspec/rspec-rails/blob/53604f4f98d54c95fa88bb1e972229c29e9353f9/lib/rspec/rails/tasks/rspec.rake

Because it does
```
ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'test'
```
Which means that it is always setting the env to be 'test'

I would like to change this code to
```
ENV['RACK_ENV'] = ENV['RAILS_ENV'] ||= 'test'
```

On Tue, 8 Dec 2020 at 13:26, Phil Pirozhkov <[email protected]> wrote:

> Can you please clarify, is there something in rspec-rails that
> prevents you from having a separate env?
> There's this
>
> https://github.com/rspec/rspec-rails/blob/13a8a01cc07c93db97b5f1cd57229527441cd626/lib/generators/rspec/install/templates/spec/rails_helper.rb#L3
>
>    ENV['RAILS_ENV'] ||= 'test'
>
> With `||=` you can override `RAILS_ENV` when running your tests in a
> different environment with `RAILS_ENV=integration rspec`.
> Or you can create an additional `spec/integration_helper.rb` that would
> have
>
>    ENV['RAILS_ENV'] ||= 'integration'
>
> instead, and `require 'integration_helper'` from your specs that are
> intended to be run in that env.
>
> Just one word of precaution, I recommend separating those other specs
> somehow to reduce the risk of a situation when calling `rspec` would
> BOTH load specs that require `rails_helper` and `integration_helper`.
>
> Please feel free to share your experience with this setup.
>
> - Phil
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "rspec" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/rspec/naE04EDa3gQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rspec/CAAk5Ok-beeUvqgx0PkF2Jt2tg%2BWsC8KBNpgtY972_V161eqZaw%40mail.gmail.com
> .
>


-- 
Axlessoft
Developing solutions for engineers. Bringing 3D on the web.
https://www.axlessoft.com/

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/CAJtYerGiNZbg789F%2B_i0tv9UUfjdJ6YfsfsLLVN%2BR%3D149DhTCw%40mail.gmail.com.

Reply via email to