Im still trying to adapt to the dynamically typed nature of elixir and I have a doubt about testing a function that has a guard
def new(id) where is_integer(id)
so how do I write a test for it?
I can test it when id is a integer pretty easy,
but I would like to write a test when id is not an integer
Im asking because I can call
new("hello") in the code and mix compile doesn’t cry at all
so Im guessing this will blowup in runtime.
when I pass a string in test I get
** (FunctionClauseError) no function clause matching in Dealer.new/1
and test fails (expected) and shows a stacktrace
What is the common practice here?
since Im still struggling with “when to use guards” any tips are appreciated as well