如何解决rspec_api_documentation gem
我正在使用rspec_api_documentation拥有大量的文档。我有POST端点,唯一的工作就是接收webhook数据并发送响应。关键是我在这里使用name
和password
进行了基本身份验证:
webhook_controller.rb
class Api::V1::WebhooksController < ActionController::API
include ActionController::HttpAuthentication::Basic::ControllerMethods
include ActionController::HttpAuthentication::Token::ControllerMethods
http_basic_authenticate_with name: Rails.application.credentials.webhook_auth_name,password: Rails.application.credentials.webhook_auth_password
def create
return head(:not_implemented) unless Flipflop.digital_human_integration?
# ...
# some other code
end
如何在此特定的rspec-dsl中验证收到的Webhook?基于docs,我正在尝试执行以下操作:
require 'rails_helper'
require 'rspec_api_documentation/dsl'
resource 'Webhooks' do
explanation 'Dialogflow webhooks receiver endpoint'
authentication :basic,name: Rails.application.credentials.webhook_auth_name,password: Rails.application.credentials.webhook_auth_password
post '/api/v1/webhooks' do
context 'with feature flag set to false' do
before do
Flipflop::FeatureSet.current.test!.switch!(:digital_human_integration,false)
end
example_request 'returns 501' do
expect(response_status).to eq http_status_code(:not_implemented)
end
end
但是我得到的是401而不是501
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。