Skip to content
This repository


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 
6 
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
+## Use `before(:each)`, not `before(:all)`
+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.
+Instead of `before(:all)`, use `before(:each)`.
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.