Skip to content
TheNotary edited this page Apr 13, 2016 · 4 revisions

The rails community agreed that rspec is the gem to use for unit testing your application. I don't know how to structure a tutorial to explain testing.

What do you need to test?

Every method you define in your models should have at least one model test associated with it. It should be written at about the time you decide it should exist, though writing it before hand isn't always practical in rails apps.

Integration tests should be written for creating, deleting, viewing and updating resources. If your functionality is expected to change based on whether you're logged in or not, you should test the logged in condition too.

Controller tests are fun for testing the restful interface of the app. You can basically do curl requests against your app, even if there's no UI for doing some things, and make sure, say, security is in place to stop a malicious user from deleting all the users in your app.

Clone this wiki locally