Last active
June 6, 2017 13:34
-
-
Save coline-carle/f8992e44a0f3dc0a5b752ea82190ff73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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