test/aitch/request_test.rb in aitch-1.2.0 vs test/aitch/request_test.rb in aitch-1.2.1

- old
+ new

@@ -85,10 +85,22 @@ data = stub(to_h: {a: 1}) request = build_request(request_method: "post", data: data).request assert_equal "a=1", request.body end + test "sets json body from array" do + data = [1, 2, 3] + request = build_request( + request_method: "post", + data: data, + content_type: "application/json", + options: {json_parser: JSON} + ).request + + assert_equal "[1,2,3]", request.body + end + test "sets request body from to_s protocol" do data = stub(to_s: "some body") request = build_request(request_method: "post", data: data).request assert_equal "some body", request.body @@ -138,11 +150,11 @@ assert_equal "/some/path", last_request.uri.request_uri assert_equal :post, last_request.method assert_equal "a=1&b=2", last_request.body assert_equal "0.1", last_request.headers["Rendering"] - assert_equal "user:pass", Base64.decode64(last_request.headers["Authorization"].split(" ").last) + assert_equal "user:pass", Base64.decode64(last_request.headers["Authorization"].split.last) end test "performs request when using kwargs" do register_uri(:post, /.+/) @@ -155,10 +167,10 @@ assert_equal "/some/path", last_request.uri.request_uri assert_equal :post, last_request.method assert_equal "a=1&b=2", last_request.body assert_equal "0.1", last_request.headers["Rendering"] - assert_equal "user:pass", Base64.decode64(last_request.headers["Authorization"].split(" ").last) + assert_equal "user:pass", Base64.decode64(last_request.headers["Authorization"].split.last) end test "uses base url" do register_uri(:get, /.+/)