From d78e361c295b0bfb570bd625e23c6114bc8a2ddf Mon Sep 17 00:00:00 2001 From: Adam Townsend Date: Thu, 12 Oct 2023 18:25:38 -0700 Subject: [PATCH] added test for validating a url is accessible --- spec/create_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/create_spec.rb b/spec/create_spec.rb index 0ce9011..6b7ecc9 100644 --- a/spec/create_spec.rb +++ b/spec/create_spec.rb @@ -65,4 +65,14 @@ describe "Submit API request to create new link" do response_json = JSON.parse(last_response.body) expect(response_json['message']).to eq('invalid url parameter') end + + it "should return with a 400 status and 'url not found' message when an invalid url is submitted" do + data = { + url: 'http://google.com/example' + } + post('/links', data.to_json, "CONTENT_TYPE" => "application/json") + expect(last_response.status).to eq(400) + response_json = JSON.parse(last_response.body) + expect(response_json['message']).to eq('url not found') + end end