Skip to content

Instantly share code, notes, and snippets.

@thiagokokada
Last active August 15, 2018 02:30
Show Gist options
  • Save thiagokokada/906059587de786a59afef561a784cf08 to your computer and use it in GitHub Desktop.
Save thiagokokada/906059587de786a59afef561a784cf08 to your computer and use it in GitHub Desktop.
defmodule CalculatorTest do
use ExUnit.Case
import ExUnit.CaptureIO
doctest Calculator
describe "+ 1.0" do
defmodule FakeIO do
defdelegate puts(message), to: IO
def gets("operation> "), do: "+ 1.0"
end
test "accumulator should be 1.0" do
run = fn ->
# Simulate two loops of our REPL since the accumulator is
# printed at the start of the call from interpret
Calculator.interpret(0.0, FakeIO)
|> Calculator.interpret(FakeIO)
end
assert capture_io(run) =~ "1.0"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment