@@ -29,7 +29,7 @@ def test_non_tidewave_route_passes_through
2929 status , headers , body = perform_request ( @app , path : "/" )
3030
3131 assert_equal 200 , status
32- assert_equal "text/plain" , headers [ "Content-Type" ]
32+ assert_equal "text/plain" , response_header ( headers , "Content-Type" )
3333 assert_equal "demo response" , body
3434 assert_equal 1 , @downstream_calls . length
3535 end
@@ -45,7 +45,7 @@ def test_home_route_returns_html
4545 status , headers , body = perform_request ( @app , path : "/tidewave" )
4646
4747 assert_equal 200 , status
48- assert_equal "text/html" , headers [ "Content-Type" ]
48+ assert_equal "text/html" , response_header ( headers , "Content-Type" )
4949 assert_includes body , "https://tidewave.ai/tc/tc.js"
5050 refute_includes body . downcase , "tidewave:config"
5151 end
@@ -73,7 +73,7 @@ def test_security_remote_ip_allowed_when_enabled
7373 status , headers , body = perform_request ( app , path : "/tidewave/config" , remote_addr : "192.168.1.100" )
7474
7575 assert_equal 200 , status
76- assert_equal "application/json" , headers [ "Content-Type" ]
76+ assert_equal "application/json" , response_header ( headers , "Content-Type" )
7777 assert_includes body , "\" tidewave_version\" "
7878 end
7979
@@ -84,7 +84,7 @@ def test_local_ip_detection
8484 status , headers , body = perform_request ( app , path : "/tidewave/config" , remote_addr : ip )
8585
8686 assert_equal 200 , status , "expected #{ ip } to be accepted as a loopback address"
87- assert_equal "application/json" , headers [ "Content-Type" ]
87+ assert_equal "application/json" , response_header ( headers , "Content-Type" )
8888 assert_includes body , "\" tidewave_version\" "
8989 end
9090 end
@@ -120,7 +120,7 @@ def test_config_endpoint_returns_json
120120 )
121121
122122 assert_equal 200 , status
123- assert_equal "application/json" , headers [ "Content-Type" ]
123+ assert_equal "application/json" , response_header ( headers , "Content-Type" )
124124 assert_equal "*" , headers [ "Access-Control-Allow-Origin" ]
125125
126126 payload = JSON . parse ( body )
@@ -240,7 +240,7 @@ def test_upload_endpoint_accepts_valid_screenshot_from_same_origin
240240 expected_path = File . join ( @tmpdir , "tmp" , "tidewave" , "screenshots" , "capture.png" )
241241
242242 assert_equal 200 , status
243- assert_equal "application/json" , headers [ "Content-Type" ]
243+ assert_equal "application/json" , response_header ( headers , "Content-Type" )
244244 assert_equal ( { "status" => "ok" , "path" => expected_path } , JSON . parse ( body ) )
245245 assert_equal valid_png , File . binread ( expected_path )
246246 end
@@ -388,7 +388,7 @@ def test_no_origin_header_allowed
388388 status , headers , body = perform_request ( @app , path : "/tidewave/config" )
389389
390390 assert_equal 200 , status
391- assert_equal "application/json" , headers [ "Content-Type" ]
391+ assert_equal "application/json" , response_header ( headers , "Content-Type" )
392392 assert_includes body , "\" tidewave_version\" "
393393 end
394394
@@ -515,4 +515,12 @@ def collect_body(response)
515515 response . close if response . respond_to? ( :close )
516516 body
517517 end
518+
519+ def response_header ( headers , key )
520+ headers . each do |header , value |
521+ return value if header . to_s . downcase == key . downcase
522+ end
523+
524+ nil
525+ end
518526end
0 commit comments