RSpec 是否有可能期望在两个表中发生变化? [英] Is it possible for RSpec to expect change in two tables?
本文介绍了RSpec 是否有可能期望在两个表中发生变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
RSpec 期望改变:
RSpec expect change:
it "should increment the count" do
expect{Foo.bar}.to change{Counter.count}.by 1
end
有没有办法期待两个表的变化?
Is there a way to expect change in two tables?
expect{Foo.bar}.to change{Counter.count}.by 1
and change{AnotherCounter.count}.by 1
推荐答案
这应该是两个测试.RSpec 最佳实践要求每个测试一个断言.
describe "#bar" do
subject { lambda { Foo.bar } }
it { should change { Counter.count }.by 1 }
it { should change { AnotherCounter.count }.by 1 }
end
这篇关于RSpec 是否有可能期望在两个表中发生变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文