【问题标题】:Test around amazon S3 upload fails only on Circle CI using WebMock仅在使用 WebMock 的 Circle CI 上测试亚马逊 S3 上传失败
【发布时间】:2017-02-10 05:25:24
【问题描述】:

我有关于将图像上传到 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 => {})

【问题讨论】:

    标签: ruby-on-rails ruby aws-sdk circleci webmock


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2012-03-30
      • 1970-01-01
      • 2013-06-09
      • 2013-10-29
      • 2011-12-05
      • 1970-01-01
      • 1970-01-01
      • 2012-03-07
      • 2015-11-01
      相关资源
      最近更新 更多