rspec_api_documentation - undefined method `call' for nil:NilClass

1k Views Asked by At

I've just started using rspec_api_documentation and cannot get it to work with my api. Created simple spec, as basic as first example in the readme but it keeps throwing undefined method 'call' for nil:NilClass error at me, and I have no idea what may cause the problem.

Here is full stack trace:

  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)>

Here is the spec

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

and here is the controller

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

My api is under localhost:3000/api/v1/users

Any help appreciated

1

There are 1 best solutions below

0
On BEST ANSWER

It seems that configuration block is required, so I've just created acceptance_helper.rb as in the example application and imported it in spec.