Skip to content

Commit a094d52

Browse files
committed
Merge pull request #2163 from giovannibonetti/patch-1
Update docs: :all => :context, :each => :example
1 parent 1db61c0 commit a094d52

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

features/Transactions.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ simply tell RSpec to tell Rails not to manage transactions:
2323
config.use_transactional_fixtures = false
2424
end
2525

26-
### Data created in `before(:each)` are rolled back
26+
### Data created in `before(:example)` are rolled back
2727

28-
Any data you create in a `before(:each)` hook will be rolled back at the end of
28+
Any data you create in a `before(:example)` hook will be rolled back at the end of
2929
the example. This is a good thing because it means that each example is
3030
isolated from state that would otherwise be left around by the examples that
3131
already ran. For example:
3232

3333
describe Widget do
34-
before(:each) do
34+
before(:example) do
3535
@widget = Widget.create
3636
end
3737

@@ -48,34 +48,34 @@ The `@widget` is recreated in each of the two examples above, so each example
4848
has a different object, _and_ the underlying data is rolled back so the data
4949
backing the `@widget` in each example is new.
5050

51-
### Data created in `before(:all)` are _not_ rolled back
51+
### Data created in `before(:context)` are _not_ rolled back
5252

53-
`before(:all)` hooks are invoked before the transaction is opened. You can use
53+
`before(:context)` hooks are invoked before the transaction is opened. You can use
5454
this to speed things up by creating data once before any example in a group is
5555
run, however, this introduces a number of complications and you should only do
5656
this if you have a firm grasp of the implications. Here are a couple of
5757
guidelines:
5858

59-
1. Be sure to clean up any data in an `after(:all)` hook:
59+
1. Be sure to clean up any data in an `after(:context)` hook:
6060

61-
before(:all) do
61+
before(:context) do
6262
@widget = Widget.create!
6363
end
6464

65-
after(:all) do
65+
after(:context) do
6666
@widget.destroy
6767
end
6868

6969
If you don't do that, you'll leave data lying around that will eventually
7070
interfere with other examples.
7171

72-
2. Reload the object in a `before(:each)` hook.
72+
2. Reload the object in a `before(:example)` hook.
7373

74-
before(:all) do
74+
before(:context) do
7575
@widget = Widget.create!
7676
end
7777

78-
before(:each) do
78+
before(:example) do
7979
@widget.reload
8080
end
8181

0 commit comments

Comments
 (0)