Net::HTTP
There are many ways to use Net::HTTP. The scenarios below provide regression tests for some Net::HTTP APIs that have not worked properly with VCR and WebMock in the past (but have since been fixed).
Background ()
Given a file named "vcr_setup.rb" with:
Calling #post on new Net::HTTP instance
Given a file named "vcr_net_http.rb" with:
When I run ruby vcr_net_http.rb --with-server
Then the output should contain "VCR works with Net::HTTP posts!"
And the file "cassettes/net_http.yml" should contain "VCR works with Net::HTTP posts!"
When I run ruby vcr_net_http.rb
Then the output should contain "VCR works with Net::HTTP posts!".
Examples
Return from yielded block
Given a file named "vcr_net_http.rb" with:
When I run ruby vcr_net_http.rb --with-server
Then the output should contain "VCR works with Net::HTTP gets!"
And the file "cassettes/net_http.yml" should contain "VCR works with Net::HTTP gets!"
When I run ruby vcr_net_http.rb
Then the output should contain "VCR works with Net::HTTP gets!".
Examples
Use Net::ReadAdapter to read body in fragments
Given a file named "vcr_net_http.rb" with:
When I run ruby vcr_net_http.rb --with-server
Then the output should contain "VCR works with Net::HTTP gets!"
And the file "cassettes/net_http.yml" should contain "VCR works with Net::HTTP gets!"
When I run ruby vcr_net_http.rb
Then the output should contain "VCR works with Net::HTTP gets!".
Examples
Use open-uri (which is built on top of Net::HTTP and uses a seldom-used Net::HTTP API)
Given a file named "vcr_net_http.rb" with:
When I run ruby vcr_net_http.rb --with-server
Then the output should contain "VCR works with Net::HTTP gets!"
And the file "cassettes/net_http.yml" should contain "VCR works with Net::HTTP gets!"
When I run ruby vcr_net_http.rb
Then the output should contain "VCR works with Net::HTTP gets!".
Examples
Make an HTTPS request
Given a file named "vcr_https.rb" with:
When I run ruby vcr_https.rb
Then the output should contain "VCR gist"
And the file "cassettes/https.yml" should contain "VCR gist"
When I modify the file "cassettes/https.yml" to replace "VCR gist" with "HTTPS replaying works"
And I run ruby vcr_https.rb
Then the output should contain "HTTPS replaying works".
Examples
Last updated