Skip to content

Commit 53059bb

Browse files
committed
2.5.1
Fix skipping skipped responses during coverage tracking
1 parent 2a0b7cb commit 53059bb

6 files changed

Lines changed: 27 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## 2.5.1
6+
7+
- Fix skipping skipped responses during coverage tracking
8+
59
## 2.5.0
610

711
### New feature

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
openapi_first (2.5.0)
4+
openapi_first (2.5.1)
55
hana (~> 1.3)
66
json_schemer (>= 2.1, < 3.0)
77
openapi_parameters (>= 0.3.3, < 2.0)

benchmarks/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ..
33
specs:
4-
openapi_first (2.5.0)
4+
openapi_first (2.5.1)
55
hana (~> 1.3)
66
json_schemer (>= 2.1, < 3.0)
77
openapi_parameters (>= 0.3.3, < 2.0)

lib/openapi_first/test/coverage/plan.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def track_request(validated_request)
3838
end
3939

4040
def track_response(validated_response)
41-
index[validated_response.response_definition.key].track(validated_response) if validated_response.known?
41+
index[validated_response.response_definition.key]&.track(validated_response) if validated_response.known?
4242
end
4343

4444
def done?

lib/openapi_first/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module OpenapiFirst
4-
VERSION = '2.5.0'
4+
VERSION = '2.5.1'
55
end

spec/test/coverage/plan_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,25 @@
169169
expect(plan.tasks[2].status).to eq('4XX')
170170
end
171171

172+
it 'ignores unknown responses' do
173+
request = Rack::Request.new(Rack::MockRequest.env_for('/stuff/24'))
174+
response = Rack::Response.new
175+
response.status = 208
176+
unknown_response = oad.validate_response(request, response)
177+
178+
plan.track_response(unknown_response)
179+
180+
expect(plan.tasks.count(&:finished?)).to eq(0)
181+
end
182+
183+
it 'ignores skipped responses' do
184+
plan = described_class.for(oad, skip_response: ->(res) { res.status == '200' })
185+
186+
plan.track_response(valid_response)
187+
188+
expect(plan.tasks.count(&:finished?)).to eq(0)
189+
end
190+
172191
context 'with skip_response option' do
173192
let(:plan) do
174193
skip_response = ->(response) { response.status == '4XX' }

0 commit comments

Comments
 (0)