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

Prepend openapi! in any case #128

Merged
merged 3 commits into from
Aug 15, 2023
Merged

Prepend openapi! in any case #128

merged 3 commits into from
Aug 15, 2023

Commits on Jul 26, 2023

  1. Add failing tests

    andyundso committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    f34f3f1 View commit details
    Browse the repository at this point in the history
  2. Prepend openapi! in any case

    If you run tests with Minitest at themoment, but without the environment variable `OPENAPI`, you are greeted with an error message.
    
    `undefined method `openapi!' for Api::V0::SomeControllerTest:Class (NoMethodError)`
    
    This is because the current code adds the `openapi!` method only if `OPENAPI` environment variable is set.
    
    This commit modifies the loading logic, always requiring the `minitest` hooks class to be loaded if `Minitest` constant is defined, to avoid issues with RSpec. Then, the `openapi?` and `openapi!` methods are always prepended to `Minitest::Test`, while the modified `run` method and the `after_run` hook are only activated when `OPENAPI` environment variable is set.
    andyundso committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    ed1f83f View commit details
    Browse the repository at this point in the history
  3. Ensure Minitest is loaded before RSpec OpenAPI

    The alternative to this approach would be to remove the check for `Object.const_defined?('Minitest')`, but I assume in environments where you only have RSpec, not Minitest (like when you use another framework than Rails), this would not work.
    andyundso committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    a37d3ec View commit details
    Browse the repository at this point in the history