gpt4 book ai didi

arrays - 如何使用 Rspec 检查某物是否为数组?

转载 作者:数据小太阳 更新时间:2023-10-29 07:55:24 26 4
gpt4 key购买 nike

我尝试了以下并得到了相关的错误:

Failure/Error: reminders_array.should be_an(Array)
NoMethodError:
undefined method `should' for #<Array:0x0000000202c9a0>

reminders_array 应该是一个数组,我想用 Rspec 测试来检查它。我应该如何不同于上面测试的断言?

最佳答案

should 是旧语法,你应该这样做:

expect(reminders_array).to be_an(Array) 

或:

expect(reminders_array).to be_an_instance_of(Array)

您可以从 rspec-expectations 获得更多信息

关于arrays - 如何使用 Rspec 检查某物是否为数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33031986/

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