rake cucumber and rake spec always use “develop” environment

后端 未结 3 2033
心在旅途
心在旅途 2021-02-14 04:01

My rake tasks for running Cucumber and RSpec tests are always using my development environment.

Here are the relevant config files:

RAILS_ROOT

3条回答
  •  粉色の甜心
    2021-02-14 04:16

    Not only config files are relevant to setting up rails environment.

    Check your lib/tasks/cucumber.rake file and if it doesn't contain it already add one of the following lines to it depending on your rails version (I added it after 'begin' line):

    ENV["RAILS_ENV"] ||= 'cucumber' #for rails2
    
    Rails.env ||= ActiveSupport::StringInquirer.new('cucumber') #for rails3
    

    Notice that if you set environment to development in application.rb directly for example, then your tests will run in development.

    Also there's another way to set environment to cucumber. If you're running rails with Passenger and Apache for example, then it is possible to run cucumber test in cucumber environment by adding "RailsEnv cucumber" line to your virtualhost configuration.

提交回复
热议问题