简体   繁体   English

如何使用 Faraday 自定义存根请求?

[英]How to customize stub request using Faraday?

I'm trying to customize stubs via Faraday and have a little problem with setting request_body and request_headers.我正在尝试通过 Faraday 自定义存根并且在设置 request_body 和 request_headers 时遇到了一些问题。 All test works and are green, but I'm still getting message by Rubymine: „Found extra argument“ and that part of the code is underlined in red.所有测试都有效并且是绿色的,但我仍然收到 Rubymine 的消息:“找到额外的参数”并且那部分代码带有红色下划线。 I would like to get rid of it.我想摆脱它。 Just how to customize body and headers in right way, please?请问如何以正确的方式自定义正文和标题?

Actual problem实际问题

1个

I have tried to customize it like this:我试过像这样自定义它:

conn = Faraday.new(url: "url") do |faraday|
        faraday.response :raise_error
      end

conn.get("url") do |req|
  req.body: {body: "body"}
  req.headers: {headers: "headers"}
end

But it did not work.但它没有用。

Thank you for the feedback.感谢您的反馈。 This is a known problem, please follow the RUBY-30140/False-positive-found-extra-argument-warning-with-Faraday.get (see help if you are not familiar with YouTrack).这是一个已知问题,请遵循RUBY-30140/False-positive-found-extra-argument-warning-with-Faraday.get (如果您不熟悉 YouTrack,请参阅帮助)。

I've requested this issue to include in one of our nearest maintenance sprint.我已要求将此问题包含在我们最近的维护冲刺中。 Sorry for inconveniences:(抱歉给您带来不便:(

Best regards Anna Kutarba.最好的问候安娜库塔巴。

JetBrains https://jetbrains.com The Drive to Develop JetBrains https://jetbrains.com开发的动力

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM