Faraday middleware
VCR provides middleware that can be used with Faraday. You can use this as an alternative to Faraday's built-in test adapter.
VCR will automatically insert this middleware in the Faraday stack when you configure hook_into :faraday
. However, if you want to control where the middleware goes in the faraday stack, you can use it yourself. The middleware should come before the Faraday HTTP adapter.
Note that when you use the middleware directly, you don't need to configure hook_into :faraday
.
Use Faraday middleware
Given a file named "faraday_example.rb" with:
When I run ruby faraday_example.rb
Then the output should contain:
And the file "cassettes/example.yml" should contain "Hello foo 1".
Examples
adapter | extra_require |
net_http | |
typhoeus | require 'typhoeus/adapters/faraday' |
Last updated