-
Notifications
You must be signed in to change notification settings - Fork 19
Make OpenapiFirst::Test more strict and more configurable #371
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Just like Array#delete_if or such
- OpenapiFirst::Test now raises an "invalid response" error if it sees an invalid response. You can change this back to the old behavior by setting `response_raise_error = false`: ```ruby OpenapiFirst::Test.setup do |test| # test.register(...) test.response_raise_error = false end ```
to configure the behavior if not all requests/responses of the API under test have been tested. Deprecate `OpenapiFirst::Test::Configuration#minimum_coverage=` use "#report_coverage" instead to modify the behavior
It think it's louder and clearer that way Also avoid checking coverage and failing after our own test case is finished by disabling exit handler via Test.uninstall And move setup/handling at_exit from Configuration to Test
Add `OpenapiFirst::Test::Configuration#ignored_unknown_status` to configure response status(es) that do not have to be descriped in the API description.
Added `Test.setup { it.observe }` and low-level `Test::Callable[]` to inject request/response validation in rack app as an alternative to overwrite the `app` method in a test
…I should have squashe-merged this. Sorry for the noise. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
OpenapiFirst::Test is now stricter and more configurable
Changes:
You can change this back to the old behavior by setting
OpenapiFirst::Test::Configuration#response_raise_error = false
(but you shouldn't).Test.setup { it.observe(MyApp) }
,Test.observe(App, api: :my_api)
and internalTest::Callable[]
to inject request/response validation in rack app as an alternative to overwrite theapp
method in a testTest::Configuration#ignored_unknown_status
to configure response status(es) that do not have to be descriped in the API description. 404 statuses are ignored by default.OpenapiFirst::Test
to make tests fail if API description is not covered by tests. You can adapt this behavior viaOpenapiFirst::Test.setup
/skip_response_coverage
or deactivate coverage withOpenapiFirst::Test::Configuration#report_coverage = false
orreport_coverage = :warn
Solves #366