File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,9 @@ def merge(headers)
230230 # @parameter key [String] The header key.
231231 # @parameter value [String] The header value.
232232 def []= key , value
233+ # The value MUST be a string, so we convert it to a string to prevent errors later on.
234+ value = value . to_s
235+
233236 if @indexed
234237 merge_into ( @indexed , key . downcase , value )
235238 end
Original file line number Diff line number Diff line change 167167 end
168168
169169 with "#[]=" do
170- it "can add field" do
170+ it "can add field with a String value" do
171+ headers [ "Content-Length" ] = "1"
172+
173+ expect ( headers . fields . last ) . to be == [ "Content-Length" , "1" ]
174+ expect ( headers [ "content-length" ] ) . to be == "1"
175+ end
176+
177+ it "can add field with an Integer value" do
171178 headers [ "Content-Length" ] = 1
172179
173- expect ( headers . fields . last ) . to be == [ "Content-Length" , 1 ]
174- expect ( headers [ "content-length" ] ) . to be == 1
180+ expect ( headers . fields . last ) . to be == [ "Content-Length" , "1" ]
181+ expect ( headers [ "content-length" ] ) . to be == "1"
175182 end
176183
177184 it "can add field with indexed hash" do
178185 expect ( headers . to_h ) . not . to be ( :empty? )
179186
180- headers [ "Content-Length" ] = 1
181- expect ( headers [ "content-length" ] ) . to be == 1
187+ headers [ "Content-Length" ] = "1"
188+ expect ( headers [ "content-length" ] ) . to be == "1"
182189 end
183190 end
184191
You can’t perform that action at this time.
0 commit comments