This project is archived and is in readonly mode.
rake test runs initializers in development environment
-
Carsten Gehling
Confirmed on rails 2.2.2
-
Andy Atkinson
Would you mind describing how this is a problem in your application? If I saw this personally, I wouldn't think it is a Rails bug necessarily, perhaps I'm missing something about initializers.
-
Carsten Gehling
It is a problem, if you try to test a Mailer. Since config/environments/development.rb is run instead of config/environments/test.rb, you do not get config.action_mailer.delivery_method = :test set
This again means, that when your test-suite sends a mail, ActionMailer::Base.deliveries is not updated, so your tests will fail.
-
Gaius Centus Novus
I ran into it when I had done a
config.middleware.usein myconfig/development.rbthat I expected not to be run in test mode. -
Mat Schaffer
I ran into this same problem trying to set up Workling in an initializer, but I couldn't select the appropriate dispatcher for testing.
As a work around I added this to my rspec.rake. I expect you could use a similar strategy for test:unit. I'll probably have to figure that out shortly too.
spec_prereq = [:set_rails_env, File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop] task :set_rails_env do ENV['RAILS_ENV'] = 'test' endThis doesn't suppress the evaluation of development.rb, sadly. But at least I can put some if statements in my initializer to do the right thing.
-
Kamal Fariz
- Tag changed from 2.3.2, development.rb, evironment, test, testunit to 2.3.2, 2.3.4, development.rb, evironment, test, testunit
Confirmed on rails 2.3.4
-
Rohit Arondekar
- State changed from new to stale
- Importance changed from to
Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.