Skip to content

Commit 019ded2

Browse files
authored
Prepare for release 0.14.0 (#70)
1 parent 75adf31 commit 019ded2

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# Change Log
22

3+
## 0.14.0 (2024-10-15)
4+
5+
Changes where mocks are evaluated to prevent misuse and allow for common patterns that were not previously supported.
6+
7+
Pre-0.14.0 mocks would be intercepted by the `Patch.Mock.Server` and the mock value would be calculated by the server. This works for most cases, but has surprising behavior when the mock function cares about the process executing the function. Consider the following example.
8+
9+
```elixir
10+
defmodule ExampleTest do
11+
use ExUnit.Case
12+
use Patch
13+
14+
test "example" do
15+
patch(Example, :get_pid, fn -> self() end)
16+
17+
assert Example.get_pid() == self()
18+
end
19+
end
20+
```
21+
22+
This would fail in pre-0.14.0 because the `fn -> self() end` would be executed by the `Patch.Mock.Server` and the pid returned would be the pid for the `Patch.Mock.Server` and not the caller's pid as the test author might expect.
23+
24+
0.14.0 changes this behavior and now will execute the `fn -> self() end` in the caller and return the expected result.
25+
26+
This also makes it much more difficult to address the `Patch.Mock.Server` directly, which is generally discouraged as this server is an implementation detail and should only be addressed by the Patch code itself. This should prevent a class of errors and confusing bugs caused by tests accidentally capturing the pid of, monitoring, or linking to the `Patch.Mock.Server`
27+
28+
### Improvements
29+
30+
- ⬆️ - \[Internal\] Mocks are now evaluated in the caller process instead of the `Patch.Mock.Server` process, see above for details.
31+
32+
### Breaking Changes
33+
34+
- 💔 - Mocks are now evaluated in the caller process instead of the `Patch.Mock.Server` process. Using the `Patch.Mock.Server` pid or interacting with the process is not advised but if your tests relied on being able to do this they may break due to this change.
35+
336
## 0.13.1 (2024-05-02)
437

538
Minor bugfix to correct an issue with negative step ranges in `String.slice/2` raised by

mix.exs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Patch.MixProject do
44
def project do
55
[
66
app: :patch,
7-
version: "0.13.1",
7+
version: "0.14.0",
88
elixir: "~> 1.7",
99
erlc_paths: erlc_paths(Mix.env()),
1010
elixirc_paths: elixirc_paths(Mix.env()),
@@ -25,7 +25,7 @@ defmodule Patch.MixProject do
2525
# Run "mix help deps" to learn about dependencies.
2626
defp deps do
2727
[
28-
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
28+
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
2929
]
3030
end
3131

@@ -57,18 +57,18 @@ defmodule Patch.MixProject do
5757
"pages/guide-book/02-patching.md",
5858
"pages/guide-book/03-mock-values.md",
5959
"pages/guide-book/04-spies-and-fakes.md",
60-
"pages/guide-book/05-processes.md",
60+
"pages/guide-book/05-processes.md"
6161
]
6262
],
6363
groups_for_modules: [
6464
"Developer Interface": [
6565
Patch
6666
],
67-
"Listener": [
67+
Listener: [
6868
Patch.Listener,
6969
Patch.Listener.Supervisor
7070
],
71-
"Mock": [
71+
Mock: [
7272
Patch.Mock,
7373
Patch.Mock.History,
7474
Patch.Mock.History.Tagged,
@@ -112,7 +112,7 @@ defmodule Patch.MixProject do
112112
Patch.Mock.Values.Sequence,
113113
Patch.Mock.Values.Throws
114114
],
115-
"Utilities": [
115+
Utilities: [
116116
Patch.Access,
117117
Patch.Apply,
118118
Patch.Assertions,

0 commit comments

Comments
 (0)