Unit tests

Ruby on Rails makes it very easy to add tests to an application. Because of the added security and stability such tests provide, it is desirable to add them to Chameleon. Furthermore, they provide good use cases for all functions, as a reference for plugin creators, which will be added in version 0.7. Some tests already exist (for the routes and for the Option model, for example), and the test coverage should be expanded to all models.

Please note that this spec does not only deal with unit tests (meaning tests for models mainly), but with all sorts of automated testing (unit, functional and integration).

Detailed information on adding tests to a Rails project is in the Rails manual "A guide to testing the Rails". In this manual there is also a complete list of all available assertions. Furthermore, the Ruby tool rcov can be used to calculate the code coverage, in combination with the Rails plug-in rails_rcov.

The goals of this spec for Chameleon version 0.6.2 have been reached, and this spec is now completed. In the future, some more work will probably be spent on testing, such as adding the missing tests for Admin::EntriesController, the libraries and integration tests. We can then refer back to this spec, and the overview below. (—JW, 2008-03-15)

What needs tests?

An overview of what code needs tests, and the progress:
(Watch out: looks can be deceiving, this doesn't show the overall progress of this spec.)

  • Controllers: Functional tests - Completed for now
    • AccountController - Completed
    • BlogController - Completed
    • FeedController - Completed
    • JsonController - Completed
    • Admin::*Controller - Completed, except Admin::EntriesController
      • Admin::BaseController - Nothing to test
      • Admin::CommentsController - Completed
      • Admin::DashboardController - Completed
      • Admin::EntriesController - Will be done later
      • Admin::SettingsController - Completed
      • Admin::ThemesController - Completed
      • Admin::UsersController - Completed
  • Models: Unit tests - Completed
  • Helpers: Unit tests - Completed
  • Libraries: Won't be done for now
    • Liquid drops, tags and filters - Won't test (might also need some reworking)
    • Akismet library - Won't test, we might switch to a different library
    • LoginSystem - Maybe tested as integration test?
    • Pinger - Won't test (although we should)
    • Search - Won't test, probably tested by its original author
  • The system as a whole: Integration tests - Partially done - Postponed to a later release
    • Routes - Previously completed, will be reworked after upgrade to Rails 1.2 (see here)
    • Log in?
    • (Themes?)

Functions without tests

These functions shouldn't get tests:

  • Entry
    • is_featured?: Will be moved to a plugin in the next version.
    • is_recent?: Will be moved to a plugin in the next version.
    • is_popular?: Will be moved to a plugin in the next version.
    • send_pings: Unable to test. We trust Pinger to work correctly. (But should we?)
    • contents_html, contents_text, description_html and description_text: The Markdown and regular text parts: these will be moved to a plugin in the next version.
  • The to_liquid function in all models.
page_revision: 37, last_edited: 1205601144|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.