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 回答