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

Add custom spec description option to run_test! #622

Merged

Conversation

mattpolito
Copy link
Collaborator

@mattpolito mattpolito commented Apr 8, 2023

Problem

Specifications generated by run_test! are essentially a hard coded string of "returns a RESPONSE_CODE response". If you need to customize this you have to break down into the individual parts that run_test! constructs for us.

it "custom specification description here" do |example|
  submit_request(example.metadata)
  assert_response_matches_metadata(example.metadata)
end

Solution

To facilitate configuration without the need to break out of the nicety that run_test! provides, we can now pass a description as the first argument.

run_test!("custom specification description here")

A huge benefit to this is that when paired with auto generation of request/response examples, many example scenarios can be provided for documentation within the same response grouping.

NOTE: description is not an allowable option to pass down to a specification, so we delete it vs forwarding down to it.

The changes I made are compatible with:

  • OAS2
  • OAS3
  • OAS3.1

Checklist

  • Added tests
  • Changelog updated
  • Added documentation to README.md
  • Added example of using the enhancement into test-app

@mattpolito mattpolito force-pushed the add_custom_spec_description_to_run_test branch from b5ff355 to 18b1c26 Compare April 8, 2023 04:33
Co-authored-by: Matt Polito <matt.polito@hashrocket.com>
Co-authored-by: Tony Yunker <tony.yunker@hashrocket.com>
@mattpolito mattpolito force-pushed the add_custom_spec_description_to_run_test branch from 18b1c26 to 745d240 Compare April 8, 2023 04:34
@mattpolito
Copy link
Collaborator Author

@romanblanco If rswag is in need of maintainer help. We can be of assistance.

@a-lavis
Copy link
Contributor

a-lavis commented Apr 19, 2023

This is a great idea! I have a proposal of how we could do it slightly differently here: hashrocket#1
Let me know your thoughts!

@mattpolito
Copy link
Collaborator Author

Updated PR with test-app scenario

@BookOfGreg
Copy link
Member

Hi @mattpolito, Roman pointed out your PR here on this project and I've chosen to grant you Write access to the project.
We hope you and the rest of the team at Hashrocket a good time with rswag.

@mattpolito
Copy link
Collaborator Author

@romanblanco now that you cut a release for 2.9.0, this is technically a breaking change. I was hoping it would make it in prior to the 'run_test!' options change. How would you like to handle this?

@romanblanco
Copy link
Member

@mattpolito, my plan is to review and release this and other PRs in 2.10.0 before merging #574 and other future changes for 3.0.0.

I've tried to rebase your changes and run tests and everything is still passing.

@mattpolito
Copy link
Collaborator Author

@romanblanco It's not a breaking change in code but in usage. However after thinking about how ruby would handle the args vs options, I believe it will be fine after-all.

Copy link
Member

@romanblanco romanblanco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@mattpolito, @a-lavis, @ayunker, thanks for getting this done!

@romanblanco romanblanco merged commit ca23785 into rswag:master Apr 25, 2023
10 checks passed
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

Successfully merging this pull request may close these issues.

None yet

5 participants