RSpec“全部更改”匹配器
我有一些更新记录的工作,我想要类似的东西:
it 'updates each record' do
expect {
described_class.perform_now
}.to(change_all_of{
Record.pluck(:updated_at)
})
end
只是我找不到任何看起来像如何完成此操作的东西,或我可以识别为如何编写的文档自定义匹配器。
问题是,如果任何元素发生更改,数组上的change
将返回true;我只想在每个元素发生变化时返回 true。
任何人都可以指出我错过的任何可以让我这样做的内容,或者我需要编写自己的 change
匹配器的任何文档/信息吗?
I've got some job that updates records, and I want something like:
it 'updates each record' do
expect {
described_class.perform_now
}.to(change_all_of{
Record.pluck(:updated_at)
})
end
Only I can't find anything that looks like how to accomplish this, or what I can recognize as the docs for how to write a custom matcher.
The issue is that change
, on an array, will return true if any element has changed; I only want to return true if every element has changed.
Can anyone point me either at whatever I missed that would let me do this, OR, whatever docs/info I need to write my own change
matcher?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,感谢这个答案在另一个问题上,并盯着实际代码,这是我的得到了 -
欢迎提出建议!
Alright, thanks to this answer on another question, and staring at the actual code, here's what I've got -
Suggestions welcome!