{"_id":"5447ef8d0319802200fc0713","category":{"_id":"5447ed230319802200fc0702","__v":7,"version":"54471fc9e12a270800028adf","pages":["5447ef8d0319802200fc0713","56ac1ec3aa91300d00bede9b","56ac213d0bbe170d00f11272","56ac21d2c69a430d008aabb3","56b1401d4b05c50d001ceb3b","56c72ca5862f940d0056475d","56c75ec053cafe0d00a53d7b"],"project":"54471fc9e12a270800028adc","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-22T17:45:07.793Z","from_sync":false,"order":6,"slug":"convention-system","title":"Convention System"},"user":"54471f91beb6320800da6f75","__v":1,"githubsync":"","project":"54471fc9e12a270800028adc","is_link":false,"version":{"_id":"54471fc9e12a270800028adf","__v":10,"project":"54471fc9e12a270800028adc","createdAt":"2014-10-22T03:08:57.750Z","releaseDate":"2014-10-22T03:08:57.750Z","categories":["54471fc9e12a270800028ae0","5447b9e7b96a63140077d747","5447be130319802200fc0620","5447ed118d7af31a00dd411c","5447ed230319802200fc0702","5448524c4544c30800241f41","544854504544c30800241f4d","544854af4544c30800241f50","544854e74544c30800241f51","54485557c1b42e08005b82bf"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-22T17:55:25.587Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","try":true,"basic_auth":false,"auth":"never","params":[],"url":""},"isReference":false,"order":0,"body":"In your application code, you probably try to adhere to the DRY principle: Don't Repeat Yourself. Why shouldn't you do the same thing with your test code? Unfortunately, most modern frameworks don't really provide you with many tools for keeping your specs DRY. That's where SpecsFor really shines.\n\nSpecsFor includes a convention system that you can use to alter the behavior of your specs. You can encapsulate behaviors, such as starting and rolling back a transaction, and apply those behaviors to your specs based on whatever conventions you defined. \n\nIn this section, we'll look at how to specify conventions, create behaviors, and apply them to our specs.","excerpt":"","slug":"overview","type":"basic","title":"Overview"}

Advanced Topics

Overview

In your application code, you probably try to adhere to the DRY principle: Don't Repeat Yourself. Why shouldn't you do the same thing with your test code? Unfortunately, most modern frameworks don't really provide you with many tools for keeping your specs DRY. That's where SpecsFor really shines.
SpecsFor includes a convention system that you can use to alter the behavior of your specs. You can encapsulate behaviors, such as starting and rolling back a transaction, and apply those behaviors to your specs based on whatever conventions you defined.
In this section, we'll look at how to specify conventions, create behaviors, and apply them to our specs.