开发者

Testing a Rails app without a database

I have a Rails app (Rails - 2.3.8, Linux) which uses a MySQL database, but the database is generated separately (not t开发者_如何学JAVAhrough 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.


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜