Forum: Ruby on Rails Problem with test_truth

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hello G. (Guest)
on 2009-02-21 22:51
hello all,

i have a problem with test_truth.


require 'test_helper'

class MyDataTest < ActiveSupport::TestCase
 def test_truth
   assert true
 end

end

this should ok without failures or errors. but it failure:

1) Error:
test_truth(MyDataTest):
ActiveRecord::StatementInvalid: Mysql::Error: Table
'alldataserver_test.members' doesn't exist: DELETE FROM `members`

whats here wrong?
i understand table members is not exist in alldataserver_test, but why?
here is a mistake with migration i think, can someone help me?


lg
Frederick C. (Guest)
on 2009-02-22 01:49
(Received via mailing list)
On 21 Feb 2009, at 20:51, Hello G. wrote:

>   assert true
>
> whats here wrong?
> i understand table members is not exist in alldataserver_test, but
> why?
> here is a mistake with migration i think, can someone help me?
>
it means that there is a fixtures file called members.yml so rails
helpfully tries to load it into your test database but there is no
such table.

Fred
Hello G. (Guest)
on 2009-02-22 14:34
Frederick C. wrote:
> On 21 Feb 2009, at 20:51, Hello G. wrote:
>
>>   assert true
>>
>> whats here wrong?
>> i understand table members is not exist in alldataserver_test, but
>> why?
>> here is a mistake with migration i think, can someone help me?
>>
> it means that there is a fixtures file called members.yml so rails
> helpfully tries to load it into your test database but there is no
> such table.
>
> Fred

thanks, i know, in test database are not tables. my question is: why are
not
the tables for test database create?
i did database migration and it creates only tables for development
database but
not for my test database. where can be the problem?
Phlip (Guest)
on 2009-02-22 17:49
(Received via mailing list)
Hello G. wrote:

> thanks, i know, in test database are not tables. my question is: why are
> not
> the tables for test database create?
> i did database migration and it creates only tables for development
> database but
> not for my test database. where can be the problem?

I find the rake db:migrate commands to be less than comprehensive here.
Sometimes one rake command understands testing, but another one does
not.

In this case, I always find myself entering:

   rake RAILS_ENV=test db:migrate

That uses rake's ability to push its command line options with = into
environmental variables. Then the migrator uses the test: version in
database.yml.

Also try db:reset, or db:migrate:reset.
Frederick C. (Guest)
on 2009-02-22 18:21
(Received via mailing list)
On Feb 22, 3:48 pm, Phlip <removed_email_address@domain.invalid> wrote:
>
If you run

rake

to run  your unit tests, that should clone the structure from the
development database to the test one.

Fred
Hello G. (Guest)
on 2009-02-22 19:52
Frederick C. wrote:
> On Feb 22, 3:48�pm, Phlip <removed_email_address@domain.invalid> wrote:
>>
> If you run
>
> rake
>
> to run  your unit tests, that should clone the structure from the
> development database to the test one.
>
> Fred

Hello Philip and Fred,

i use netbeans6.5 and i don't know how i can enter   rake RAILS_ENV=test
db:migrate

but i try db:migrate:reset and it reset tables on development but in
test are
nothing with tables :(((

i do the whole time run "rake", but the effect is what i tell :(((

i will tell you, this problem appearance when i checkout the project
from svn repository, perhaps this is a good information for you to help
me.
Hello G. (Guest)
on 2009-02-22 20:06
Hello,

ok it works :)))))) there are tables in my test database :))))
there are the right tables :)))))

i think .... :((

if i run the unit test
  def test_truth
    assert true
  end

there is one error:
1) Error:
test_truth(MyDataTest):
ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'mydata' in
'field list': INSERT INTO `members` (`person_id`, `created_at`,
`updated_at`, `mydata`, `id`, `mydata_id`) VALUES (1, '2009-02-22
18:00:49', '2009-02-22 18:00:49', 'verein1', 238752903, 4)

where does this column come from?
i look at my database and there is no column witch call 'mydata'.
also it is not in schema.rb

hmpf :(((
Phlip (Guest)
on 2009-02-22 20:20
(Received via mailing list)
Frederick C. wrote:
>
>> I find the rake db:migrate commands to be less than comprehensive here.
>> Sometimes one rake command understands testing, but another one does not.

> If you run
>
> rake
>
> to run your unit tests, that should clone the structure from the
> development database to the test one.

Maybe we do the trick too often where we add a migration, then run the
one test
waiting for it. That resolves to:

  ruby test/unit/foo_test.rb -n test_bar

...which utterly bypasses all rake scripts.

But our projects are old, so their scripts might not be well tuned.

Then I don't know what the OP's real problem is, but 'rake
RAILS_ENV=test
db:migrate' is well-worth a shot!

--
   Phlip
Phlip (Guest)
on 2009-02-22 20:26
(Received via mailing list)
> test_truth(MyDataTest):
> ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'mydata' in
> 'field list': INSERT INTO `members` (`person_id`, `created_at`,
> `updated_at`, `mydata`, `id`, `mydata_id`) VALUES (1, '2009-02-22
> 18:00:49', '2009-02-22 18:00:49', 'verein1', 238752903, 4)
>
> where does this column come from?

test/fixtures/members.yml
Hello G. (Guest)
on 2009-02-22 20:33
Phlip wrote:
>> test_truth(MyDataTest):
>> ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'mydata' in
>> 'field list': INSERT INTO `members` (`person_id`, `created_at`,
>> `updated_at`, `mydata`, `id`, `mydata_id`) VALUES (1, '2009-02-22
>> 18:00:49', '2009-02-22 18:00:49', 'verein1', 238752903, 4)
>>
>> where does this column come from?
>
> test/fixtures/members.yml

THANK YOU SOOOO MUCH!!!

it works great :))))
im so happy :))))
Phlip (Guest)
on 2009-02-22 20:36
(Received via mailing list)
Hello G. wrote:

> i use netbeans6.5 and i don't know how i can enter   rake RAILS_ENV=test
> db:migrate

You cannot do Rails without learning and frequently using a command
line. Either
CMD.EXE or bash - pick your poison!

--
   Phlip
This topic is locked and can not be replied to.