vendredi 25 décembre 2020

How to mock or stub an external request, not necessarily an http one?

I want to mock or stub an external request. It’s not a simple HTTP request and there’s no direct access to an underlying library, nor information of how it’s implemented under the hood, therefore it should be treated as some external request that can be http, file, database. A simplified code is as follows:

def my_external_call
  Lib1::get_some_data()
end

I know what my_external_call() can return. How do I mock or stub it?

Aucun commentaire:

Enregistrer un commentaire