Difference between Mocks and Stubs in RSpec

What is the difference, how and when to apply?

Stub

allow(object).to receive(:method_name)
allow(object).to receive(:method_name).and_return(example_value)

Mock

expect(object).to receive(:method_name)
expect(object).to receive(:method_name).and_return(example_value)

Double

describe UpdateObject do
let(:external_api) { double }
before do
allow(ExternalApi).to recieve(:new).and_return(external_api)
allow(external_api).to recieve(:some_api_call)
end
it 'returns success' do
expect(subject.call).to eq(:success)
end
end

Software Engineer. Interested in Full-Stack Development and DevOps.