Simão Freitas wrote:
> Hi there! I'm creating an application in RoR and I'm implementing unit
> testing in all my models.
> 
> When I run every test on his own (by running ruby
> test/unit/some_test.rb) all tests are successful.

Slightly off-topic tip: use RSpec instead of Test::Unit.  It's a lot 
nicer.

> 
> But when I run all tests together (by running rake test:units) some
> tables from both databases (development e test) are deleted.

That's odd.  What is your database.yml file like?

> 
> I'm using raw SQL (mysql) do create tables 

With migrations or not?

> because I need composite
> primary keys and physical constraints so I figured it would be the best.

BAD IDEA!  Use the composite_primary_keys and foreigner plugins.

> Maybe this be the cause?

Perhaps.  Are all your tables mentioned in schema.rb?

> 
> All my tests are in this form:
> -----------------------
> require File.dirname(FILE) + '/../test_helper'
> require File.dirname(FILE) + '/../../app/models/order'
> 
> class OrderTestCase < Test::Unit::TestCase
> 
> def setup
> 
> @order = Order.new(
>     :user_id => 1,
>     :total => 10.23,
>     :date => Date.today,
>     :status => 'processing',
>     :date_concluded => Date.today,
>     :user_address_user_id => 3,
>     :user_address_address_id => 5,
>     :creation_date => Date.today,
>     :update_date => Date.today
>   )
> end

You probably should start using factories (I'm fond of Machinist for 
this).

> 
> ################ Happy Path
> 
> def test_happy_path
> 
> assert @order.valid?, @order.errors.full_messages
> 
> end (...)
> -----------------------
> The errors I get when running the tests are something like this:
> 
> 3) Error: test_empty_is_primary(AddressTestCase):
> ActiveRecord::StatementInvalid: Mysql::Error: Table
> 'shopshop_enterprise_test.addresses' doesn't exist: SHOW FIELDS FROM
> addresses
>  /test/unit/address_test.rb:9:in new'
>  /test/unit/address_test.rb:9:insetup'
> 
> Any guesses? Thanks!
> 
> PS: When using postgres as the database engine, everything works fine
> with rake test:units! (of course, with the correct changes so the sql
> statements can work with postgres)

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to