razum2um / lurker

📖 The ultimate tool for documenting and testing APIs in Rails
https://lurker.razum2um.me/lurker
MIT License
116 stars 22 forks source link

Does not create yml schemas #113

Closed zhulik closed 8 years ago

zhulik commented 8 years ago

Hi!

I trying to use lurker in my project: i put it in my gemfile, install it, then add require 'lurker/spec_helper' in my spec_helper and then i wrote request spec:

  it 'lists cities', :lurker do
    get '/api/v1/cities.json?radius=50000&lon=10&lat=20'
  end

I know, that endpoint on this URL works and return some json array with 200 code, but no schemas was created. So, i try to read luker code and i note it in spy.rb:

def call
      @request = @response = nil # fill in while test
# @request and @response is nils, it's normal
      @block.call.tap do |result|
# @request and @response still nils, reuslt is nil too, i think it's not nornal
        if @request && @response
          @service.verify!(
            verb, endpoint_path, payload,
            extensions, status, body
          )
          @service.persist! if success?(result)
        end
      end
    end

Any assumptions? rspec 3.3.2, rails 4.1.13, ruby 2.2.3p173

razum2um commented 8 years ago

@zhulik you definitely got the problem, the @request && @response should be filled here: https://github.com/razum2um/lurker/blob/master/lib/lurker/spec_helper/rails.rb#L20 by hooking into ActionDispatch in request specs

for the further help I need an example app or steps to reproduce

zhulik commented 8 years ago

@razum2um thanks for answer, i check your link and i found that defined?(ActionDispatch::Integration::Session) and defined?(ActionController::TestCase::Behavior) returns nils in your code, but in my specs those constans is correctly defined. Any ideas?

razum2um commented 8 years ago

@zhulik what do you mean under "returns nils in your code"? gem itself doesn't require all rails, only active_support and does what stays there: if you use rails, it hooks into it

zhulik commented 8 years ago

The solution in position of require 'lurker/spec_helper'. It should be placed after require 'rspec/rails'. @razum2um can you add a note to readme?

razum2um commented 8 years ago

@zhulik yep, you're right, order matters, will do

zhulik commented 8 years ago

@razum2um great, thanks!