I am wondering how to set up testing in my rails applications. When I run rake test , the first thing that is strange is launching a bunch of CREATE TABLE against my dev. database (buzz .. don't like it ..). So I run rake test RAILS_ENV=test and even try bundle exec rake test RAILS_ENV=test . Now CREATE TABLE works against my test database, but all this error crashes:
** Execute test:units test/unit/category_test.rb:5:in `test': unknown command 't' (ArgumentError) from test/unit/category_test.rb:5:in `<class:CategoryTest>'
I used the base generator in Rails 3 and do not change anything. So I have this in caterogy_test.rb:
require 'test_helper' class CategoryTest < ActiveSupport::TestCase
I am using Rails 3.0.7 and the basic configuration.
Any ideas?
EDIT
I get crazy, make many attempts, and it doesn't seem to work. When I launch a new application with several things, rake test works fine, but when I try to do this on my current one, it starts always against my dev. db and do not work at all. I tried to edit the test files, return them back, try to uninstall / install test db in different ways, try a different version of the rake, compare a lot of things on the one hand with my current application, and on the other a completely new one ... Nothing was found .. Help !
EDIT 2
It sounds weak, but is it normal that rake does the same as rake test ?
EDIT 3
There is disagreement, while I continue to work on what is wrong, I understand that every time I run rake test , it works in the dev environment, and not in the test one (viewing logs). It does this on my OSX computer and on our FreeBSD server for all Rails 3.0.7 applications. Are you sure rake test should work by default test environment?
EDIT 4
Please, help!
EDIT 5 - SUMMARY
When running rake test on my computer or on our server in Rails 3.0.7 with various applications, it performs the following actions:
- perform a
CREATE TABLE and INSERT INTO migration from dev. db - do not clean dev. db
- development.log is not written to test.log
- also a problem with the
unknowm comman 't' error with one specific application.
EDIT 6 - db config
Nothing has changed so far: https://gist.github.com/1006199
EDIT 7
rake db:test:prepare --trace nothing breaks (but keep printing (first_time) https://gist.github.com/1007340
With RAILS_ENV="test" for the rake, everything is going well. It is recorded in test logs.
ruby -I test test/unit/category_test.rb the same erros as with rake , but do not write to dev. or test logs.