What we should test - agentbright/rails-guide GitHub Wiki
Fixtures
- Create fixtures
- Keep fixtures up-to-date with models
Model tests
Process:
- Setup the data we need
- Trigger the item being tested
- Assert what we expect
What to test:
- Validations
- Collections
- Public methods
Controller tests
Process:
- Setup the application to respond to a request
- Fake a request to an action
- Make assertions on instance variables, cookies, the session, and the flash
- Assert that the application changed or didn't change as expected
- Assert that the response is what we expect
What to test:
- get index
- :filter
- get new
- get show
- get edit
- post create
- put update
- delete destroy
Mailers
What to test:
- The mail options (to, from, subject, etc) are set properly
- The mail body matches keywords or even an entire fixture
- The mail template renders without errors