You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Matchers are used to provide flexible argument matching for `called_with` and `returned_with` asserts. Just like with asserts, you can chain a modifier value using `is` or `is_not`, followed by the matcher you wish to use. Extending busted with your own matchers is done similar to asserts as well; just build a matcher with a common signature and [register it](#matcher-extend). Furthermore, matchers can be combined using [composite matchers](#matcher-composite).
5
+
]]
6
+
---@classluassert_match
7
+
localmatch= {}
8
+
9
+
--- this is a `placeholder`, match any thing
10
+
--[[
11
+
```lua
12
+
it("tests wildcard matcher", function()
13
+
local s = spy.new(function() end)
14
+
local _ = match._
15
+
16
+
s("foo")
17
+
18
+
assert.spy(s).was_called_with(_) -- matches any argument
19
+
assert.spy(s).was_not_called_with(_, _) -- does not match two arguments
20
+
end)
21
+
```]]
22
+
match._= {}
23
+
24
+
--[[
25
+
If you're creating a spy for functions that mutate any properties on an table (for example `self`) and you want to use `was_called_with`, you should use `match.is_ref(obj)`.
26
+
```lua
27
+
describe("combine matchers", function()
28
+
local match = require("luassert.match")
29
+
30
+
it("tests ref matchers for passed in table", function()
0 commit comments