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.
ViewPoint is using HTTPClient for its connection, so you need to configure VCR to use hook into :webmock and stub your requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With