Module: FulfilApi::TestHelper
- Defined in:
- lib/fulfil_api/test_helper.rb
Overview
The TestHelper module provides utility methods for stubbing HTTP requests to the Fulfil API in test environments. It uses WebMock to intercept and simulate API requests, allowing developers to test how their code interacts with the Fulfil API without making real HTTP requests.
This module is designed to be included in test cases where you need to simulate API interactions. It offers a flexible interface to stub requests for various models and resources, making it easier to write comprehensive and isolated tests.
Instance Method Summary collapse
-
#stub_fulfil_request(method, response: {}, status: 200, **options) ⇒ WebMock::RequestStub
Stubs an HTTP request to the Fulfil API based on the provided parameters.
Instance Method Details
#stub_fulfil_request(method, response: {}, status: 200, **options) ⇒ WebMock::RequestStub
Stubs an HTTP request to the Fulfil API based on the provided parameters.
39 40 41 42 |
# File 'lib/fulfil_api/test_helper.rb', line 39 def stub_fulfil_request(method, response: {}, status: 200, **) stubbed_request_for(method, **) .and_return(status: status, body: response.to_json, headers: { "Content-Type": "application/json" }) end |