# Error when running my unit test

**URL:** <https://www.ruby-forum.com/t/error-when-running-my-unit-test/143294>\
**Category:** Rails\
**Created:** [July 17, 2008, 1:41am UTC](https://www.ruby-forum.com/t/error-when-running-my-unit-test/143294 "2008-07-17T01:41:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joernborup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joernborup](https://www.ruby-forum.com/u/joernborup)\
**Post date:** [July 17, 2008, 1:41am UTC](https://www.ruby-forum.com/t/error-when-running-my-unit-test/143294/1 "2008-07-17T01:41:38Z")

</div>

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:in `initialize’  
/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:in `mysql\_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:in `retrieve\_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: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: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: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: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: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: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: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: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: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: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: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: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: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: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:in `invoke’  
/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: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: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: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: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: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: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: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: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: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: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: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: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: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: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:in `invoke\_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:in `each’  
/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: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: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:in `run’  
/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:in `run’  
/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:

root@dk90394lud:/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:in `connect’  
/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:in `new’  
/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:in `send’  
/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:in `retrieve\_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:in `call’  
/usr/lib/ruby/1.8/rake.rb:387:in `execute' /usr/lib/ruby/1.8/rake.rb:387:in `each’  
/usr/lib/ruby/1.8/rake.rb:387:in `execute' /usr/lib/ruby/1.8/rake.rb:357:in `invoke’  
/usr/lib/ruby/1.8/rake.rb:350:in `synchronize' /usr/lib/ruby/1.8/rake.rb:350:in `invoke’  
/usr/lib/ruby/1.8/rake.rb:364:in `invoke_prerequisites' /usr/lib/ruby/1.8/rake.rb:1017:in `each’  
/usr/lib/ruby/1.8/rake.rb:1017:in `send' /usr/lib/ruby/1.8/rake.rb:1017:in `each’  
/usr/lib/ruby/1.8/rake.rb:363:in `invoke_prerequisites' /usr/lib/ruby/1.8/rake.rb:356:in `invoke’  
/usr/lib/ruby/1.8/rake.rb:350:in `synchronize' /usr/lib/ruby/1.8/rake.rb:350:in `invoke’  
/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:in `execute’  
/usr/lib/ruby/1.8/rake.rb:387:in `each' /usr/lib/ruby/1.8/rake.rb:387:in `execute’  
/usr/lib/ruby/1.8/rake.rb:357:in `invoke' /usr/lib/ruby/1.8/rake.rb:350:in `synchronize’  
/usr/lib/ruby/1.8/rake.rb:350:in `invoke' /usr/lib/ruby/1.8/rake.rb:364:in `invoke\_prerequisites’  
/usr/lib/ruby/1.8/rake.rb:1017:in `each' /usr/lib/ruby/1.8/rake.rb:1017:in `send’  
/usr/lib/ruby/1.8/rake.rb:1017:in `each' /usr/lib/ruby/1.8/rake.rb:363:in `invoke\_prerequisites’  
/usr/lib/ruby/1.8/rake.rb:356:in `invoke' /usr/lib/ruby/1.8/rake.rb:350:in `synchronize’  
/usr/lib/ruby/1.8/rake.rb:350:in `invoke' /usr/lib/ruby/1.8/rake.rb:1924:in `run’  
/usr/lib/ruby/1.8/rake.rb:1924:in `each' /usr/lib/ruby/1.8/rake.rb:1924:in `run’  
/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](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

---

<div class="post-metadata">

**Author:** ![joernborup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joernborup](https://www.ruby-forum.com/u/joernborup)\
**Post date:** [July 17, 2008, 2:22am UTC](https://www.ruby-forum.com/t/error-when-running-my-unit-test/143294/2 "2008-07-17T02:22:00Z")

</div>

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

Thanks…

Jørn.

---

<div class="post-metadata">

**Author:** ![joernborup](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joernborup](https://www.ruby-forum.com/u/joernborup)\
**Post date:** [July 17, 2008, 1:56am UTC](https://www.ruby-forum.com/t/error-when-running-my-unit-test/143294/3 "2008-07-17T01:56:15Z")

</div>

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
