Skip to content

Commit

Permalink
[copycopter#4] Create testing guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Croak committed Mar 15, 2012
1 parent 1bda2fc commit ee48391
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Expand Up @@ -195,6 +195,27 @@ Rails
* Use the default `render 'partial'` syntax over `render :partial => 'partial'`.
* Use the `:only` option to explicitly state exposed routes.

Testing
-------

* Avoid `its`, `specify`, `subject`, and other DSLs. Prefer explicitness and
consistency.
* Disable real HTTP requests to external services.
* Don't prefix `it` blocks with 'should'.
* Prefix `context` blocks names with 'given' when receiving input. Prefix with
'when' in most other cases.
* Name outer `describe` blocks after the method under test. Use `self.method`
for class methods and `method` for instance methods. This matches the method
definition itself.
* Run specs with `--format documentation`.
* Stub requests to external services.
* Use a `context` block for each execution path through the method.
* Use `before` blocks to clearly define the 'setup' phase of the
[Four Phase Test](http://xunitpatterns.com/Four%20Phase%20Test.html).
* Use integration tests to execute the entire app.
* Use one expection per `it` block.
* Use stubs and spies (not mocks) to isolate unit tests as much as possible.

Credit
------

Expand Down

0 comments on commit ee48391

Please sign in to comment.