Ruby - Testing with RSpec and Minitest
How can you verify that a test double cart received the method add_item with argument 'apple' exactly once?
How can you verify that a test double cart received the method add_item with argument 'apple' exactly once?
expect(...).to receive sets expectation before the method call.receive and once. expect(cart).to have_received(:add_item).with('apple').once checks after call but requires have_received only after call. allow(cart).to receive(:add_item).with('apple').once uses allow which stubs but does not verify. cart.should_receive(:add_item).with('apple').once uses old syntax.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions