RSpec预期变化:
it "should increment the count" do
expect{Foo.bar}.to change{Counter.count}.by 1
end
有没有一种方法可以让两张桌子发生变化?
expect{Foo.bar}.to change{Counter.count}.by 1
and change{AnotherCounter.count}.by 1
RSpec预期变化:
it "should increment the count" do
expect{Foo.bar}.to change{Counter.count}.by 1
end
有没有一种方法可以让两张桌子发生变化?
expect{Foo.bar}.to change{Counter.count}.by 1
and change{AnotherCounter.count}.by 1
这应该是两个测试.RSpec best practices call for one assertion per test
describe "#bar" do
subject { lambda { Foo.bar } }
it { should change { Counter.count }.by 1 }
it { should change { AnotherCounter.count }.by 1 }
end