Coder Social home page Coder Social logo

Comments (6)

k0kubun avatar k0kubun commented on June 2, 2024 1

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.

k0kubun avatar k0kubun commented on June 2, 2024

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 from describe. Do you expect to include describe's descriptions as well?
  • it cannot be distinguished from specify. 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?

from rspec-openapi.

AlexeyMatskevich avatar AlexeyMatskevich commented on June 2, 2024
  1. 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
  1. Here we are talking about the fact that rspec implies the use of BDD descriptions through describe and context 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 leave it. Can we just simple add it string in the presence of context?

from rspec-openapi.

k0kubun avatar k0kubun commented on June 2, 2024
  1. 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.

AlexeyMatskevich avatar AlexeyMatskevich commented on June 2, 2024
  1. 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 ...
  2. I agree

from rspec-openapi.

AlexeyMatskevich avatar AlexeyMatskevich commented on June 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.