Update ExUnit cheatsheet: Demonstrate named setup context more clearly (#850)

This commit is contained in:
Pavel Lishin 2018-11-16 14:41:08 -05:00 committed by chad d
parent 05bca6d01c
commit a78dab76cf
1 changed files with 13 additions and 4 deletions

View File

@ -85,13 +85,22 @@ end
```elixir
describe "a block" do
setup [:my_hook]
defp my_hook(_context) do
# Invoked in every block in "a block"
{:ok, name: "John", age: 54}
end
defp my_hook(context) do
# Invoked in every block in "a block"
describe "a block" do
setup [:my_hook]
test "John's age", context do
assert context[:name] == "John"
assert context[:age] == 54
end
end
```