From 581601d8f70f5e27285641fc2657133a7b9e182b Mon Sep 17 00:00:00 2001 From: Konstantin Munteanu Date: Tue, 4 Oct 2022 16:56:17 +0200 Subject: [PATCH] Fix build for rack 3.0 --- lib/api_valve.rb | 1 + spec/examples/middlewares_spec.rb | 2 +- spec/examples/permissions_spec.rb | 2 +- spec/examples/rewriting_spec.rb | 2 +- spec/support/helper.rb | 4 +++- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/api_valve.rb b/lib/api_valve.rb index 31c4636..c399868 100644 --- a/lib/api_valve.rb +++ b/lib/api_valve.rb @@ -12,6 +12,7 @@ require 'faraday' require 'multi_json' require 'logger' +require 'rack' module ApiValve autoload :Benchmarking, 'api_valve/benchmarking' diff --git a/spec/examples/middlewares_spec.rb b/spec/examples/middlewares_spec.rb index ceb0493..e3d7819 100644 --- a/spec/examples/middlewares_spec.rb +++ b/spec/examples/middlewares_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'Middleware example', type: :feature do let(:builder) { example_app 'middleware' } - let(:app) { builder[0] } + let(:app) { builder } before do stub_request(:get, %r{^http://api.host/api}) diff --git a/spec/examples/permissions_spec.rb b/spec/examples/permissions_spec.rb index 36f7d19..48c8a6a 100644 --- a/spec/examples/permissions_spec.rb +++ b/spec/examples/permissions_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'Permissions example', type: :request do let(:builder) { example_app 'permissions' } - let(:app) { builder[0] } + let(:app) { builder } before do stub_request(:get, %r{^http://api.host/api}) diff --git a/spec/examples/rewriting_spec.rb b/spec/examples/rewriting_spec.rb index 9d47e3b..2a28163 100644 --- a/spec/examples/rewriting_spec.rb +++ b/spec/examples/rewriting_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'Rewriting example', type: :feature do let(:builder) { example_app 'rewriting' } - let(:app) { builder[0] } + let(:app) { builder } before do stub_request(:get, %r{^http://api.host/api}) diff --git a/spec/support/helper.rb b/spec/support/helper.rb index bd498d2..04ad879 100644 --- a/spec/support/helper.rb +++ b/spec/support/helper.rb @@ -1,6 +1,8 @@ module Helper def example_app(example) path = Pathname.new(__FILE__).join("../../../examples/#{example}/config.ru") - Rack::Builder.parse_file(path.to_s) + # In rack 2.x parse_file returns a tuple + app, _config = *Rack::Builder.parse_file(path.to_s) + app end end