@@ -97,7 +97,7 @@ Public Function Specs() As SpecSuite
97
97
Request.AddParameter "A B" , " !""#$%&'"
98
98
Request.Method = httpGET
99
99
100
- .Expect(Request.FormattedResource).ToEqual "?A%20B=%20 %21%22%23%24%25%26%27"
100
+ .Expect(Request.FormattedResource).ToEqual "?A+B=+ %21%22%23%24%25%26%27"
101
101
End With
102
102
103
103
With Specs.It("should include cachebreaker in FormattedResource by default" )
@@ -144,7 +144,7 @@ Public Function Specs() As SpecSuite
144
144
.Expect(Request.Body).ToEqual "{""A"":123}"
145
145
146
146
Request.Method = httpPOST
147
- .Expect(Request.Body).ToEqual "{""A "":123 ,""b "":456 }"
147
+ .Expect(Request.Body).ToEqual "{""b "":456 ,""A "":123 }"
148
148
End With
149
149
150
150
With Specs.It("should use given client base url for FullUrl only if BaseUrl isn't already set" )
@@ -175,25 +175,20 @@ Public Function Specs() As SpecSuite
175
175
.Expect(Request.FullUrl("facebook.com/api/" )).ToEqual "https://facebook.com/api/status"
176
176
End With
177
177
178
- With Specs.It("should user form-urlencoded content type for non-GET requests with parameters " )
178
+ With Specs.It("should include content- type based on specified format " )
179
179
Set Request = New RestRequest
180
180
181
181
Request.AddParameter "A" , 123
182
182
Request.Method = httpPOST
183
183
184
- .Expect(Request.ContentType).ToEqual "application/x-www-form-urlencoded;charset=UTF-8"
185
- End With
186
-
187
- With Specs.It("should use application/json for GET requests with parameters and requests without parameters" )
188
- Set Request = New RestRequest
189
-
190
- Request.Method = httpPOST
184
+ ' JSON by default
191
185
.Expect(Request.ContentType).ToEqual "application/json"
192
186
193
- Request.AddParameter "A" , 123
194
- Request.Method = httpGET
195
-
187
+ Request.Format = json
196
188
.Expect(Request.ContentType).ToEqual "application/json"
189
+
190
+ Request.Format = formurlencoded
191
+ .Expect(Request.ContentType).ToEqual "application/x-www-form-urlencoded;charset=UTF-8"
197
192
End With
198
193
199
194
With Specs.It("should override existing headers, url segments, and parameters" )
@@ -260,6 +255,23 @@ Public Function Specs() As SpecSuite
260
255
.Expect(Request.Body).ToEqual "Howdy!"
261
256
End With
262
257
258
+ With Specs.It("should format body based on set format" )
259
+ Set Request = New RestRequest
260
+ Request.Method = httpPOST
261
+
262
+ Request.AddParameter "A" , 123
263
+ Request.AddParameter "B" , "Howdy!"
264
+
265
+ ' JSON by default
266
+ .Expect(Request.Body).ToEqual "{""A"":123,""B"":""Howdy!""}"
267
+
268
+ Request.Format = json
269
+ .Expect(Request.Body).ToEqual "{""A"":123,""B"":""Howdy!""}"
270
+
271
+ Request.Format = formurlencoded
272
+ .Expect(Request.Body).ToEqual "A=123&B=Howdy%21"
273
+ End With
274
+
263
275
InlineRunner.RunSuite Specs
264
276
End Function
265
277
0 commit comments