diff --git a/lib/rack/conform/application.rb b/lib/rack/conform/application.rb index 90b5afd..ba4321f 100644 --- a/lib/rack/conform/application.rb +++ b/lib/rack/conform/application.rb @@ -43,6 +43,14 @@ def test_echo(env) [200, {}, EchoWrapper.new(env["rack.input"])] end + def test_env(env) + query = Rack::Utils.parse_nested_query(env["QUERY_STRING"]) + key = query["key"] + value = env[key] + + [200, {}, [JSON.dump(value)]] + end + def test_cookies(env) cookies = JSON.parse(env["rack.input"].read) diff --git a/test/rack/conform/request.rb b/test/rack/conform/request.rb new file mode 100644 index 0000000..4c01537 --- /dev/null +++ b/test/rack/conform/request.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# Released under the MIT License. +# Copyright, 2022, by Samuel Williams. + +require "client_context" +include ClientContext + +it "has REQUEST_PATH set correctly" do + response = client.get("/env?key=REQUEST_PATH") + expect(response.status).to be == 200 + + body = JSON.parse(response.body.read) + expect(body).to be == "/env" +ensure + response&.finish +end