0

I'm currently trying to get VCR to run correctly for my app. Right now everything seems to be configured right but I must be missing something because when the test that uses the VCR.use_cassette is not render the response in the yml file I have set up. I'll post all of my code that is pertaining the issue and let me know if I'm doing something wrong.

/support/vcr.rb:

    VCR.configure do |c|
  c.configure_rspec_metadata!
  c.cassette_library_dir = Rails.root.join("spec", "vcr")
  c.hook_into :webmock
  c.after_http_request do |request, _response|
    VCR.http_requests_made << request
  end
end

Request spec:

 require "rails_helper"

describe "Mailchimp" do
  describe "Manage list" do
    let!(:subscriber) { FactoryGirl.create(:subscriber) }

    it "adds new subscriber to list" do
      expect do
        VCR.use_cassettes("mailchimp/list") do
          post new_subscriber_path
        end.to change(:subscriber, :count).by(1)
      end
    end
  end
end

YML file: /vcr/mailchimp/list.yml

NOTHING RENDERS. THIS IS WHERE I EXPECT THE RESPONSE FOR VCR BUT I"M GETTING NOTHING.

Hopefully this is enough info. let me know if you need more?

Bitwise
  • 8,021
  • 22
  • 70
  • 161

2 Answers2

1

Try adding

VCR.configure do |config|
  config.allow_http_connections_when_no_cassette = true
end
nikkypx
  • 1,925
  • 17
  • 12
0

I can't pin-point what the error might have been in your case, but here are my thoughts:

require "rails_helper"

describe "Mailchimp" do
  describe "Manage list" do
    let!(:subscriber) { FactoryGirl.create(:subscriber) }

    it "adds new subscriber to list" do
      expect do
        VCR.use_cassette("mailchimp/list") do
          post new_subscriber_path
        end
      end.to change(:subscriber, :count).by(1)
    end
  end
end

Changes made,

  1. Moved the VCR call into the expectation block
  2. Changed to VCR.use_cassete

Let me know if it works.

oreoluwa
  • 5,553
  • 2
  • 20
  • 27
  • I appreciate The help but that doesn't seem to do the job... although that is some obvious stuff I should have noticed. Thanks – Bitwise Jul 10 '16 at 03:37