Probably you have run into this: if you have slightly more complex tests
than testing the output of a single function, you need assignment and then
assert that assignment with an operator. Consider this controller test in
phoenix:
conn =
build_conn()
|> post("/upload_content_cover", params)
assert %{"success" => true} = json_response(conn, 200)
with an `assert_match` function this translates to the following:
build_conn()
|> post("/upload_content_cover", params)
|> json_response(conn, 200)
|> assert_match(%{"success" => true})
I prefer the latter, because it is more declarative.
My issue with using operators in assertions, is that while improving
readability in some cases, they are not very functional constructs, and
thus do not compose well. Having a functional equivalent for the
assertions, makes sense in a functional language in my opinion.
I can also see why this should be a library, keeping the assertion library
less complex. Just would like to share my thinking. I'm also interested in
feedback, and how I might be wrong :).
See the following pull request for an
implementation: https://github.com/elixir-lang/elixir/pull/5259.
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/26f11166-0b29-47e0-9707-93c89361e86b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.