This project is archived and is in readonly mode.
`rake test(:functionals|:units|....)` loads the environment twice
-
Daniel Abrahamsson
I'm facing the same issue with running my tests, due to the double loading of the environment.What is the reason that the environment is loaded twice?
-
Roger Leite
I tested with rails 3.0.4, created an empty application and scaffold of users.
With a "puts" in config/environment.rb, i did:rake test -t
(in /home/roger/dev/trivial/temp/raketest) Invoke test (first_time) Execute test Invoke test:units (first_time) Invoke test:prepare (first_time) Invoke db:test:prepare (first_time) Invoke db:abort_if_pending_migrations (first_time) Invoke environment (first_time) Execute environment ENV LOADED !
Execute db:abort_if_pending_migrations Execute db:test:prepare Invoke db:test:load (first_time) Invoke db:test:purge (first_time) Invoke environment Execute db:test:purge Execute db:test:load Invoke db:schema:load (first_time) Invoke environment Execute db:schema:load Execute test:prepare Execute test:units ENV LOADED !
Loaded suite /home/roger/.rvm/gems/ruby-1.8.7-p330@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
. Finished in 0.027144 seconds.1 tests, 1 assertions, 0 failures, 0 errors
Invoke test:functionals (first_time) Invoke test:prepare ** Execute test:functionals ENV LOADED !
Loaded suite /home/roger/.rvm/gems/ruby-1.8.7-p330@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
....... Finished in 0.171518 seconds.7 tests, 10 assertions, 0 failures, 0 errors
Invoke test:integration (first_time) Invoke test:prepare ** Execute test:integrationI tried to test with rails edge too (changing Gemfile to use
gem 'rails', :git => 'git://github.com/rails/rails.git'), and i got an error:
{mkd-extraction-a95f96cb27b5f9de47f004b440afe16e}
(in /home/roger/dev/trivial/temp/raketest) Invoke test (first_time) Execute test Invoke test:units (first_time) Invoke test:prepare (first_time) Invoke db:test:prepare (first_time) Invoke db:abort_if_pending_migrations (first_time) Invoke environment (first_time) Execute environment Invoke test:functionals (first_time) Invoke test:prepare ** Execute test:functionals /home/roger/.rvm/gems/ruby-1.8.7-p330@rails-edge/bundler/gems/rails-8276a240207a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb:23: uninitialized constant Rack::Session::Abstract::SessionHash (NameError)Invoke test:integration (first_time) Invoke test:prepare ** Execute test:integration Errors running test:units, test:functionals!
-
Roger Leite
Trying to clean the previous message
I tested with rails 3.0.4, created an empty application and scaffold of users.
With a "puts" in config/environment.rb, i did:rake test -tI tried to test with rails edge too (changing Gemfile to use gem 'rails', :git => 'git://github.com/rails/rails.git'), and i got an error.
Put the output at gist: https://gist.github.com/829168
-
Roger Leite
Looking at source, i realized two things:
1. https://github.com/rails/rails/blob/master/railties/lib/rails/appli... Rails, raises exception if application is already initialized.
2. Task test ( https://github.com/rails/rails/blob/master/railties/lib/rails/test_... ) invokes "test:units test:functionals test:integration". I think they are running in different process.Somebody can help me ?
-
Christopher Meiklejohn
Hi Roger,
I'm not running into any problems running the test suite on the rails master branch -- can you try doing this again?
Thanks,
Chris -
Christopher Meiklejohn
Roger,
Keep in mind if you are running edge rails, you need to be running edge rack as well, which is probably why you are getting the SessionHash error.
-
Roger Leite
I didn't know about edge rack ...
Sorry for the false positive.Thanks for the tip Christopher! It worked.
