added test for an invalid url
This commit is contained in:
+10
-2
@@ -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
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user