11

I am stubbing all requests that go through the ViewPoint gem. Using the vcr gem.

require 'spec_helper'
require 'vcr'

describe CalendarImporters::Ews::Get do
  let(:conf_connection) { FactoryGirl.create(:conf_connection)}
  let(:calendar) { create(:calendar, :for_ews) }
  let(:connection) { Connections::Ews.new(conf_connection, calendar.ews_email) }

  it "works" do
    VCR.use_cassette("a/cassette") do
      connection.client.get_folder(:calendar)
    end
  end
end

connection.client returns a new ViewPoint connection.

The response i get back from the gem is: Viewpoint::EWS::Errors::UnauthorizedResponseError which equates to a 401 unauthorised code from the ews api.

I found this issue: https://github.com/vcr/vcr/issues/297

It is exactly the same problem I am having, but it is 3 years old and with no solution. All of my other google foo has turned up nothing.

Digging into the viewpoint gem, I can't find any difference between the request objects apart from: HTTPClient and WebMockHTTPClient which is to be expected.

DickieBoy
  • 4,886
  • 1
  • 28
  • 47

1 Answers1

1

ViewPoint is using HTTPClient for its connection, so you need to configure VCR to use hook into :webmock and stub your requests.

Oz Ben-David
  • 1,589
  • 1
  • 16
  • 26
  • Thanks for your reply. I anticipate returning to this at some point in the new year. I will let update the question when i find that out. – DickieBoy Nov 26 '20 at 14:21