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

Running tests with OPENAPI=1 causes all request tests to fail #25

Closed
xcskier56 opened this issue May 27, 2021 · 5 comments
Closed

Running tests with OPENAPI=1 causes all request tests to fail #25

xcskier56 opened this issue May 27, 2021 · 5 comments

Comments

@xcskier56
Copy link

Hi there,

I'm hoping to use this gem to automatically document our api, a wonderful thing. However, when I run our tests with OPENAPI=1 rspec spec every request spec fails with No route matched for ..... These tests pass when running rspec without OPENAPI=1.

All I have done is install the gem into the :test group and bundle install

Ideas?

@k0kubun
Copy link
Collaborator

k0kubun commented May 28, 2021

Could you provide a repository that reproduces the issue?

@xcskier56
Copy link
Author

I think I've found the problem, but I do not know why it is causing a problem. We are mounting a custom build engine at the top of the routes file and at the root of the project. Ie.

Rails.application.routes.draw do
  mount MyEngine::Engine => '/'

  # ... rest of routes
end

When I move the engine below the routes it works fine

@k0kubun
Copy link
Collaborator

k0kubun commented May 29, 2021

Thank you for reporting more details. Using the engine might have something to do with the issue.

Because I haven't seen the issue in my apps, including ones using Rails engines, I still need a repository that captures your situation, or some instructions to reproduce it from rails new, to give helpful advice or work on a fix. I'm sorry for the trouble, but I'd appreciate your help in reproducing it on my side.

@xcskier56
Copy link
Author

Unfortunately I don't have enough time right now to build a repo that will reproduce, but what I found is that in this method, https://github.com/k0kubun/rspec-openapi/blob/4c6041952e478c32d5e7ee1e9745f8a5e6748a8a/lib/rspec/openapi/record_builder.rb#L65 it will be called recursively and on the first recursive call (aka 2nd call), all routes except the engine route have been removed.

Feel free to close this. Thanks

@k0kubun
Copy link
Collaborator

k0kubun commented May 31, 2021

Yeah, I think the place could be relevant to your problem. However, I cannot fix what I cannot reproduce, so please feel free to take your time and reopen this when a repository that I can take a look at is ready. Thanks.

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

2 participants