👋
In my testing, it looks like patching does not work if a method is called from within a string interpolation expression. I took a look at the "limitations" section of the docs, and didn't see this mentioned, so I think it's a bug.
Module:
defmodulePatchtestdodefgreet()do"Hello, world!"enddefformat_greeting_1()dogreeting=greet()"The program says: #{greeting}"enddefformat_greeting_2()do"The program says: #{greet()}"endendTest:
defmodulePatchtestTestdouseExUnit.CaseusePatchdoctestPatchtesttest"greets the world"dopatch(Patchtest,:greet,"Hello, patched!")assertPatchtest.format_greeting_1()=="The program says: Hello, patched!"assertPatchtest.format_greeting_2()=="The program says: Hello, patched!"endend
This fails with:
1) test greets the world (PatchtestTest)
test/patchtest_test.exs:6
Assertion with == failed
code: assert Patchtest.format_greeting_2() == "The program says: Hello, patched!"
left: "The program says: Hello, world!"
right: "The program says: Hello, patched!"
stacktrace:
test/patchtest_test.exs:10: (test)
👋
In my testing, it looks like patching does not work if a method is called from within a string interpolation expression. I took a look at the "limitations" section of the docs, and didn't see this mentioned, so I think it's a bug.
Module:
Test:
This fails with: