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
5
votes
2 answers

How to stub external javascript libraries when writing Rails integration tests/specs?

My app interfaces with Google Maps for geocoding and Stripe for payments. Using VCR I've mocked all requests to these services, which works great. But the libraries for both are still being loaded in javascript_include_tags. What's the best way…
Gavin
  • 4,273
  • 3
  • 27
  • 39
4
votes
1 answer

How to stop VCR from overwriting erb in the cassettes

We've recently started using VCR to stub requests in our cucumber tests. We're using cucumber tables to describe different kinds of requests, and storing them as variables with gherkin. Our cassette files have all been reworked to include erb, so…
Ziggy
  • 21,845
  • 28
  • 75
  • 104
4
votes
1 answer

Run Specs With VCR without explicitly specifying the cassette name

I have capybara feature specs I intend running without explicitly specifying a cassette name. E.g: scenario "by searching via a title" do visit root_path fill_in "search", with: "cheddar" find(".search-btn").click …
4
votes
0 answers

Is it possible to persist VCR cassettes generated from tests run on CircleCI

We are using VCR to record http requests for our tests in a Rails application. The cassettes are currently committed to source, and every month we rerecord the cassettes manually and commit the new responses to source. We are using CircleCI to run…
4
votes
2 answers

VCR: "There is currently no cassette in use." when creating a second cassette

I'm attempting to do RSpec feature tests on an external API. My VCR config is as follows: VCR.configure do |config| config.cassette_library_dir = 'spec/vcr' config.hook_into :webmock config.ignore_localhost = true end My test looks like…
Tristan
  • 43
  • 4
4
votes
1 answer

How to assert HTTP request is made with correct URI when using VCR and WebMock?

I am testing a Ruby on Rails project using WebMock and VCR. I would like to assert that a request is made to the correct host, but I can't find an example of how to do that. Here's some pseudo-code for what I'm trying to do:…
Andrew
  • 227,796
  • 193
  • 515
  • 708
4
votes
1 answer

How to tell if VCR is in record or playback mode?

I'm using VCR with RSpec to unit test a section of API code, and I've hit a small challenge. My client code uses sleep to rate limit API requests. Thanks to this elegant solution, I can now intercept the sleep message with a stub from my unit…
Chris Tonkinson
  • 13,823
  • 14
  • 58
  • 90
4
votes
1 answer

VCR unhandled http request error

My specs will pass in master branch. If I create a new branch and modify some code completely unrelated to the subscriptions, they'll fail with this. The only way I can get them to pass is to change my vcr.rb to have :record => :new_episodes. If I…
3
votes
0 answers

Simple example for omniauth-facebook, devise, capybara, capybara-mechanize, vcr, rpsec integration test?

I'm looking for a simple example for a omniauth-facebook, devise, capybara, capybara-mechanize, (maybe with VCR), and rpsec integration test... Capybara can't connect to to an external website. So capybara-mechanize would be needed. Maybe VCR could…
justingordon
  • 12,553
  • 12
  • 72
  • 116
3
votes
1 answer

How can I set a VCR global cassette for model geocoding?

I have a user model with a gym association. Gyms use the google api via the geocoder gem for geocoding which is done after_save. In my gym specs, I was able to add use_vcr_cassette to have the request recorded and specs passing. The issue now is…
Eric M.
  • 5,399
  • 6
  • 41
  • 67
3
votes
0 answers

VCR not playing well with CircleCI

We are using VCR to record http requests for our tests in a Rails application. The cassettes are currently committed to source but CircleCI does not seem to use them as CircleCI makes new requests everytime. Tests are passing on local environement.…
Snake
  • 1,157
  • 1
  • 10
  • 21
3
votes
0 answers

Possible to load VCR cassette inside before(:create) in factory_bot Factory?

I am trying to stub a call that is made when validating a connection made based on settings during the create process on my model. Disabling the callbacks seems messy as it means maintaining several instances of the callback (likely to change in…
RKBuiltMyRothod
  • 101
  • 1
  • 8
3
votes
1 answer

How to allow web requests when using VCR / WebMock?

I'm currently using RSpec2, Cucumber and VCR (via WebMock), and everything's working great. With VCR normally all requests are recorded and then replayed against the recorded cassettes. Now I want to allow real web requests in some scenarios: In…
Cory Schires
  • 2,146
  • 2
  • 14
  • 26
3
votes
0 answers

Is there a way to use vcrpy for requests made from a different process?

I'm trying to use vcrpy to record and replay requests. Issue is, those requests are happening on a different process and it looks like vcrpy doesn't work on that. code looks something like this: import vcr with vcr.use_cassette("path/to/cassette"): …
Shtut
  • 1,397
  • 2
  • 14
  • 28
3
votes
1 answer

how do I dynamically generate multiple HTTP mock responses with VCR for Ruby/RSpec?

I'm hitting an API and for each request, there was a recorded request/response in the cassette YAML file. However, the only difference between the requests was the id in the query parameters. How do I shrink my YAML file so that URLs are dynamically…
user9903
1 2
3
11 12