Skip to content

using apivore in seperate test framework #110

@mugdhachauhan

Description

@mugdhachauhan
  • I am using apivore in a separate(custom) test framework.
  • So apivore is not used with a rails app. i am just testing some rest APIs
  • i had to override follwing method to return the swagger.json file located (temp) in my framework
def fetch_swagger!
     JSON.parse(File.read(LOCAL_SWAGGER_JSON_PATH))
   end

here is my test:

describe 'the API', type: :apivore, order: :defined do
  before do
    byebug
    @json = Apivore::SwaggerChecker.instance_for(LOCAL_SWAGGER_JSON_PATH)
  end
  context 'testing' do
    let(:params){}
    it 'identify' do
         expect(@json).to validate(
         :post, "/identify", 200, {
                           "_data" => {user_id: 'xxx', email: "test@test.com"},
                           "_headers" => {'X-Outbound-Key' => 'xxxx'}
                       }
     )
    end
  end
end

Error after executing test:

Failure/Error:
        expect(@json).to validate(
           :post, "/identify", 200, {
                             "_data" => {user_id: 'xxx', email: "test@test.com"},
                             "_headers" => {'X-Outbound-Key' => 'xxx'}
                         }
       )

     NoMethodError:
       undefined method `call' for nil:NilClass

How can i user Apivore:

  • with non rails app?
  • by loading local swagger.json file?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions