diff --git a/spec/create_spec.rb b/spec/create_spec.rb index c814803..0ce9011 100644 --- a/spec/create_spec.rb +++ b/spec/create_spec.rb @@ -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 -