【发布时间】:2013-11-28 22:16:46
【问题描述】:
当我使用 stub_chain 运行测试时,我会收到弃用警告。
describe "stubbing a chain of methods" do
subject { Object.new }
context "given symbols representing methods" do
it "returns the correct value" do
subject.stub_chain(:one, :two, :three).and_return(:four)
expect(subject.one.two.three).to eq(:four)
end
end
end
弃用警告:
不推荐使用 rspec-mocks 的旧 :should 语法中的 stub_chain 而不显式启用该语法。改用新的:expect 语法或显式启用:should。
如何避免这个警告?
【问题讨论】:
标签: ruby-on-rails rspec