File tree 2 files changed +21
-4
lines changed
lib/pact_broker/api/resources
spec/lib/pact_broker/api/resources
2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,17 @@ def allowed_methods
20
20
[ "GET" , "PUT" ]
21
21
end
22
22
23
+ def malformed_request?
24
+ begin
25
+ JSON . load ( pact_content )
26
+ false
27
+ rescue
28
+ response . headers [ 'Content-Type' ] = 'application/json'
29
+ response . body = { error : 'Invalid JSON' } . to_json
30
+ true
31
+ end
32
+ end
33
+
23
34
def resource_exists?
24
35
@pact = pact_service . find_pact ( identifier_from_path )
25
36
@pact != nil
Original file line number Diff line number Diff line change @@ -17,14 +17,20 @@ module Resources
17
17
context "with invalid JSON" do
18
18
19
19
before do
20
- put ""
20
+ put "/pacts/provider/Provider/consumer/Consumer/version/1.2" , '{' , { 'CONTENT_TYPE' => "application/json" }
21
21
end
22
22
23
- it "returns a 400 response"
23
+ it "returns a 400 response" do
24
+ expect ( last_response . status ) . to eq 400
25
+ end
24
26
25
- it "returns a JSON body"
27
+ it "returns a JSON content type" do
28
+ expect ( last_response . headers [ 'Content-Type' ] ) . to eq "application/json"
29
+ end
26
30
27
- it "returns an error message"
31
+ it "returns an error message" do
32
+ expect ( JSON . parse ( last_response . body ) ) . to eq "error" => "Invalid JSON"
33
+ end
28
34
end
29
35
end
30
36
You can’t perform that action at this time.
0 commit comments