Hello, I'm new to busted and am currently trying to understand a bit better how stubbing works as I'm trying to use it via plenary to test a Neovim plugin. I wasn't able to get it to work so I figured I'd just try with vanilla lua and busted, but I still had issues even with the example give on the website. For example on the webiste here.
describe("stubs", function()
it("replaces an original function", function()
local t = {
greet = function(msg) print(msg) end
}
assert.stub(t, "greet")
t.greet("Hey!") -- DOES NOT print 'Hey!'
assert.stub(t.greet).was.called_with("Hey!")
t.greet:revert() -- reverts the stub
t.greet("Hey!") -- DOES print 'Hey!'
end)
end)
I did change stub to assert.stub
When trying this out locally with busted my_spec.lua I'm met with the following error:
❯ busted my_spec.lua
Hey!
✱
0 successes / 0 failures / 1 error / 0 pending : 0.001806 seconds
Error → my_spec.lua @ 2
stubs replaces an original function
/usr/local/share/lua/5.4/luassert/spy.lua:108: attempt to index a function value (local 'payload')
Looking at the code there I don't fully understand what's going on, and I'm hoping there is just something changed about the way you're supposed to stub that the docs aren't explaining. Is there something I'm missing? I'll happily update the docs if so.
System
MacOS Monterey 12.3.1
iTerm 2
fish shell
Lua 5.4.4
Busted 2.0.0-1 ( I see the website docs are for version 2.0.rc12-1 so not sure if there is a difference here)
Hello, I'm new to busted and am currently trying to understand a bit better how stubbing works as I'm trying to use it via plenary to test a Neovim plugin. I wasn't able to get it to work so I figured I'd just try with vanilla lua and busted, but I still had issues even with the example give on the website. For example on the webiste here.
I did change
stub
toassert.stub
When trying this out locally with
busted my_spec.lua
I'm met with the following error:Looking at the code there I don't fully understand what's going on, and I'm hoping there is just something changed about the way you're supposed to stub that the docs aren't explaining. Is there something I'm missing? I'll happily update the docs if so.
System