我正在编写一些代码并使用 rspec 但收到警告,提示语法已过时,我不太清楚应该如何编写它?
it "should calculate the value correctly" do
mock_cards = [Card.new(:clubs, 5), Card.new(:diamonds, 10)]
hand = Hand.new
hand.stub(:cards) { cards } #stub out cards and have it return cards
expect(hand.value).to eq (15)
end
错误信息如下: 使用stub
来自 rspec-mocks 的旧版本:should
不推荐使用未显式启用语法的语法。使用新的:expect
语法或显式启用:should
反而。
这样做:
allow(hand).to receive(:cards) { cards }
https://github.com/rspec/rspec-mocks#method-stubs https://github.com/rspec/rspec-mocks#method-stubs
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)