Questions tagged [vcr]

VCR is a ruby tool that facilitates testing HTTP-dependent code by recording HTTP interactions for future playback.

For more information: https://github.com/vcr/vcr

178 questions
2
votes
0 answers

VCR cassette with empty body returns nil instead instead of empty string

I have an API that I'm trying to write some specs on and mock out the requests using the VCR gem. The issue I'm having is that when the API returns an empty body, Ruby interprets this as a empty string. However when I use VCR to generate a cassette…
Travis
  • 13,311
  • 4
  • 26
  • 40
2
votes
1 answer

Can't filter sensitive data with VCR

I've got the following in my spec_helper c.filter_sensitive_data("") { keys['s3_key'] } c.filter_sensitive_data("") { keys['s3_secret'] } Yet when I run my spec I find that it creates the following entry in the…
stephenmurdoch
  • 34,024
  • 29
  • 114
  • 189
2
votes
1 answer

Can I log the unhandled VCR request body?

I'm using the VCR gem to mock HTTP queries. I've recorded cassettes, but then I had to change some stuff around, and now I'm getting an error: An HTTP request has been made that VCR does not know how to handle: POST…
art-solopov
  • 4,289
  • 3
  • 25
  • 44
2
votes
2 answers

VCR with webmock blocking my rspec

I have a problem with my vcr with webmock spec. I have all the time the same problem when i run rspec spec/ .rvm/gems/ruby-2.1.3/gems/webmock-1.18.0/lib/webmock/http_lib_adapters/net_http.rb:114:in `request': Real HTTP connections are disabled.…
Panczo
  • 424
  • 5
  • 20
2
votes
2 answers

Restricting VCR to specs

Is there a way to make VCR active only when called via rspec in a Rails app? It works great for my tests, but I don't want it to intercept requests when outside of those tests. I get Real HTTP connections are disabled if I use a client to connect…
marcantonio
  • 958
  • 10
  • 24
2
votes
0 answers

Testing error callback from Delayed::Job with RSpec

all, I have a custom Delayed::Job setup that uses the the success and error callbacks to change the attributes of the object that is being modified in the background. This object is interacting with an external API. To test this, I'm using RSpec…
Andrew Anderson
  • 441
  • 4
  • 14
2
votes
1 answer

VCR+rspec metadata: how to use inferred cassette name like use_vcr_cassette

The VCR testing gem provides a macro called use_vcr_cassette that has a handy convention to infer the cassette name based on the example name. Since the use_vcr_cassette macro is deprecated in the latest versions of VCR in favor of rspec metadata…
Ken Liu
  • 22,503
  • 19
  • 75
  • 98
2
votes
1 answer

Remove VCR/Webmock logs from stdout when running tests

On a standard Rails 3.2.19 project, when running tests with RSpec I'm getting these logs on stdout when using VCR cassettes: Request[post]: https://svcs.sandbox.paypal.com/AdaptivePayments/Pay …
alf
  • 18,372
  • 10
  • 61
  • 92
2
votes
1 answer

Set default options in VCR based on request URI

On all specs with requests to example.com I want to ignore the trailing id in the URI with respect the request matcher. Something like this. VCR.configure do |c| # omitted c.register_request_matcher :uri_ignoring_trailing_id do |request_1,…
Minimul
  • 4,060
  • 2
  • 21
  • 18
2
votes
1 answer

VCR do not want to handle requests inside before and after hooks.

I developed a ruby wrapper for one HTTP REST API, using rspec with vcr for testing my requests. Project is loaded to travis-ci.org, which automatiacly runs tests all the time. I have a problem inside my test. VCR can't handle requests inside before…
user1291365
  • 516
  • 1
  • 4
  • 16
2
votes
3 answers

in python unit test using vcr, can we use one function to generate different cassettes files?

vcrpy is the python record/play package, below is the common way from the guideline class TestCloudAPI(unittest.TestCase): def test_get_api_token(self): with vcr.use_cassette('fixtures/vcr_cassettes/test_get_api_token.yaml'): …
Larry Cai
  • 55,923
  • 34
  • 110
  • 156
2
votes
0 answers

How to record requests during testing Javascript crawler (Capybara + Poltergeist) in Ruby?

I am using Capybara + Poltergeist as replacement for Mechanize. Mechanize doesn't support Javascript and I want to scrap page which heavily uses JS and iframes. I am using similiar approach to…
nothing-special-here
  • 11,230
  • 13
  • 64
  • 94
2
votes
0 answers

Issue with using vcr and guard jasmine in rspec

In a rails project using rspec, I have had guard jasmine running jspecs for a while. But I just included vcr for some regular specs and when I did, it broke jasmine. 09:23:13 - ERROR - Jasmine test runner isn't available: Real HTTP connections are…
2
votes
1 answer

VCR runs only one time for integration test in capybara with selenium webkit

I am using Rspec with Capybara running the integrational tests using VCR gem to mock stub the api requests. I am facing a vary weird kind of an issue. The test runs successfully for the first time and creates the yaml file for saving the requests…
2
votes
1 answer

How to record http interactions in ruby vcr?

I am working in Rails project which uses below gems. gem "webmock", "1.6.1" gem "vcr", "1.4.0" Already few http interactions are recorded in test_data.yml. I have implemented new business logic and I tried to record the http interactions. But its…
Soundar Rathinasamy
  • 6,658
  • 6
  • 29
  • 47