Skip to content

Commit cf4adfb

Browse files
Add test for OPTIONS * handling.
1 parent c263672 commit cf4adfb

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

gems/webrick-rack-v3.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
eval_gemfile "../gems.rb"
77

8-
gem "rack", "~> 3.0.1"
8+
gem "rack", "~> 3.2"
99
gem "webrick"
1010
gem "rackup"
11+
12+
# export RACK_CONFORM_SERVER="rackup -s webrick"
13+
# export RACK_CONFORM_ENDPOINT="http://127.0.0.1:9292"

lib/rack/conform/application.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_middleware_body_itself(env)
114114
Middleware::BodyItself.new(self).call(env)
115115
end
116116

117-
def test_options_star(env)
117+
def test_options(env)
118118
request_method = env["REQUEST_METHOD"]
119119
path_info = env["PATH_INFO"]
120120

@@ -129,7 +129,7 @@ def test_method_for(env)
129129

130130
# Special case for OPTIONS * request:
131131
if request_method == "OPTIONS"
132-
return :test_options_star
132+
return :test_options
133133
end
134134

135135
parts = path_info.split("/")

test/rack/conform/options_star.rb renamed to test/rack/conform/options.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,17 @@
1919
ensure
2020
response&.finish
2121
end
22+
23+
it "can handle OPTIONS * request" do
24+
request = Protocol::HTTP::Request.new(
25+
endpoint.scheme, endpoint.authority, "OPTIONS", "*", nil, Protocol::HTTP::Headers.new, nil
26+
)
27+
28+
response = client.call(request)
29+
expect(response.status).to be == 200
30+
if ::Rack::RELEASE > "3.0"
31+
expect(response.read).to be(:start_with?, "OPTIONS *")
32+
end
33+
ensure
34+
response&.finish
35+
end

0 commit comments

Comments
 (0)