File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -336,6 +336,32 @@ defmodule ExUnit.AssertionsTest do
336
336
"Expected exception SyntaxError but got FunctionClauseError (no function clause matching in :lists.flatten/1)" = error . message
337
337
end
338
338
339
+ test "assert raise comparing messages (for equality)" do
340
+ assert_raise RuntimeError , "foo" , fn ->
341
+ raise RuntimeError , "bar"
342
+ end
343
+ rescue
344
+ error in [ ExUnit.AssertionError ] ->
345
+ "Wrong message for RuntimeError" <>
346
+ "\n Expected:" <>
347
+ "\n \" foo\" " <>
348
+ "\n Got:" <>
349
+ "\n \" bar\" " = error . message
350
+ end
351
+
352
+ test "assert raise comparing messages (with a regex)" do
353
+ assert_raise RuntimeError , ~r/ ba[zk]/ , fn ->
354
+ raise RuntimeError , "bar"
355
+ end
356
+ rescue
357
+ error in [ ExUnit.AssertionError ] ->
358
+ "Wrong message for RuntimeError" <>
359
+ "\n Expected:" <>
360
+ "\n ~r/ba[zk]/" <>
361
+ "\n Got:" <>
362
+ "\n \" bar\" " = error . message
363
+ end
364
+
339
365
test "assert greater than operator" do
340
366
true = assert 2 > 1
341
367
end
You can’t perform that action at this time.
0 commit comments