gpt4 book ai didi

ruby - 在 Rack 应用程序中模拟 Ruby 的 Timeout::timeout

转载 作者:数据小太阳 更新时间:2023-10-29 08:03:30 25 4
gpt4 key购买 nike

我有一个 Sinatra 应用程序。我正在使用 Rack::Test 对其进行测试。我想确保将查询字符串参数传递给 Timeout::timeout()

我认为 expect_any_instance_of(Timeout).to receive(:timeout) 会起作用。

它没有,我只是得到默认的 Exactly one instance should have received the following message(s) but didn't: timeout。我可以亲眼看到,毫无疑问,代码肯定会被调用。

有什么想法吗?

最佳答案

Timeout::timeout - 这是类方法调用,而不是实例方法调用。因此,你应该使用这个:

expect(Timeout).to receive(:timeout)

关于ruby - 在 Rack 应用程序中模拟 Ruby 的 Timeout::timeout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32052255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com