When using WebMock to stub HTTP requests, one usually checks with an expectation (or assertion) that the correct request is made, i.e. that the correct URL is called with the correct request body. In seldom cases, you might want to fetch a value from a request you do not know otherwise.
Assume you generate a token with generates_token_for
and send that to an API. If you want to test that behavior using a feature spec, you notice that there is no way to access the token from within the feature spec. You could then check the executed WebMock request and fetch the token from the request.
To access the request, use WebMock::RequestRegistry
: