Stubbing API responses

Has anyone been successful with ways to mock or stub responses from the API for unit tests? For instance, I have some code that responds differently based on whether they are active maintenance windows or not and I’ll like to be able to test both branches.

Specifically looking for Ruby solutions, but since it’s REST calls, probably non-Ruby solutions could be converted.