Ouverture de session

Commentaires récents

Syndication
Flux XML

Rake test:units lance les tests sur la BDD de développement

Rake test:units lance les tests sur la BDD de développement
Posté par Gravis le Vendredi, 26 Octobre, 2007 - 11:22am. Développement

Bonjour,

un soucis que je n'arrive pas à expliquer. Je développe sur Mac OS X, et déploie sur un serveur Linux Debian. Jusque là, pas de soucis, à priori.

Le problème, c'est que lorsque je lance mes tests sur le linux, c'est l'environnement de DEV qui est utilisé :

$ rake test:units
(in ...)
rake aborted!
Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)

(See full trace by running task with --trace)
$

et le contenu de mon fichier database.yml :

# MySQL (default setup).  Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
#   gem install mysql
# On MacOS X:
#   gem install mysql -- --include=/usr/local/lib
# On Windows:
#   gem install mysql
#       Choose the win32 build.
#       Install MySQL and put its /bin directory on your path.
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
  adapter: mysql
  database: project_dev
  username: project_dev
  password: xxxxxxx
  encoding: utf8
  socket: /opt/local/var/run/mysql5/mysqld.sock

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
  adapter: mysql
  database: project_test
  username: project_test
  password: xxxxxxx
  encoding: utf8
  socket: /var/run/mysqld/mysqld.sock

production:
  adapter: mysql
  database: project_prod
  username: project_prod
  password: xxxxxxx
  encoding: utf8
  socket: /var/run/mysqld/mysqld.sock

Une idée ?

Au passage, les tests marchent bien sur Mac OS X



[ Vous devez vous connecter ou vous enregistrer pour écrire des commentaires | sujet précédent | sujet suivant | envoyer par email ]

Options d'affichage des commentaires
Sélectionnez la méthode d'affichage des commentaires que vous préférez, puis cliquez sur "Sauvegarder" pour activer vos changements.

Sujet: 
Hi David,
Auteur: 
Gravis
Date: 
Jeu, 08/11/2007 - 00:42

Hi David,

thanks for your help. Sorry, since you're the only one helping there, I will go with english :)

So, the

puts ENV['RAILS_ENV']

returned a

nil

as expected.

Regarding the rake file, mine looks slightly different, I will try to update my gems and see weather if the problem is still there. Anyway, the project is running well in "production" mode, on the same server. I've googled a lot, and it appears that I'm the only one having this issue.


[ Vous devez vous connecter ou vous enregistrer pour écrire des commentaires | envoyer par email ]

Sujet: 
re: Rake test:units lance les tests sur la BDD de développement
Auteur: 
alpinegizmo
Date: 
Dim, 04/11/2007 - 01:40

First I would double-check that you have the same config/database.yml file on the server as in development.

One way to check if something bizarre is going on would be to put this at the beginning of config/environment.rb:

puts ENV['RAILS_ENV']

If you want to dig in deeper, the code that causes the tests to run in the 'test' environment is in this rake task in railties/lib/tasks/databases.rake:

namespace :test do
desc "Recreate the test database from the current environment's database schema"
task :clone => %w(db:schema:dump db:test:purge) do
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
ActiveRecord::Schema.verbose = false
Rake::Task["db:schema:load"].invoke
end

Bonnes chances (and sorry for the english),

--david


[ Vous devez vous connecter ou vous enregistrer pour écrire des commentaires | envoyer par email ]

Sujet: 
Hi, I think I know where the
Auteur: 
Gravis
Date: 
Jeu, 08/11/2007 - 09:03

Hi,

I think I know where the problem is. Running rake test:units will clone the development environment for the tests. This is silly, but the only explanation I have.

UPDATE :
http://snippets.dzone.com/posts/show/2031

=> Rake will use the dev DB instead of migrations, that's crazy.


[ Vous devez vous connecter ou vous enregistrer pour écrire des commentaires | envoyer par email ]

Nouveaux liens

Sondage
Lorsque je développe avec Ruby on Rails c'est principalement sous:
Linux
37%
Mac OS X
29%
Windows
32%
(Free|Open|Net) BSD
1%
Autre...
1%
Nombre de votes: 356

Qui est en ligne
Il y a actuellement 1 utilisateur et 42 invités en ligne.

railsfrance.org - communauté francophone des utilisateurs de Ruby on Rails
[ Hébergement et ressources techniques gracieusement fournis par la SSLL Nuxos Group ]