Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Explained why `before(:all)` won't work for stubs.

  • Loading branch information...
commit 0815a4a365bcf8078aa74709b2ba26f959c928ec 1 parent 185d47e
Nathan Long authored March 05, 2012

Showing 1 changed file with 6 additions and 0 deletions. Show diff stats Hide diff stats

  1. 6  README.md
6  README.md
Source Rendered
@@ -239,6 +239,12 @@ While this is a good thing when you really need it, you probably don't really
239 239
 need it! Take care to specify only the things that matter to the behavior of
240 240
 your code.
241 241
 
  242
+## Use `before(:each)`, not `before(:all)`
  243
+
  244
+Stubs in `before(:all)` are not supported. The reason is that all stubs and mocks get cleared out after each example, so any stub that is set in `before(:all)` would work in the first example that happens to run in that group, but not for any others.
  245
+
  246
+Instead of `before(:all)`, use `before(:each)`.
  247
+
242 248
 ## Further Reading
243 249
 
244 250
 There are many different viewpoints about the meaning of mocks and stubs. If

0 notes on commit 0815a4a

Please sign in to comment.
Something went wrong with that request. Please try again.