Foreign API Simulation with Sinatra
summary
Proposes using Sinatra interceptor apps to simulate foreign APIs instead of scattering VCR or Webmock stubs, claiming a single-file, readable service definition plus per-test customize and nesting of interceptors. Implements this by overriding net/http start/finish/request to route matching hosts to Rack::MockRequest/Rack::MockResponse, logs transactions for assertions, and deliberately propagates exceptions (disable show_exceptions enable raise_errors) to simulate host unreachable; roadmap includes Faraday adapter and reusable interceptor traits.
AI-written summary · about
chapters (16)
- 0:00Intro
- 3:40Request Interceptor and Rack
- 5:35Sinatra Basics
- 6:45Request Interceptor Definition
- 7:49Intercepting HTTP Request
- 8:25Request Logging
- 8:52Asserting on the Request and Response Data
- 10:52Customizing Request Interceptors
- 14:43Simulating Network Errors
- 16:10Utilizing Advanced Sinatra Features
- 17:59Request Interceptor Core
- 19:48Caching the Original Methods
- 20:48Overriding Methods
- 21:38Requestinterceptor request
- 23:58Restoring the Original Methods
- 25:24Error Propagation








