Thank you, solution of @Sovoboys works for me.
Here is my variant:
allow(Resolv).to receive(:getaddresses).and_return(['8.8.8.8']) stub_request(:get, /http:\/\/.+/).to_return(body: file, status: 200)