0

I have a Rails app (Rails - 2.3.8, Linux) which uses a MySQL database, but the database is generated separately (not through the Rails migration), so I would like to know

How can I implement testing on this application (please note currently there are no test suit at all)?

I would prefer not to have a database at all and test the functionality (including ActiveRecord models through the unit test) (because it will make the test suit independent as I see).

Currently I found this gem (temping - https://github.com/jpignata/temping) via a Stack Overflow link itself.

Please let me know if I'm going in a wrong direction.

halfer
  • 19,824
  • 17
  • 99
  • 186
sameera207
  • 16,547
  • 19
  • 87
  • 152

1 Answers1

0

This is a great resource on one method of TDD using RSpec which is more powerful than unit testing imo.

http://railscasts.com/episodes/275-how-i-test

If you are avoiding using MySQL you could simply specify Sqlite3 in your Database.yaml file:

test:
adapter: sqlite3
encoding: unicode
database: gc_test
pool: 5

Be sure to include Gem:

gem 'sqlite3-ruby'

If you have having trouble with this install, checkout this question: Why can't I install the SQLite gem?

Community
  • 1
  • 1
hagope
  • 5,523
  • 7
  • 38
  • 52
  • Hi @hagope, thanks for the answer, but I guess even to use sqlite3, I need to have a schema.rb file to load the database, but in my case, my db folder is empty. so I guess I cant use sqlite3, please correct me if I'm wrong, – sameera207 Sep 01 '11 at 17:09
  • I ended up dumping the existing schema and creating the test database – sameera207 Dec 01 '11 at 19:45