Problem
When example_mode: :none is set on a test, it correctly prevents recording examples to the OpenAPI output, but it does not prevent overwriting the response description. Since RSpec runs tests in random order, a test marked with example_mode: :none can run last for a given endpoint+status code and its description (derived from describe/context/it blocks) overwrites the description from a documented test.
Steps to reproduce
- Have two tests for the same endpoint — one documented (default or
:single/:multiple) and one with example_mode: :none
- Run the suite multiple times with different random seeds
- Observe that the response description in the generated YAML changes depending on which test runs last
describe 'GET /api/events', openapi: { example_mode: :multiple } do
it 'returns the owner\'s events' do
get '/api/events'
expect(response.status).to eq(200)
end
end
describe 'GET /api/events', openapi: { example_mode: :none } do
it 'paginates results' do
get '/api/events', params: { page: 2 }
expect(response.status).to eq(200)
end
end
Expected description: "Returns the owner's events"
Actual description (when the :none test runs last): "Paginates results"
Expected behavior
example_mode: :none should prevent the test from overwriting an existing response description, just as it prevents recording examples. The description should still be recorded if the :none test is the first or only test for that endpoint (since description is a required field in the OpenAPI Response Object).
Environment
Problem
When
example_mode: :noneis set on a test, it correctly prevents recording examples to the OpenAPI output, but it does not prevent overwriting the response description. Since RSpec runs tests in random order, a test marked withexample_mode: :nonecan run last for a given endpoint+status code and its description (derived fromdescribe/context/itblocks) overwrites the description from a documented test.Steps to reproduce
:single/:multiple) and one withexample_mode: :noneExpected description:
"Returns the owner's events"Actual description (when the
:nonetest runs last):"Paginates results"Expected behavior
example_mode: :noneshould prevent the test from overwriting an existing response description, just as it prevents recording examples. The description should still be recorded if the:nonetest is the first or only test for that endpoint (sincedescriptionis a required field in the OpenAPI Response Object).Environment