【发布时间】:2015-03-18 23:18:59
【问题描述】:
我正在编写一些代码并使用 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
错误消息如下:使用来自 rspec-mocks 的旧 :should 语法的 stub 而不显式启用该语法已被弃用。改用新的:expect 语法或显式启用:should。
【问题讨论】: