help needed in UNIT Testing

Hi!

assert avail.valid?

one trick I find convenient to get more accurate information in that case is to do something like:

assert avail.valid?, “The model is invalid: #{avail.errors.full_messages}”

hth

Thibaut

one trick I find convenient to get more accurate information in that case is to do something like:

assert avail.valid?, “The model is invalid: #{avail.errors.full_messages}”

Unless you use : assert_valid :slight_smile:

Narayana Karthick wrote:

Thibaut Barrère wrote: >> >> one trick I find convenient to get more accurate information in that case >> is to do something like: >> >> assert avail.valid?, "The model is invalid: #{avail.errors.full_messages}" > > > Unless you use : assert_valid :slight_smile: hi, Thx for Both Guys. now   assert avail.valid?   assert avail.save NO Errors & No Failures.

It passes the both the test, now the problem is, it does not save data into the test database. From fixtures to database, transaction takes place successfully. but for save method the transaction does not take place.

Plz help me to solve this problem.

advance Thx

regards, Narayana.

-- Posted via http://www.ruby-forum.com/.

A normal test cycle runs like this..

setup 1. clear the DB 2. load the data from fixtures into the DB

run tests 3. start a transaction 4. run the test 5. rollback the transaction 6. lather, rinse, repeat (from 3)

So if you save data to the DB from one test, you won't see any trace of it in the DB when you are done.

If you so desire, you can load all of your fixtures into your test db by using rake db:fixtures:load

_Kevin

Jonathan,

Why can't you manually set vendor_id?

I've done it several times when I wanted to avoid loading the associated record.

The only problem I can see is where you need to create the record and immediately use the association....

No problems yet - but I want to make sure I'm not shooting myself in the foot.

Starr