Skip to content

Instantly share code, notes, and snippets.

@ma2gedev
Last active October 14, 2015 11:07
Show Gist options
  • Select an option

  • Save ma2gedev/b0ad5fb1c81c5804d1d6 to your computer and use it in GitHub Desktop.

Select an option

Save ma2gedev/b0ad5fb1c81c5804d1d6 to your computer and use it in GitHub Desktop.
Use PowerAssert with ExSpec
defmodule PowerAssertWrapper do
defmacro passert(ast, message \\ nil) do
quote do
PowerAssert.Assertion.assert(unquote(ast), unquote(message))
end
end
end
defmodule ExSpecSampleTest do
use ExSpec, async: true
require PowerAssert.Assertion
import PowerAssertWrapper
describe "describe" do
context "context" do
it "it" do
drew = %{first_name: "Drew"}
passert drew.first_name == "Drew Olson"
end
end
end
end
$ mix test
1) test describe context it (ExSpecSampleTest)
test/ex_spec_sample_test.exs:16
drew.first_name() == "Drew Olson"
| |
| "Drew"
%{first_name: "Drew"}
stacktrace:
test/ex_spec_sample_test.exs:19
Finished in 0.08 seconds (0.07s on load, 0.01s on tests)
1 tests, 1 failures
Randomized with seed 425781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment