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)
230
230
# @parameter key [String] The header key.
231
231
# @parameter value [String] The header value.
232
232
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
+
233
236
if @indexed
234
237
merge_into ( @indexed , key . downcase , value )
235
238
end
Original file line number Diff line number Diff line change 167
167
end
168
168
169
169
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
171
178
headers [ "Content-Length" ] = 1
172
179
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"
175
182
end
176
183
177
184
it "can add field with indexed hash" do
178
185
expect ( headers . to_h ) . not . to be ( :empty? )
179
186
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"
182
189
end
183
190
end
184
191
You can’t perform that action at this time.
0 commit comments