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 support for context blocks in HTML index #486

Open
greggroth opened this issue Nov 20, 2020 · 3 comments
Open

Add support for context blocks in HTML index #486

greggroth opened this issue Nov 20, 2020 · 3 comments
Labels
good-first-issue Good issue for new contributors to pick up

Comments

@greggroth
Copy link

Right now, all examples under a resource are flattened to a single list, so tests that have the same example name across different contexts to highlight different behaviors lose this organization. For example, given a test like:

resource "Blog" do
  get "/blog/:client_id" do
    context "as the page owner" do
      before { sign_in }

      example_request "responds with 200" do
        expect(status).to eq 200
      end
    end

    context "as a visitor" do
      example_request "responds with 200" do
        expect(status).to eq 200
      end
    end
  end
end

Would generate docs structured like

Blog
  - responds with 200
  - responds with 200

So the request detail GET /blog/:client and the context of each example are left out.

This can be worked around with more verbose example descriptions, but would y'all be open to considering an update to the HTML doc writer to include the structure of the tests so the index output is more like

Blog
  - GET /blog/:client_id
    - as a page owner
      - responds with 200
    - as a visitor
      - responds with 200
@jakehow jakehow added the good-first-issue Good issue for new contributors to pick up label Nov 20, 2020
@jakehow
Copy link
Member

jakehow commented Nov 20, 2020

@greggroth sounds good to me, even better if it can be flipped on via a flag to preserve existing behavior for now.

@greggroth
Copy link
Author

👍 I'll try to find time to hack on this in the coming weeks and will keep a configuration option in mind. Thank you!

@PhilT
Copy link

PhilT commented Apr 30, 2021

I've hit this issue as well and there's actually even more to this. Example requests with the same description get overwritten in the generated files.

post '/orders' do
  example_request 'responds with 200' do
  end
end

get '/orders' do
  example_request 'responds with 200' do
  end
end

Outputs 2 identically named files called orders/responds_with_200.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good-first-issue Good issue for new contributors to pick up
Projects
None yet
Development

No branches or pull requests

3 participants