Forum: Ruby on Rails Unit tests - without the db ?

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.
91eb330fb36d1e03c856574dfb77d2bc?d=identicon&s=25 thibaut.barrere (Guest)
on 2005-12-08 11:00
(Received via mailing list)
Hi

Having done TDD and unit tests in general before coming (recently) to
Ruby
and RoR, a question comes to my mind: do many people write unit tests
which
do not interact with the database ? The skeletton of unit tests
generated
automatically when creating a new model class seems to assume the common
behaviour is to test against the database rather than in memory.

Please note that I understand the benefits of testing against the
database,
but I'd like to know if it's also a common habit when writing RoR apps
to
add non-db related unit tests for the model...

Any advice or opinion ?

cheers!

Thibaut Barrère
13ea48f056b19349027d2f4a6921a46a?d=identicon&s=25 jf.web3 (Guest)
on 2005-12-08 14:14
(Received via mailing list)
Thibaut :
>  Having done TDD and unit tests in general before coming (recently)
> to Ruby and RoR, a question comes to my mind: do many people
> write unit tests which do not interact with the database ? The
> skeletton of unit tests generated automatically when creating a
> new model class seems to assume the common behaviour is to
> test against the database rather than in memory.

Assuming you can use SQLite3, You can do tests against in-memory
SQLite database. Of course, it will not deal with MySQL or PostgreSQL
specific issues.

in database.yml :

test:
  adapter: sqlite3
  database: ":memory:"


        -- Jean-François.

--
À la renverse.
This topic is locked and can not be replied to.