Comments (6)
Yes it is really problematic. Maybe cut top level describe with regex, but this seems like an unreliable solution. I think that for this we need to develop some kind of agreement on the description if we want to process it automatically. For example, use only /path in the upper describe, then we can somehow cut it based on regexp.
Table /index when another ... return another ... -> (regexp) -> when another ... return another ...
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.
from rspec-openapi.
Although it is possible use description into the response is not entirely correct, I lack a technical understanding in this matter.
I took a look at how to support this feature. Let me ask a few things.
- Don't you use a
describe
block? Please include it if you use it in your real example.context
cannot be distinguished fromdescribe
. Do you expect to includedescribe
's descriptions as well?
it
cannot be distinguished fromspecify
. Therefore we can't reasonably generate "it" in your proposed description.- Therefore the description would be
when your ... foo but not ... bar return some error
. Are you okay with it?
- Therefore the description would be
from rspec-openapi.
- Yep, I use it to separate tests by methods or by queries for request tests and use context for refinement of behavior context. I try to follow the rules from http://www.betterspecs.org/
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
- Here we are talking about the fact that rspec implies the use of BDD descriptions through
describe
andcontext
and if we merging which together it, it should ultimately be a complete English sentence describing the behavior in each case. so it would be better to leaveit
. Can we just simple addit
string in the presence of context?
from rspec-openapi.
- Yep, I use it to separate tests by methods or by queries for request tests and use context for refinement of behavior context. I try to follow the rules from
Because context
and describe
are the same things, description
will need to be:
Table /index when ... return ...
Table /index when ... but ... return ...
Table /index when another ... return another ...
Let me ask this again: are you okay with that? We simply can't remove Table /index
part in a reasonable manner.
Can we just simple add it string in the presence of context?
I think it's feasible to just generate it
regardless of whether a user used it
or specify
(because of the assumption, I think the behavior should not be a default). Though, as context
cannot be distinguished from describe
, it
will need to be generated in a presence of describe
too.
from rspec-openapi.
- Yes it is really problematic. Maybe cut top level
describe
with regex, but this seems like an unreliable solution. I think that for this we need to develop some kind of agreement on the description if we want to process it automatically. For example, use only/path
in the upperdescribe
, then we can somehow cut it based on regexp.
Table /index when another ... return another ...
-> (regexp) ->when another ... return another ...
- I agree
from rspec-openapi.
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.
Thanks for the work you've done.
from rspec-openapi.
Related Issues (20)
- Support for OAS 3.1? HOT 2
- Support Minitest's parallel execution HOT 1
- Generated Request Body for Path is using 422 Response HOT 3
- Is there any way to define additionalProperties? or Free-Form Object HOT 5
- Suggestion for the readOnly property HOT 1
- Getting invalid byte sequence in UTF-8 when the response is a pdf HOT 3
- Difference in Empty Values Handling in Examples HOT 3
- Dealing with responses with different possible bodies for the same status code HOT 1
- requestBody should not merge examples for error HOT 2
- Setting additionalProperties = false HOT 1
- Include property descriptions in response schema? HOT 1
- Regenerating (remove file and run rspec) the schema without changing the code, generates different file. HOT 1
- Authorization HTTP header is inserted as parameter even though there is securityScheme defined HOT 2
- Using `RSpec::OpenAPI.path = ->` but for different audiences HOT 1
- Evaluate proc for RSpec::OpenAPI.title HOT 2
- Manually edited oneOf in response schema is overridden HOT 4
- Referenced components in "items" not generated?
- API schema that is not subject to rspec execution is deleted. HOT 1
- Minitest support HOT 2
- Can we support 'required' ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rspec-openapi.