Skip to content

Commit 9e5ca92

Browse files
committed
Add typespec
1 parent ab24d46 commit 9e5ca92

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/bypass.ex

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ defmodule Bypass do
124124
end)
125125
```
126126
"""
127+
@spec expect(Bypass.t(), (Plug.Conn.t() -> Plug.Conn.t())) :: :ok
127128
def expect(%Bypass{pid: pid}, fun),
128129
do: Bypass.Instance.call(pid, {:expect, fun})
129130

@@ -141,8 +142,9 @@ defmodule Bypass do
141142
end)
142143
```
143144
"""
144-
def expect(%Bypass{pid: pid}, methods, paths, fun),
145-
do: Bypass.Instance.call(pid, {:expect, methods, paths, fun})
145+
@spec expect(Bypass.t(), String.t(), String.t(), (Plug.Conn.t() -> Plug.Conn.t())) :: :ok
146+
def expect(%Bypass{pid: pid}, method, path, fun),
147+
do: Bypass.Instance.call(pid, {:expect, method, path, fun})
146148

147149
@doc """
148150
Expects the passed function to be called exactly once regardless of the route.
@@ -155,6 +157,7 @@ defmodule Bypass do
155157
end)
156158
```
157159
"""
160+
@spec expect(Bypass.t(), (Plug.Conn.t() -> Plug.Conn.t())) :: :ok
158161
def expect_once(%Bypass{pid: pid}, fun),
159162
do: Bypass.Instance.call(pid, {:expect_once, fun})
160163

@@ -172,8 +175,9 @@ defmodule Bypass do
172175
end)
173176
```
174177
"""
175-
def expect_once(%Bypass{pid: pid}, methods, paths, fun),
176-
do: Bypass.Instance.call(pid, {:expect_once, methods, paths, fun})
178+
@spec expect_once(Bypass.t(), String.t(), String.t(), (Plug.Conn.t() -> Plug.Conn.t())) :: :ok
179+
def expect_once(%Bypass{pid: pid}, method, path, fun),
180+
do: Bypass.Instance.call(pid, {:expect_once, method, path, fun})
177181

178182
@doc """
179183
Allows the function to be invoked zero or many times for the specified route (method and path).
@@ -189,8 +193,9 @@ defmodule Bypass do
189193
end)
190194
```
191195
"""
192-
def stub(%Bypass{pid: pid}, methods, paths, fun),
193-
do: Bypass.Instance.call(pid, {:stub, methods, paths, fun})
196+
@spec stub(Bypass.t(), String.t(), String.t(), (Plug.Conn.t() -> Plug.Conn.t())) :: :ok
197+
def stub(%Bypass{pid: pid}, method, path, fun),
198+
do: Bypass.Instance.call(pid, {:stub, method, path, fun})
194199

195200
def pass(%Bypass{pid: pid}),
196201
do: Bypass.Instance.call(pid, :pass)

0 commit comments

Comments
 (0)