Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Foreign API Simulation with Sinatra by Konstantin Tennhard Nowadays, we often rely on third party services that we integrate into our product, instead of building every aspect of an application. In many cases, well written API clients exist, but on occasion you run into the issue that there isn't a ready to use client or it simply doesn't fit your needs. How do you write a good API client and more importantly how do you test it without hitting the remote API. So far, the standard approach has been replaying requests with VCR or stubbing them with Webmock. There is a third option: simulating foreign APIs with Sinatra from within your test suite! Help us caption & translate this video! http://amara.org/v/JvLq/
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In this video titled 'Foreign API Simulation with Sinatra,' Konstantin Tennhard presents an innovative approach to testing HTTP connections when building API clients. Traditionally, developers have used libraries like VCR and WebMock to stub API requests, but Tennhard introduces a new method that utilizes Sinatra to create simulated foreign APIs directly within test suites. Key points discussed in the talk include: - **Introduction to Request Interceptor**: Tennhard introduces his library, Request Interceptor, designed to facilitate the testing of HTTP requests without relying on external APIs. - **Comparison with Existing Libraries**: The speaker discusses the limitations of using VCR and WebMock, outlining how Request Interceptor provides a cleaner, more organized approach to defining API interactions. - **How Request Interceptor Works**: The library allows developers to intercept HTTP requests and reroute them to a Rack-compatible application using Sinatra. This provides greater flexibility in simulating different API behaviors. - **Example Implementation**: Tennhard shows a minimal example where a simple Rack app is created to respond to requests that match a specific hostname, showcasing the basic functionality of intercepting API calls. - **Nesting and Customization**: The talk covers advanced features such as nesting multiple interceptors for more complex testing scenarios and customizing the response for specific tests, allowing fine control over what each test needs to simulate. - **Error Simulation**: Another significant advantage of using Request Interceptor is its ability to simulate network errors, gracefully testing an application’s robustness against failures by raising exceptions in predefined scenarios. - **Readable Code**: Tennhard emphasizes the readability of the code created with Sinatra and Request Interceptor compared to traditional stubs, making it easier for developers to understand and maintain their test suites. - **Future Plans**: The talk concludes with Tennhard sharing his plans to enhance Request Interceptor by supporting traits for endpoint simulations and introducing different adapters for compatibility with various libraries. Overall, Konstantin Tennhard's presentation highlights an efficient, organized, and flexible approach to testing API clients, advocating for the use of Sinatra in simulating foreign APIs within the testing frameworks of Ruby applications. This method enhances the clarity and maintainability of the code, ultimately leading to a better development experience.
Suggest modifications
Cancel