[Rails] Problem with unit tests
Jens-Christian Fischer
jcf at invisible.ch
Tue Nov 16 12:21:19 GMT 2004
Hi list
I'm trying to unit test my little rail app and run into the following
problems (using the new beta gems)
Model: Person, database table: people
Unit Test:
require File.dirname(__FILE__) + '/../test_helper'
require 'person'
class PersonTest < Test::Unit::TestCase
def setup
@people = create_fixtures "person"
end
def test_count_my_fixtures
assert_equal 2, Person.count
end
end
and I have a file "person.yaml" in test/fixtures/person
When I run "rake test_units" I get the following message:
2) Error:
test_count_my_fixtures(PersonTest):
ActiveRecord::StatementInvalid: Table 'mush_test.person' doesn't exist:
DELETE FROM person
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.0.0.20041114/lib/active_record/connection_adapters/abstract_adapter.rb:339:in
`log'
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.0.0.20041114/lib/active_record/connection_adapters/mysql_adapter.rb:67:in
`delete'
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.0.0.20041114/lib/active_record/fixtures.rb:105:in
`delete_existing_fixtures'
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.0.0.20041114/lib/active_record/fixtures.rb:83:in
`initialize'
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.0.0.20041114/lib/active_record/fixtures.rb:68:in
`new'
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.0.0.20041114/lib/active_record/fixtures.rb:68:in
`create_fixtures'
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.0.0.20041114/lib/active_record/fixtures.rb:67:in
`map'
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.0.0.20041114/lib/active_record/fixtures.rb:67:in
`create_fixtures'
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.0.0.20041114/lib/active_record/fixtures.rb:66:in
`transaction'
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.0.0.20041114/lib/active_record/fixtures.rb:66:in
`create_fixtures'
./test/unit/../test_helper.rb:8:in `create_fixtures'
./test/unit/person_test.rb:6:in `setup'
(and the same error for the other models).
The problem seems to be that the table name isn't pluralized
Any ideas?
thanks
jc
More information about the Rails
mailing list