Compare commits
No commits in common. "7eaa8eacf872adecd313363b7c7557e8e7c73e0c" and "1ae6c0247212a18a6353606906f34ac574fc2825" have entirely different histories.
7eaa8eacf8
...
1ae6c02472
3
app.rb
3
app.rb
|
|
@ -66,9 +66,6 @@ class App < Roda
|
||||||
rescue URI::BadURIError
|
rescue URI::BadURIError
|
||||||
response.status = 400
|
response.status = 400
|
||||||
return {message: "invalid url parameter"}.to_json
|
return {message: "invalid url parameter"}.to_json
|
||||||
rescue OpenURI::HTTPError
|
|
||||||
response.status = 400
|
|
||||||
return {message: "url not found"}.to_json
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,14 +65,4 @@ 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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue