-
Notifications
You must be signed in to change notification settings - Fork 64
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
Can we use rspec context description stack for describe responses? #6
Comments
I took a look at how to support this feature. Let me ask a few things.
|
describe Table, type: :request do
describe "/index" do
context "when ..." do
it "return ..." do
context "but ..." do
it "return ..."
...
context "when another..." do
it "return another ..." do
...
end
|
Because
Let me ask this again: are you okay with that? We simply can't remove
I think it's feasible to just generate |
|
If it requires some agreement on the description, probably it's too specific to your project. So I added some flexibility on the solution for you 2f36d0d. You take a RSpec example, and you traverse a context tree as you like, and yield a description from it: RSpec::OpenAPI.description_builder = -> (example) do
contexts = example.example_group.parent_groups.map(&:description).select do |description|
description.match?(/\Awhen /)
end
[*contexts, 'it', example.description].join(' ')
end I hope you'll find a best way to build a description using the config as you like. Please try v0.3.1. |
I would not say that I have a specific use of rspec in the project, I try to follow generally accepted techniques, but you are right that in the end everything becomes specific. |
Example
It generate
description: return some error
in openapi.yamlIt would be more convenient to add a description from the entire description stack context.
For example, this would generate
description: when user ... foo but not ... bar it return some error
Then we will have all the power of the rspec as a BDD in the API description.
Although it is possible use description into the response is not entirely correct, I lack a technical understanding in this matter.
The text was updated successfully, but these errors were encountered: