From bbb710a5e185b80aeaf006366bc8a4bac5d58a59 Mon Sep 17 00:00:00 2001 From: Adam Townsend Date: Thu, 12 Oct 2023 19:02:38 -0700 Subject: [PATCH] added test for bad TLD, better named 404 url test --- spec/create_spec.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/create_spec.rb b/spec/create_spec.rb index 6b7ecc9..16611cf 100644 --- a/spec/create_spec.rb +++ b/spec/create_spec.rb @@ -66,7 +66,7 @@ describe "Submit API request to create new link" do 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 + it "should return with a 400 status and 'url not found' message when a 404 url is submitted" do data = { url: 'http://google.com/example' } @@ -75,4 +75,14 @@ describe "Submit API request to create new link" do response_json = JSON.parse(last_response.body) expect(response_json['message']).to eq('url not found') end + + it "should return with a 400 status and 'url not found' message when a URL with no DNS is submitted" do + data = { + url: 'http://bad.tld' + } + 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 does not resolve') + end end