-
Notifications
You must be signed in to change notification settings - Fork 8
Testing
We provide a testing setup for both Rails and Angular 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:
- https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md
- https://github.com/thoughtbot/factory_girl_rails
Testing is a vast subject, best learnt from hands-on experience. See the following for ideas on how to get started:
- https://github.com/howaboutwe/rspec-style-guide
- http://dhartweg.roon.io/rspec-testing-for-a-json-api
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.
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:
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.
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.