gpt4 book ai didi

ruby-on-rails - view.stub (Rails) 的 Rspec 3 升级问题

转载 作者:行者123 更新时间:2023-12-03 15:13:20 25 4
gpt4 key购买 nike

我正在将我的测试升级到 Rspec3(真麻烦),删除了我所有的“应该”,但我不知道如何在我的 View 测试中升级“view.stub”。

我正在使用设计

例子:

view.stub(:current_user) { nil }

render

expect(rendered).to .... etc

这给了我一个弃用警告:

Using stub from rspec-mocks' old :should syntax without explicitly enabling the syntax is deprecated. Use the new :expect syntax or explicitly enable :should instead. Called from ....



我不知道如何升级到新的“改进”语法。
谢谢

最佳答案

allow(view).to receive_messages(current_user: nil)

Notable Changes in RSpec 3

关于ruby-on-rails - view.stub (Rails) 的 Rspec 3 升级问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24171847/

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