I have a class Translator which has call to class Connector. Connector class does request to external API, wanted to use VCR to record this API action, then stub instance of Connector class and return VCR response of the API action in call Translator.
class Translator
def initialize
@obj = Connector.new().connect
end
def format
# use obj here for some logic
end
end
class Connector
def connect
# http request to external API
end
end
RSpec.describe Translator, type: :services do
before do
allow_any_instance_of(Connector).to receive(:connect).and_return(VCR recorded response)
end
end