Packages

ExDoubles is an opinionated mocking library for Elixir. It takes the stance that the easiest way to create loose coupling in your codebase is to follow the Dependency Inversion Principle (DIP). This framework allows adhoc mocks so that you can emulate edge cases in your tests.

Retired package: Release invalid - Doesn't allow users to compile

Current section

Files

Jump to
exdoubles lib error_messages.ex
Raw

lib/error_messages.ex

defmodule ExDoubles.ErrorMessages do
def not_called_error(name, args, []) do
"#{inspect name} was never called with #{inspect args}"
end
def not_called_error(name, args, calls) do
"""
#{inspect name} was never called with #{inspect args}
but was called with:
#{format_calls(calls)}
"""
end
def arity_not_supported do
"Arity greater than 6 is not supported."
end
def unsupported_call() do
"called_with cannot have more arguments than the mocked function."
end
def call_count_incorrect(expected, actual) do
"expected #{expected} times but was #{actual}"
end
defp format_calls(calls) do
calls
|> Enum.map(fn call -> "#{inspect call}" end)
|> Enum.join("\n")
end
end