Skip to content

Instantly share code, notes, and snippets.

@coline-carle
Last active June 6, 2017 13:34
Show Gist options
  • Save coline-carle/f8992e44a0f3dc0a5b752ea82190ff73 to your computer and use it in GitHub Desktop.
Save coline-carle/f8992e44a0f3dc0a5b752ea82190ff73 to your computer and use it in GitHub Desktop.
defmodule Test.Behaviour do
@doc "Define The Behaviour"
@callback handle_something(String.t) :: String.t
end
defmodule Test.Util do
def handle_general_case("general_special") do
"return something general but special"
end
def handle_general_case(_) do
"return something general"
end
end
defmodule Test.Special do
alias Test.Util
@behaviour Test.Behaviour
def handle_something("special") do
"return something special"
end
def handle_something(param) do
Util.handle_general_case(param)
end
end
defmodule Test.SpecialTest do
use ExUnit.Case, async: true
test "General Case" do
assert Test.Special.handle_something("general") == "return something general"
end
test "Special Case" do
assert Test.Special.handle_something("special") == "return something special"
end
test "General but special case" do
assert Test.Special.handle_something("general_special") == "return something general but special"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment