change request to use the /links path, to fit more into a RESTful API
format + also renamed the test to better describe the behaviorpull/21/head
parent
4a82174526
commit
d1a0fc0222
|
|
@ -13,15 +13,16 @@ end
|
||||||
|
|
||||||
describe "Submit API request to create new link" do
|
describe "Submit API request to create new link" do
|
||||||
include Rack::Test::Methods
|
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 = {
|
data = {
|
||||||
url: 'http://google.com'
|
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
|
expect(last_response).to be_ok
|
||||||
response_json = JSON.parse(last_response.body)
|
response_json = JSON.parse(last_response.body)
|
||||||
expect(response_json['url']).to eq(data[:url])
|
expect(response_json['url']).to eq(data[:url])
|
||||||
expect(response_json['code']).not_to eq(nil)
|
expect(response_json['code']).not_to eq(nil)
|
||||||
|
expect(response_json['link']).to include(response_json['code'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue