[rspec-users] Why does rake spec attempt to drop development db?

Byo Fuel byofuel at gmail.com
Sun Oct 2 03:57:26 EDT 2011


I have a new Rails 3.1 app on Ruby 1.9.2 with Postgres.  My specs pass if 
run separately, but when I rake spec it fails because it can't purge the 
development database. in task 'rake:test:purge' .  I confirmed my 
database.yml is pointing to the correct db:

development: &postgres_defaults
  adapter: postgresql
  encoding: unicode
  database: via_development
  pool: 5
  username: devuser
  password: xxx
#  host: /var/run/postgresql  # or: 127.0.0.1
  host: 127.0.0.1

test:
  <<: *postgres_defaults
  database: via_test

Here's the stack dump (I get the same results with RAILS_ENV=test rake spec 
--tracce)

kurtmacb:via kurtsnyder$ rake spec --trace
** Invoke spec (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** 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
rake aborted!
PGError: ERROR:  database "via_development" is being accessed by other users
DETAIL:  There are 2 other session(s) using the database.
: DROP DATABASE IF EXISTS "via_development"
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:541:in 
`async_exec'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:541:in 
`block in execute'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:244:in 
`block in log'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0/lib/active_support/notifications/instrumenter.rb:21:in 
`instrument'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:239:in 
`log'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:540:in 
`execute'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:661:in 
`drop_database'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:546:in 
`drop_database'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:454:in 
`block (3 levels) in <top (required)>'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:205:in 
`call'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:205:in 
`block in execute'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:200:in 
`each'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:200:in 
`execute'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:158:in 
`block in invoke_with_call_chain'
/Users/kurtsnyder/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in 
`mon_synchronize'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:151:in 
`invoke_with_call_chain'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:176:in 
`block in invoke_prerequisites'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:174:in 
`each'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:174:in 
`invoke_prerequisites'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:157:in 
`block in invoke_with_call_chain'
/Users/kurtsnyder/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in 
`mon_synchronize'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:151:in 
`invoke_with_call_chain'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:144:in 
`invoke'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:481:in 
`block (3 levels) in <top (required)>'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:205:in 
`call'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:205:in 
`block in execute'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:200:in 
`each'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:200:in 
`execute'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:158:in 
`block in invoke_with_call_chain'
/Users/kurtsnyder/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in 
`mon_synchronize'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:151:in 
`invoke_with_call_chain'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:176:in 
`block in invoke_prerequisites'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:174:in 
`each'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:174:in 
`invoke_prerequisites'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:157:in 
`block in invoke_with_call_chain'
/Users/kurtsnyder/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in 
`mon_synchronize'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:151:in 
`invoke_with_call_chain'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:144:in 
`invoke'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:112:in 
`invoke_task'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:in 
`block (2 levels) in top_level'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:in 
`each'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:in 
`block in top_level'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in 
`standard_exception_handling'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:84:in 
`top_level'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:62:in 
`block in run'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in 
`standard_exception_handling'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:59:in 
`run'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/bin/rake:32:in 
`<top (required)>'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load'
/Users/kurtsnyder/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>'
Tasks: TOP => db:test:load => db:test:purge

Thanks for looking!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20111002/1e61f4f3/attachment-0001.html>


More information about the rspec-users mailing list