0
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
とスナッククラス内RSpecのスパイ法の問題に
def self.find_or_create(attrs)
snack = find_by_name(attrs[:name])
snack ||= create(attrs)
end
ただし作成は呼ば取得していないようです - 私はこれが期待されていると思い、私が持っていたためととして/任意の考え?説明されていない?私は信じて
は魅力のように働きました!ありがとうございました! – Drew