Skip to content

Commit

Permalink
Merge pull request rspec#115 from nathanl/master
Browse files Browse the repository at this point in the history
Explained why `before(:all)` won't work for stubs.
  • Loading branch information
dchelimsky committed May 17, 2012
2 parents eebee30 + 0815a4a commit 2a69b71
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -246,6 +246,12 @@ While this is a good thing when you really need it, you probably don't really
need it! Take care to specify only the things that matter to the behavior of
your code.

## 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)`.

## Further Reading

There are many different viewpoints about the meaning of mocks and stubs. If
Expand Down

0 comments on commit 2a69b71

Please sign in to comment.