Skip to content

Commit efae69c

Browse files
committed
Adapt test to new middlewares argument
1 parent d5e6f4c commit efae69c

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

spec/middlewares/request_validation_spec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
let(:app) do
1212
Rack::Builder.app do
1313
use Rack::Lint
14-
use(OpenapiFirst::Middlewares::RequestValidation, spec: File.expand_path('../data/petstore.yaml', __dir__))
14+
use(OpenapiFirst::Middlewares::RequestValidation, File.expand_path('../data/petstore.yaml', __dir__))
1515
use Rack::Lint
1616
run lambda { |_env|
1717
Rack::Response.new('hello', 200).finish
@@ -32,10 +32,10 @@
3232
end
3333
end
3434

35-
context 'when OAD is passed as first argument' do
35+
context 'when OAD is passed as spec: argument' do
3636
let(:app) do
3737
Rack::Builder.app do
38-
use(OpenapiFirst::Middlewares::RequestValidation, File.expand_path('../data/petstore-expanded.yaml', __dir__))
38+
use(OpenapiFirst::Middlewares::RequestValidation, spec: File.expand_path('../data/petstore-expanded.yaml', __dir__))
3939
run ->(_) {}
4040
end
4141
end
@@ -60,7 +60,7 @@
6060
let(:app) do
6161
Rack::Builder.app do
6262
use(OpenapiFirst::Middlewares::RequestValidation,
63-
spec: File.expand_path('../data/petstore-expanded.yaml', __dir__))
63+
File.expand_path('../data/petstore-expanded.yaml', __dir__))
6464
run ->(_) {}
6565
end
6666
end
@@ -92,8 +92,8 @@
9292
context 'with error_response: :default' do
9393
let(:app) do
9494
Rack::Builder.app do
95-
use OpenapiFirst::Middlewares::RequestValidation, spec: './spec/data/request-body-validation.yaml',
96-
error_response: :default
95+
use OpenapiFirst::Middlewares::RequestValidation, './spec/data/request-body-validation.yaml',
96+
error_response: :default
9797
run ->(_) {}
9898
end
9999
end
@@ -115,8 +115,8 @@ def content_type = 'text/plain'
115115
def status = 409
116116
end
117117
Rack::Builder.app do
118-
use OpenapiFirst::Middlewares::RequestValidation, spec: './spec/data/request-body-validation.yaml',
119-
error_response: custom_class
118+
use OpenapiFirst::Middlewares::RequestValidation, './spec/data/request-body-validation.yaml',
119+
error_response: custom_class
120120
run ->(_) {}
121121
end
122122
end
@@ -133,7 +133,7 @@ def status = 409
133133
let(:app) do
134134
Rack::Builder.app do
135135
use(OpenapiFirst::Middlewares::RequestValidation,
136-
spec: File.expand_path('../data/discriminator-refs.yaml', __dir__))
136+
File.expand_path('../data/discriminator-refs.yaml', __dir__))
137137
run lambda { |_env|
138138
Rack::Response.new('hello', 200).finish
139139
}
@@ -178,8 +178,8 @@ def status = 409
178178
end
179179
end
180180
Rack::Builder.app do
181-
use OpenapiFirst::Middlewares::RequestValidation, spec:,
182-
error_response: false
181+
use OpenapiFirst::Middlewares::RequestValidation, spec,
182+
error_response: false
183183
run lambda { |_env|
184184
Rack::Response.new('hello', 200).finish
185185
}
@@ -197,8 +197,8 @@ def status = 409
197197
context 'with error_response: nil' do
198198
let(:app) do
199199
Rack::Builder.app do
200-
use OpenapiFirst::Middlewares::RequestValidation, spec: './spec/data/request-body-validation.yaml',
201-
error_response: nil
200+
use OpenapiFirst::Middlewares::RequestValidation, './spec/data/request-body-validation.yaml',
201+
error_response: nil
202202
run ->(_) {}
203203
end
204204
end
@@ -214,7 +214,7 @@ def status = 409
214214
describe '#app' do
215215
it 'returns the next app in the stack' do
216216
app = double
217-
expect(described_class.new(app, spec: File.expand_path('../data/petstore.yaml', __dir__)).app).to eq app
217+
expect(described_class.new(app, File.expand_path('../data/petstore.yaml', __dir__)).app).to eq app
218218
end
219219
end
220220
end

spec/middlewares/response_validation_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
end
2626
let(:response) { Rack::Response.new(response_body, status, headers) }
2727

28-
context 'with path to OAD as first argument' do
28+
context 'with path to OAD as spec: argument' do
2929
let(:response_body) { '2' }
3030

3131
let(:app) do
3232
res = response
3333
definition = spec
3434
Rack::Builder.app do
3535
use Rack::Lint
36-
use OpenapiFirst::Middlewares::ResponseValidation, definition
36+
use OpenapiFirst::Middlewares::ResponseValidation, spec: definition
3737
run ->(_env) { res.finish }
3838
end
3939
end
@@ -93,7 +93,7 @@
9393
res = response
9494
definition = spec
9595
Rack::Builder.app do
96-
use OpenapiFirst::Middlewares::ResponseValidation, spec: definition
96+
use OpenapiFirst::Middlewares::ResponseValidation, definition
9797
run ->(_env) { res.finish }
9898
end
9999
end
@@ -255,7 +255,7 @@
255255
context 'when response is invalid' do
256256
let(:app) do
257257
Rack::Builder.new.tap do |builder|
258-
builder.use(described_class, spec: './spec/data/petstore.yaml')
258+
builder.use(described_class, './spec/data/petstore.yaml')
259259
builder.run lambda { |_env|
260260
Rack::Response.new('{"foo": "bar"}', 200, { 'Content-Type' => 'application/json' }).finish
261261
}
@@ -271,7 +271,7 @@
271271
context 'with raise_error: false' do
272272
let(:app) do
273273
Rack::Builder.new.tap do |builder|
274-
builder.use(described_class, spec: './spec/data/petstore.yaml', raise_error: false)
274+
builder.use(described_class, './spec/data/petstore.yaml', raise_error: false)
275275
builder.run lambda { |_env|
276276
Rack::Response.new('{"foo": "bar"}', 200, { 'Content-Type' => 'application/json' }).finish
277277
}
@@ -289,7 +289,7 @@
289289
context 'when response is not valid JSON' do
290290
let(:app) do
291291
Rack::Builder.new.tap do |builder|
292-
builder.use(described_class, spec: './spec/data/petstore.yaml')
292+
builder.use(described_class, './spec/data/petstore.yaml')
293293
builder.run lambda { |_env|
294294
Rack::Response.new('{boofar}', 200, { 'Content-Type' => 'application/json' }).finish
295295
}

0 commit comments

Comments
 (0)