0

次のメッセージに応答するためにオブジェクトAをパラメーター1でスタブ化し、 "B"文字列を返します。

describe "some situation" do
  before do
    A = double("Some Object")
    A.stub(:next).with(1).and_return("B")
  end

  it "passes" do
    expect(A.next(1)).to eq(B)    
  end
end

A.stub(:next).with(1).and_return("B")新しい rspec 構文で行を書きたいのですが、その部分A.allow...を追加する場所が見つかりませんでしたwith

4

1 に答える 1

0

新しい構文は次のように機能します。

allow(A).to receive(:next).with(1).and_return("B")
于 2014-11-17T20:39:24.333 に答える