From d1a0fc02222a7c4099269d77faddd0c3845eeebd Mon Sep 17 00:00:00 2001 From: Adam Townsend Date: Thu, 12 Oct 2023 11:32:00 -0700 Subject: [PATCH] change request to use the /links path, to fit more into a RESTful API format + also renamed the test to better describe the behavior --- spec/create_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/create_spec.rb b/spec/create_spec.rb index 79deef8..39cebfa 100644 --- a/spec/create_spec.rb +++ b/spec/create_spec.rb @@ -13,15 +13,16 @@ end describe "Submit API request to create new link" do include Rack::Test::Methods - it "should return link data in json format" do + it "should return link data in json format when a valid url is entered" do data = { url: 'http://google.com' } - post('/create', data.to_json, "CONTENT_TYPE" => "application/json") + post('/links', data.to_json, "CONTENT_TYPE" => "application/json") expect(last_response).to be_ok response_json = JSON.parse(last_response.body) expect(response_json['url']).to eq(data[:url]) expect(response_json['code']).not_to eq(nil) + expect(response_json['link']).to include(response_json['code']) end end