Add an agent to keep track of completed koans

This commit is contained in:
Felipe Sere
2016-04-24 12:59:55 +01:00
parent 143040c0a0
commit c9ee4dbae0
2 changed files with 49 additions and 0 deletions

25
test/tracker_test.exs Normal file
View File

@@ -0,0 +1,25 @@
defmodule TrackerTest do
use ExUnit.Case
@sample_modules [SampleKoan, PassingKoan]
test "can start" do
Tracker.start(@sample_modules)
assert Tracker.get == %{total: 2, current: 0}
end
test "can be notified of completed koans" do
Tracker.start(@sample_modules)
Tracker.completed(:"Hi there")
assert Tracker.get == %{total: 2, current: 1}
end
test "multiple comletions of the same koan count only once" do
Tracker.start(@sample_modules)
Tracker.completed(:"Hi there")
Tracker.completed(:"Hi there")
Tracker.completed(:"Hi there")
Tracker.completed(:"Hi there")
assert Tracker.get == %{total: 2, current: 1}
end
end