I want to use a rspec to simulate a flakey service handling.
For that, I want to make the service call raise an exception for a few times and after those times to return the real value.
Is this possible with rspec?
I tried with
allow(Service).to receive(:run).once.and_raise(MyError)
allow(Service).to receive(:run).once.and_return(response)
but on the first run it returns the response and not the error