0

我有关于将图像上传到 S3 的测试,无论在哪里测试,我都会存根发出的请求。

所有测试都在本地通过,但在圈 CI 上,我得到以下异常:

WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled. Unregistered request: GET http://169.254.169.254/latest/meta-data/iam/security-credentials/ with headers {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}

You can stub this request with the following snippet:

stub_request(:get, "http://169.254.169.254/latest/meta-data/iam/security-credentials/").
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
  to_return(:status => 200, :body => "", :headers => {})
4

1 回答 1

1

这是因为我没有为 CI 上的 AWS_ID 和 AWS_SECRET 设置 ENV 变量

于 2017-02-10T16:09:57.777 回答