Skip to content
Saumya Kanoria edited this page Sep 19, 2016 · 3 revisions

We provide a testing setup for both Rails and Angular code.

Testing Rails Code

We use RSpec (instead of the default TestUnit) for Rails code testing:

We use FactoryGirl for creating real or mock objects required for testing:

Testing is a vast subject, best learnt from hands-on experience. See the following for ideas on how to get started:

Mock Objects

Most tests require real or mock objects against which tests can be run. We use FactoryGirl and rspec-mocks for creating such objects. Each has its advantages, and when to choose which is beautifully explained in this article.

User Authentication

Many controller tests require a user (possibly having certain roles) to be signed in. We have provided integration with Devise for easy authentication. See the following for more information:

Authorization Policy Testing

We provide an easy way to test authorization policies generated using Pundit. See /spec/support/pundit_matcher.rb for relevant RSpec matchers.

Authorization policy tests are placed in the /spec/policies directory.

Testing Angular Code

We use [Teaspoon](https://github.com/modeset/teaspoon for more information) (which itself supports several test frameworks - Jasmine, Mocha and QUnit) for JS and Angular code testing.

NOTE: We are using an old version (~0.8.x) of Teaspoon. As of writing, the newest version has gone well beyond 1.x. Keep this in mind when you read its documentation.

Clone this wiki locally