【问题标题】:Rspec test with HTTP post request passes locally but fails on CI server带有 HTTP 发布请求的 Rspec 测试在本地通过,但在 CI 服务器上失败
【发布时间】:2015-03-19 16:24:56
【问题描述】:

我有一个 Rspec 测试,它发出一个 POST 请求并发送一个标头,因为需要身份验证:

it 'creates a client for an organization if none exists' do
  VCR.use_cassette('create_client') do
    post "/organizations/#{@organization.id}/clients", nil, { 'TOKEN' => @token }

    expect(last_response.status).to be(201)
    expect(json_response).to be_a(Hash)
    expect(json_response["organization_id"]).to eq(@organization.id)
    expect(json_response.keys).to include('auth_token')
   end
   expect(@organization.client).to_not be_nil
end

当我在本地机器上运行测试时,这会顺利通过,但会在 CI 服务器上失败(在本例中为 Codeship):

Failure/Error: post "/organizations/#{@organization.id}/clients", nil, { 'TOKEN' => @token }
MyModule::MyClass::Errors::InvalidOptionError:
  bad URI(is not URI?):

当我从 post 请求中删除 header 部分时,测试显然会失败,因为需要 token 头,但 post 请求将通过而没有错误。

任何想法为什么会发生这种情况?如有任何意见,我将不胜感激。

【问题讨论】:

    标签: ruby-on-rails rspec http-post codeship


    【解决方案1】:

    原来这是 Elasticsearch on Codeship 的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-28
      • 2023-03-19
      • 2015-03-16
      • 1970-01-01
      相关资源
      最近更新 更多