added test for validating a url is accessible

pull/22/head
Adam Townsend 2023-10-12 18:25:38 -07:00
parent 1ae6c02472
commit d78e361c29
1 changed files with 10 additions and 0 deletions

View File

@ -65,4 +65,14 @@ describe "Submit API request to create new link" do
response_json = JSON.parse(last_response.body) response_json = JSON.parse(last_response.body)
expect(response_json['message']).to eq('invalid url parameter') expect(response_json['message']).to eq('invalid url parameter')
end 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 end