Error when running my unit test

Hi Rails team

Learning ROR, and is doing the chapter with test… feel like
skipping this, but…

(using NetBeans IDE 6.1)

I have created this story_test.rb, and when I run the 'rake test:units
(selected from the GUI), I get this error:

(in /data/NewOrder/Projects/ROR/shovell)
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:clone (first_time)
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
rake aborted!
EMULTIHOP (Reserved)
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
activerecord-2.0.2/lib/active_record/connection_adapters/
mysql_adapter.rb:471:in connect' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ activerecord-2.0.2/lib/active_record/connection_adapters/ mysql_adapter.rb:165:ininitialize’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
activerecord-2.0.2/lib/active_record/connection_adapters/
mysql_adapter.rb:88:in new' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ activerecord-2.0.2/lib/active_record/connection_adapters/ mysql_adapter.rb:88:inmysql_connection’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
activerecord-2.0.2/lib/active_record/connection_adapters/abstract/
connection_specification.rb:291:in connection=' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ activerecord-2.0.2/lib/active_record/connection_adapters/abstract/ connection_specification.rb:259:inretrieve_connection’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
activerecord-2.0.2/lib/active_record/connection_adapters/abstract/
connection_specification.rb:78:in connection' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rails-2.0.2/lib/tasks/databases.rake:285 /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:546:incall’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:546:in execute' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:541:ineach’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:541:in execute' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:508:ininvoke_with_call_chain’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:501:in synchronize' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:501:ininvoke_with_call_chain’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:518:in invoke_prerequisites' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:1183:ineach’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:1183:in each' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:515:ininvoke_prerequisites’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:507:in invoke_with_call_chain' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:501:insynchronize’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:501:in invoke_with_call_chain' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:494:ininvoke’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rails-2.0.2/lib/tasks/databases.rake:318
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:546:in call' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:546:inexecute’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:541:in each' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:541:inexecute’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:508:in invoke_with_call_chain' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:501:insynchronize’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:501:in invoke_with_call_chain' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:518:ininvoke_prerequisites’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:1183:in each' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:1183:ineach’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:515:in invoke_prerequisites' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:507:ininvoke_with_call_chain’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:501:in synchronize' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:501:ininvoke_with_call_chain’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:494:in invoke' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:1931:ininvoke_task’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:1909:in top_level' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:1909:ineach’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:1909:in top_level' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:1948:instandard_exception_handling’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:1903:in top_level' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:1881:inrun’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/lib/rake.rb:1948:in standard_exception_handling' /home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ rake-0.8.1/lib/rake.rb:1878:inrun’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/
rake-0.8.1/bin/rake:31
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/bin/rake:19:in `load’
/home/dk90394/netbeans-6.1/ruby2/jruby-1.1/bin/rake:19

doing the same from the shell gives me this error:

[email protected]:/data/NewOrder/Projects/ROR/shovell# rake test:units –
trace
(in /data/NewOrder/Projects/ROR/shovell)
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:clone (first_time)
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
rake aborted!
Access denied for user ‘root’@‘localhost’ (using password: NO)
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/mysql_adapter.rb:471:in real_connect' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/mysql_adapter.rb:471:inconnect’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/mysql_adapter.rb:165:in initialize' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/mysql_adapter.rb:88:innew’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/mysql_adapter.rb:88:in mysql_connection' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/abstract/connection_specification.rb:291:insend’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/abstract/connection_specification.rb:291:in
connection=' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/abstract/connection_specification.rb:259:inretrieve_connection’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/abstract/connection_specification.rb:78:in
connection' /var/lib/gems/1.8/gems/rails-2.0.2/lib/tasks/databases.rake:285 /usr/lib/ruby/1.8/rake.rb:387:incall’
/usr/lib/ruby/1.8/rake.rb:387:in execute' /usr/lib/ruby/1.8/rake.rb:387:ineach’
/usr/lib/ruby/1.8/rake.rb:387:in execute' /usr/lib/ruby/1.8/rake.rb:357:ininvoke’
/usr/lib/ruby/1.8/rake.rb:350:in synchronize' /usr/lib/ruby/1.8/rake.rb:350:ininvoke’
/usr/lib/ruby/1.8/rake.rb:364:in invoke_prerequisites' /usr/lib/ruby/1.8/rake.rb:1017:ineach’
/usr/lib/ruby/1.8/rake.rb:1017:in send' /usr/lib/ruby/1.8/rake.rb:1017:ineach’
/usr/lib/ruby/1.8/rake.rb:363:in invoke_prerequisites' /usr/lib/ruby/1.8/rake.rb:356:ininvoke’
/usr/lib/ruby/1.8/rake.rb:350:in synchronize' /usr/lib/ruby/1.8/rake.rb:350:ininvoke’
/var/lib/gems/1.8/gems/rails-2.0.2/lib/tasks/databases.rake:318
/usr/lib/ruby/1.8/rake.rb:387:in call' /usr/lib/ruby/1.8/rake.rb:387:inexecute’
/usr/lib/ruby/1.8/rake.rb:387:in each' /usr/lib/ruby/1.8/rake.rb:387:inexecute’
/usr/lib/ruby/1.8/rake.rb:357:in invoke' /usr/lib/ruby/1.8/rake.rb:350:insynchronize’
/usr/lib/ruby/1.8/rake.rb:350:in invoke' /usr/lib/ruby/1.8/rake.rb:364:ininvoke_prerequisites’
/usr/lib/ruby/1.8/rake.rb:1017:in each' /usr/lib/ruby/1.8/rake.rb:1017:insend’
/usr/lib/ruby/1.8/rake.rb:1017:in each' /usr/lib/ruby/1.8/rake.rb:363:ininvoke_prerequisites’
/usr/lib/ruby/1.8/rake.rb:356:in invoke' /usr/lib/ruby/1.8/rake.rb:350:insynchronize’
/usr/lib/ruby/1.8/rake.rb:350:in invoke' /usr/lib/ruby/1.8/rake.rb:1924:inrun’
/usr/lib/ruby/1.8/rake.rb:1924:in each' /usr/lib/ruby/1.8/rake.rb:1924:inrun’
/usr/bin/rake:4

Done this as normal user, and as root. Same error.

I guess the problem is ‘Access denied for user
‘root’@‘localhost’ (using password: NO)’
Now, this is my database.yml:

And be sure to use new-style password hashing:

http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development:
adapter: mysql
encoding: utf8
database: shovell_development
username: root
password: password

JRuby doesn’t support socket:

host: 127.0.0.1
#socket: /var/run/mysqld/mysqld.sock

I did have problems with creating stuff, in the base, until I gave the
password. So this works fine. I can create rows in the table inside
the ‘shovell_development’ db, using my rails app. But not run the rake
test:units what is wrong ? Something with the ‘db:test:purge’ ?

Hope some can give me a clue ? (And yes, I can log in with u:root
p:password, and browse the rows, and delete them).

Regards
Jørn

Guess, you are right. That solved the problem (adding the password in
the test section, and the host…)

Thanks…

Jørn.

On Wed, 2008-07-16 at 16:40 -0700, jborup wrote:

Hi Rails team

Learning ROR, and is doing the chapter with test… feel like
skipping this, but…

JRuby doesn’t support socket:

host: 127.0.0.1
#socket: /var/run/mysqld/mysqld.sock

I did have problems with creating stuff, in the base, until I gave the
password. So this works fine. I can create rows in the table inside
the ‘shovell_development’ db, using my rails app. But not run the rake
test:units what is wrong ? Something with the ‘db:test:purge’ ?

Hope some can give me a clue ? (And yes, I can log in with u:root
p:password, and browse the rows, and delete them).


test needs its own db

database.yml

development:
adapter: mysql
encoding: utf8
database: shovell_development
username: root
password: password
host: 127.0.0.1
test:
adapter: mysql
encoding: utf8
database: shovell_test
username: root
password: password
host: 127.0.0.1

Craig

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs