Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using apivore in seperate test framework #110

Open
mugdhachauhan opened this issue Sep 11, 2017 · 0 comments
Open

using apivore in seperate test framework #110

mugdhachauhan opened this issue Sep 11, 2017 · 0 comments

Comments

@mugdhachauhan
Copy link

mugdhachauhan commented Sep 11, 2017

  • 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: "[email protected]"},
                           "_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: "[email protected]"},
                             "_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?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant