vendredi 3 juin 2016

RSpec sequence of returned values AND raised errors from stub

I want to stub first two calls to HTTParty with raised exception and then, the third call, should return value.

   before do
          allow(HTTParty).to receive(:get).exactly(2).times.with(url).and_raise(HTTParty::Error)
          allow(HTTParty).to receive(:get).with(url).and_return('{}')
        end

but one allow override another one. how to set stub to raise errors for first few tries and then let it return a value?

Aucun commentaire:

Enregistrer un commentaire