Merge pull request #110 from iamvery/update-agents-koan
Show explicit example of named agents
This commit is contained in:
@@ -2,8 +2,13 @@ defmodule Agents do
|
|||||||
use Koans
|
use Koans
|
||||||
|
|
||||||
koan "Agents maintain state, so you can ask them about it" do
|
koan "Agents maintain state, so you can ask them about it" do
|
||||||
Agent.start_link(fn() -> "Hi there" end, name: __MODULE__)
|
{:ok, pid} = Agent.start_link(fn -> "Hi there" end)
|
||||||
assert Agent.get(__MODULE__, &(&1)) == ___
|
assert Agent.get(pid, &(&1)) == ___
|
||||||
|
end
|
||||||
|
|
||||||
|
koan "Agents may also be named so that you don't have to keep the pid around" do
|
||||||
|
Agent.start_link(fn -> "Why hello" end, name: AgentSmith)
|
||||||
|
assert Agent.get(AgentSmith, &(&1)) == ___
|
||||||
end
|
end
|
||||||
|
|
||||||
koan "Update to update the state" do
|
koan "Update to update the state" do
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ defmodule AgentTests do
|
|||||||
test "Agents" do
|
test "Agents" do
|
||||||
answers = [
|
answers = [
|
||||||
"Hi there",
|
"Hi there",
|
||||||
|
"Why hello",
|
||||||
"HI THERE",
|
"HI THERE",
|
||||||
{:multiple, [["Milk"], ["Bread", "Milk"]]},
|
{:multiple, [["Milk"], ["Bread", "Milk"]]},
|
||||||
false,
|
false,
|
||||||
|
|||||||
Reference in New Issue
Block a user