Is it possible for RSpec to expect change in two tables?

后端 未结 8 1570
借酒劲吻你
借酒劲吻你 2020-12-09 07:15

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 chan

8条回答
  •  余生分开走
    2020-12-09 08:12

    The best way I've found is to do it "manually":

    counters_before         = Counter.count
    another_counters_before = AnotherCounter.count
    Foo.bar
    expect(Counter.count).to eq (counters_before + 1)
    expect(AnotherCounter.count).to eq (another_counters_before + 1)
    

    Not the most elegant solution but it works

提交回复
热议问题