1
2
Fizz
4
Buzz
val it : seq<unit> = seq [(); (); (); (); ...]
并在Snack类中
it "calls #create if #find_or_create is called and no matching record exists" do
snack = class_spy(Snack, find_by_name: nil)
attrs = {name: 'test', location: 'test'}
snack.find_or_create(attrs)
expect(snack).to have_received(:create).with(attrs)
end
然而,创造似乎没有被召唤 - 我猜这是预期的吗?/关于我没有考虑到的任何想法?
答案 0 :(得分:1)
我相信,你可以这样做:
it 'whatewer' do
expect(Snack).to receive(:create).with(attrs)
Snack.find_or_create(attrs)
end