Packages
espec
0.4.1
1.10.0
1.9.2
1.9.1
1.9.0
1.8.3
1.8.2
1.8.1
1.8.0
1.7.0
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.1
1.5.0
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.2
1.2.1
1.2.0
1.1.2
1.1.1
1.1.0
1.0.1
1.0.0
0.8.28
0.8.27
0.8.26
0.8.25
0.8.24
0.8.23
0.8.22
0.8.21
0.8.20
0.8.19
0.8.18
0.8.17
0.8.16
0.8.15
0.8.14
0.8.13
0.8.12
0.8.11
0.8.10
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.1
0.8.0
0.7.2
0.7.1
0.7.0
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
0.5.1
0.5.0
0.4.2
0.4.1
0.4.0
0.3.7
0.3.5
0.3.0
0.2.0
0.1.0
BDD testing framework for Elixir inspired by RSpec.
Current section
Files
Jump to
Current section
Files
lib/espec/assertion_helpers.ex
defmodule ESpec.AssertionHelpers do
@moduledoc """
Defines helper functions for modules which use ESpec.
These fucntions wraps arguments for ESpec.ExpectTo module.
See `ESpec.Assertion` module for corresponding 'assertion modules'
"""
@elixir_types ~w(atom binary bitstring boolean float function integer list map number pid port reference tuple)a
def eq(value), do: {:eq, value}
def eql(value), do: {:eql, value}
def be(value), do: {:eq, value}
def be(operator, value), do: {:be, [operator, value]}
def be_between(min, max), do: {:be_between, [min, max]}
def be_close_to(value, delta), do: {:be_close, [value, delta]}
def match(value), do: {:match, value}
def raise_exception(exception, message), do: {:raise_exception, [exception, message]}
def raise_exception(exception), do: {:raise_exception, [exception]}
def raise_exception(), do: {:raise_exception, []}
def throw_term(term), do: {:throw_term, [term]}
def throw_term(), do: {:throw_term, []}
def change(func, value), do: {:change_to, [func, value]}
def change(func, before, value), do: {:change_from_to, [func, before, value]}
def have_all(func), do: {:have_all, func}
def have_any(func), do: {:have_any, func}
def have_at(pos, val), do: {:have_at, [pos, val]}
def have_count(val), do: {:have_count, val}
def have_count_by(func, val), do: {:have_count_by, [func, val]}
def have(val), do: {:have, val}
def be_empty, do: {:be_empty, []}
def have_max(value), do: {:have_max, value}
def have_max_by(func, value), do: {:have_max_by, [func, value]}
def have_min(value), do: {:have_min, value}
def have_min_by(func, value), do: {:have_min_by, [func, value]}
def have_first(value), do: {:have_first, value}
def have_last(value), do: {:have_last, value}
def have_hd(value), do: {:have_hd, value}
def have_tl(value), do: {:have_tl, value}
Enum.each @elixir_types, fn(type) ->
def unquote(String.to_atom("be_#{type}"))() do
{:be_type, unquote(Macro.escape(type))}
end
end
def be_nil, do: {:be_type, :null}
def be_function(arity), do: {:be_type, [:function, arity]}
def accepted(func, args \\ :any, opts \\ [pid: :any, count: :any]), do: {:accepted, [func, args, opts]}
end