Skip to content
natesholland edited this page Oct 9, 2013 · 2 revisions

Since this project is constantly growing and changing, it is vital that code is designed in such a way that changing implementation of one construct doesn't break something somewhere else. It's been discovered that this can get very hairy when designing Rspec tests.

When writing a test for, say, the PictureController, it would be helpful to create and save Pictures that can then be worked with throughout the test. However, if someone were to later change the Picture model (change the attributes or implement certain validations) then this PictureController test which may have been written weeks ago will suddenly fail.

For this reason, we are establishing a convention where we will be using FactoryGirl to create dummy versions for all of our models. Please use these to construct the various models in your testing. If you are making changes to a model please make sure that you keep the factory up to date so that the factory represents a valid form of the model you are working on.

If you are still a bit confused about this, go and check out the spec/factories directory.

Clone this wiki locally