File: Scope.md

package info (click to toggle)
ruby-rspec-mocks 2.14.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 868 kB
  • ctags: 725
  • sloc: ruby: 8,227; makefile: 4
file content (17 lines) | stat: -rw-r--r-- 608 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Doubles, stubs, and message expectations are all cleaned out after each
example. This ensures that each example can be run in isolation, and in any
order.

### `before(:each)`

It is perfectly fine to set up doubles, stubs, and message expectations in
a `before(:each)` hook, as that hook is executed in the scope of the example:

    before(:each) do
      @account = double('account')
    end

### Do not create doubles, stubs, or message expectations in `before(:all)`

If you do, they'll get cleaned out after the first example, and you will be
very confused as to what's going on in the second example.