Skip to content

Commit

Permalink
💚 Add tests for
Browse files Browse the repository at this point in the history
  • Loading branch information
ImNotAVirus committed Aug 26, 2019
1 parent da17f92 commit 23e1009
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/lib/elven_gard/protocol_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
defmodule ElvenGard.ProtocolTest do
use ExUnit.Case

defmodule BasicType do
use ElvenGard.Type

@impl ElvenGard.Type
def encode(val, _opts), do: val

@impl ElvenGard.Type
def decode(val, _opts), do: val
end

describe "Protocol raise error if:" do
test "encode/1 is not defined" do
needle = ~r"function encode/1 required by behaviour"

assert_raise RuntimeError, needle, fn ->
defmodule Test do
use ElvenGard.Protocol

def decode(x), do: x
end
end
end

test "decode/1 is not defined" do
needle = ~r"function decode/1 required by behaviour"

assert_raise RuntimeError, needle, fn ->
defmodule Test do
use ElvenGard.Protocol

def encode(x), do: x
end
end
end
end
end

0 comments on commit 23e1009

Please sign in to comment.