我正在运行以下 rspec 测试
expect(City.first.city_openings('2014-05-01', '2014-05-05')).to include(@listing2,@listing3)
我得到这个结果
这让我感到困惑,因为我的结果似乎确实包含正确的值。但是 rspec 说我的结果“不响应包含?”有想法该怎么解决这个吗?我在任何地方都看不到它。
最佳答案
您的方法 city_openings 返回 true 而不是数组。 TrueClass 不能用 include 迭代吗?方法。
在此处查看文档
https://relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/include-matcher
https://relishapp.com/rspec/rspec-expectations/v/3-7/docs/built-in-matchers/match-matcher
关于ruby-on-rails - RSpec 错误 : 'but it does not respond to ` include ?`' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47257802/