V
vivec manavortex
Hi list,
this is the first time I am posting here, so please be gentle
I have spent all day yesterday googeling and reading stuff, and the
only post I found having the same problem as I did was replied to
by the owner with "fixed it, was something in my database.yml", what
didn't help me the slightest bit, so please help me, ruby-wan, you are
my last hope.
I have a Rails-project (OS X Snow Leopard, Rails 3.0.3, all gems are up
to date, although we got the test reproduced on another unix) that I am
supposed to test. It's pretty simple, a basic implementation of an
access control system using the devise gem.
My problem here is that I can't run any tests. The test I try to run
is the auto-generated test for my autogenerated dummy-controller that
doesn't do anything, and that doesn't work for, stacktrace:
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in
`establish_connection': test database is not configured
(ActiveRecord::AdapterNotSpecified)
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in
`establish_connection'
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railtie.rb:59
from
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in
`instance_eval'
from
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in
`execute_hook'
from
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:26:in
`on_load'
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railtie.rb:57
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in
`instance_exec'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in
`run'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in
`run_initializers'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in
`each'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in
`run_initializers'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in
`initialize!'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /Users/vivec/Documents/RubyWorkspace/psmt/config/environment.rb:5
from
/Users/vivec/Documents/RubyWorkspace/psmt/test/unit/../test_helper.rb:2:in
`require'
from
/Users/vivec/Documents/RubyWorkspace/psmt/test/unit/../test_helper.rb:2
from
/Users/vivec/Documents/RubyWorkspace/psmt/test/unit/dummy_test.rb:1:in
`require'
from /Users/vivec/Documents/RubyWorkspace/psmt/test/unit/dummy_test.rb:1
Okay, so my test database isn't configured, so let's configure it? Not
that simple, for I simply can't.
Here's the database.yml:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: psmt_dev
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: psmt_test
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
When I try to do anything rakely in development mode, everything is
fine. MySql is up and running, the databases both exist. I can do
a rake db:migrate to the database psmt_dev and, if I change the db
in development mode to psmt_test, I can migrate to that too. (I
did that and hoped it would solve the problem, it did not.)
As soon as I try to do anything rakely in test mode, it crashes -
there seems to be a problem dumping the database:
$ rake db:testrepare --trace
(in /Users/vivec/Documents/RubyWorkspace/psmt)
** Invoke db:testrepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:testrepare
** Invoke db:test:load (first_time)
** Invoke db:testurge (first_time)
** Invoke environment
** Execute db:testurge
rake aborted!
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:429
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
`invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
`synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
`invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in
`invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in
`invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in
`invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
`synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
`invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:460
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
`invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
`synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
`invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
I chased the bug deep down to databases.rake:429, and there it says:
task urge => :environment do
abcs = ActiveRecord::Base.configurations
case abcs["test"]["adapter"]
when /mysql/
and the problem seems to be with the case-statement, there something
is a nil value (and most likely it is the "adapter" value in "test"?).
The adapter value is set in my database.yml, and everything is great
as long as I stay to the development environment - but I need to
get those tests working.
In my theory, the problem is that, to execute a test, Rails wants to
have the test environment running and therefore the test-database dumped
and re-filled from the fixtures. The explosions happen during the dump-
procedure, so I guess, it's not my fault.
Does anyone have any idea how I get this fixed? I'm helpless.
greetings
this is the first time I am posting here, so please be gentle
I have spent all day yesterday googeling and reading stuff, and the
only post I found having the same problem as I did was replied to
by the owner with "fixed it, was something in my database.yml", what
didn't help me the slightest bit, so please help me, ruby-wan, you are
my last hope.
I have a Rails-project (OS X Snow Leopard, Rails 3.0.3, all gems are up
to date, although we got the test reproduced on another unix) that I am
supposed to test. It's pretty simple, a basic implementation of an
access control system using the devise gem.
My problem here is that I can't run any tests. The test I try to run
is the auto-generated test for my autogenerated dummy-controller that
doesn't do anything, and that doesn't work for, stacktrace:
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in
`establish_connection': test database is not configured
(ActiveRecord::AdapterNotSpecified)
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in
`establish_connection'
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railtie.rb:59
from
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in
`instance_eval'
from
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in
`execute_hook'
from
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:26:in
`on_load'
from
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railtie.rb:57
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in
`instance_exec'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in
`run'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in
`run_initializers'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in
`each'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in
`run_initializers'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in
`initialize!'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
from
/Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /Users/vivec/Documents/RubyWorkspace/psmt/config/environment.rb:5
from
/Users/vivec/Documents/RubyWorkspace/psmt/test/unit/../test_helper.rb:2:in
`require'
from
/Users/vivec/Documents/RubyWorkspace/psmt/test/unit/../test_helper.rb:2
from
/Users/vivec/Documents/RubyWorkspace/psmt/test/unit/dummy_test.rb:1:in
`require'
from /Users/vivec/Documents/RubyWorkspace/psmt/test/unit/dummy_test.rb:1
Okay, so my test database isn't configured, so let's configure it? Not
that simple, for I simply can't.
Here's the database.yml:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: psmt_dev
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: psmt_test
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
When I try to do anything rakely in development mode, everything is
fine. MySql is up and running, the databases both exist. I can do
a rake db:migrate to the database psmt_dev and, if I change the db
in development mode to psmt_test, I can migrate to that too. (I
did that and hoped it would solve the problem, it did not.)
As soon as I try to do anything rakely in test mode, it crashes -
there seems to be a problem dumping the database:
$ rake db:testrepare --trace
(in /Users/vivec/Documents/RubyWorkspace/psmt)
** Invoke db:testrepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:testrepare
** Invoke db:test:load (first_time)
** Invoke db:testurge (first_time)
** Invoke environment
** Execute db:testurge
rake aborted!
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:429
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
`invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
`synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
`invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in
`invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in
`invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in
`invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
`synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
`invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:460
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
`invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
`synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
`invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
I chased the bug deep down to databases.rake:429, and there it says:
task urge => :environment do
abcs = ActiveRecord::Base.configurations
case abcs["test"]["adapter"]
when /mysql/
and the problem seems to be with the case-statement, there something
is a nil value (and most likely it is the "adapter" value in "test"?).
The adapter value is set in my database.yml, and everything is great
as long as I stay to the development environment - but I need to
get those tests working.
In my theory, the problem is that, to execute a test, Rails wants to
have the test environment running and therefore the test-database dumped
and re-filled from the fixtures. The explosions happen during the dump-
procedure, so I guess, it's not my fault.
Does anyone have any idea how I get this fixed? I'm helpless.
greetings