added test for an invalid url

pull/22/head
Adam Townsend 2023-10-12 18:20:35 -07:00
parent 33089e6fbd
commit 11206854ad
1 changed files with 10 additions and 2 deletions

View File

@ -45,8 +45,8 @@ describe "Submit API request to create new link" do
expect(last_response.status).to eq(400)
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 'missing url parameter' message when an empty url is submitted" do
data = {
}
@ -54,7 +54,15 @@ describe "Submit API request to create new link" do
expect(last_response.status).to eq(400)
response_json = JSON.parse(last_response.body)
expect(response_json['message']).to eq('missing url parameter')
end
end
it "should return with a 400 status and 'invalid url parameter' message when an invalid url is submitted" do
data = {
url: 'not-an-url'
}
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('invalid url parameter')
end
end