我刚刚开始使用rspec_api_documentation而无法让它与我的api一起使用。创建简单的规范,与自述文件中的第一个示例一样基本,但它不断向我抛出undefined method 'call' for nil:NilClass
错误,我不知道可能导致问题的原因。
这是完整的堆栈跟踪:
1) Users GET /api/v1/users Listing users
Failure/Error: do_request
NoMethodError:
undefined method `call' for nil:NilClass
# /home/swistak/.rvm/gems/ruby-2.2.2/gems/rack-test-0.6.3/lib/rack/mock_session.rb:30:in `request'
# /home/swistak/.rvm/gems/ruby-2.2.2/gems/rack-test-0.6.3/lib/rack/test.rb:244:in `process_request'
# /home/swistak/.rvm/gems/ruby-2.2.2/gems/rack-test-0.6.3/lib/rack/test.rb:58:in `get'
# /home/swistak/.rvm/gems/ruby-2.2.2/gems/rspec_api_documentation-4.7.0/lib/rspec_api_documentation/rack_test_client.rb:38:in `do_request'
# /home/swistak/.rvm/gems/ruby-2.2.2/gems/rspec_api_documentation-4.7.0/lib/rspec_api_documentation/client_base.rb:42:in `process'
# /home/swistak/.rvm/gems/ruby-2.2.2/gems/rspec_api_documentation-4.7.0/lib/rspec_api_documentation/client_base.rb:12:in `get'
# ./spec/acceptance/users_spec.rb:7:in `block (3 levels) in <top (required)>
这是规范
require 'spec_helper'
require 'rspec_api_documentation/dsl'
RSpec.resource 'Users' do
get '/api/v1/users' do
example 'Listing users' do
do_request
status.should == 200
end
end
end
这是控制器
class Api::V1::UsersController < ApplicationController
skip_before_action :authenticate_with_token, only: %i(index show create)
expose(:users)
def index
render json: users, each_serializer: ::V1::UserSerializer
end
end
我的api在localhost:3000 / api / v1 / users
下任何帮助表示赞赏