From a78dab76cf9a157b143da4df3e647afcd39943b8 Mon Sep 17 00:00:00 2001 From: Pavel Lishin <296084+pavellishin@users.noreply.github.com> Date: Fri, 16 Nov 2018 14:41:08 -0500 Subject: [PATCH] Update ExUnit cheatsheet: Demonstrate named setup context more clearly (#850) --- exunit.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/exunit.md b/exunit.md index 01bff979c..0e2bac7fa 100644 --- a/exunit.md +++ b/exunit.md @@ -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 + + ```