I am writing some code and using rspec but received a warning that the syntax is old and i can't quite figure out how i should be writing it instead?
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
The error message is as follows: Using stub
from rspec-mocks' old :should
syntax without explicitly enabling the syntax is deprecated. Use the new :expect
syntax or explicitly enable :should
instead.
Do it like this instead:
allow(hand).to receive(:cards) { cards }