stub_version_request

in spec/cc/cli/version_checker_spec.rb [108:126]


  def stub_version_request(versions_resp)
    uri = URI("https://versions.codeclimate.com")
    uri.query = { version: current_version, uid: uuid }.to_query

    stub_resolv(uri.host, "255.255.255.255")

    resp = Net::HTTPOK.new("1.1", 200, "OK")
    allow(resp).to receive(:body).and_return(versions_resp.to_json)

    http = instance_double(Net::HTTP)
    allow(http).to receive(:open_timeout=).with(5)
    allow(http).to receive(:read_timeout=).with(5)
    allow(http).to receive(:ssl_timeout=).with(5)
    allow(http).to receive(:use_ssl=).with(true)
    allow(http).to receive(:get).with(uri, "User-Agent" => /Code Climate CLI/).and_return(resp)

    allow(Net::HTTP).to receive(:new).with(uri.host, uri.port).and_return(http)
  end