Commit d3a40e56c4787dfea6e57a0c9cba44898155d173
Exists in
master
Merge pull request #1028 from stevecrozz/959_set_rails_env_for_test_rake_tasks
Refs #959 set rails env=test for test rake tasks
Showing
1 changed file
with
7 additions
and
0 deletions
Show diff stats
Rakefile
1 | 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, |
2 | 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. |
3 | 3 | |
4 | +# These rake tasks should always be run in the 'test' environment and the | |
5 | +# environment name must be set before loading the Rails application | |
6 | +test_env_tasks = %w(spec) | |
7 | +if Rake.application.top_level_tasks.any? { |t| test_env_tasks.include?(t) } | |
8 | + ENV['RAILS_ENV'] = 'test' | |
9 | +end | |
10 | + | |
4 | 11 | require File.expand_path('../config/application', __FILE__) |
5 | 12 | |
6 | 13 | Rails.application.load_tasks | ... | ... |