Ruby 存根和rspec旧语法问题

Ruby 存根和rspec旧语法问题,ruby,rspec,stubs,Ruby,Rspec,Stubs,我正在编写一些代码并使用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 ret

我正在编写一些代码并使用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 mock的old:should语法中的存根而不显式启用该语法。使用新的:expect语法或显式启用:should

改为这样做:

allow(hand).to receive(:cards) { cards }