Last active
October 14, 2015 11:07
-
-
Save ma2gedev/b0ad5fb1c81c5804d1d6 to your computer and use it in GitHub Desktop.
Use PowerAssert with ExSpec
This file contains hidden or 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 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 |
This file contains hidden or 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
| $ 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