restful_resource 0.8.25 → 0.8.26
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 497d9ea8fabfad7bf1476db40238c550d76b07d8
|
4
|
+
data.tar.gz: a2a22720cda6d80f92722dbbf916819ddadf5242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49421e9608e455840b389b53cda68b67c18b5257414cba27cec065663e8ff8064df2f5c8c99505e17c088f34fa398fb53220131a1ffbc04a023cdc71e5579cae
|
7
|
+
data.tar.gz: 2bd91a065fba45e08843ce1e0bbd381526cbcc362847e81e32ee84b7c5b0516c0d28a3d76c1be5d57547b88da8821ae8e6cead8a88dfd99d6831ceb110245d8b
|
@@ -33,6 +33,11 @@ module RestfulResource
|
|
33
33
|
RestfulResource::OpenObject.new(parse_json(response.body))
|
34
34
|
end
|
35
35
|
|
36
|
+
def self.delete(id, **params)
|
37
|
+
response = http.delete(member_url(id, params))
|
38
|
+
RestfulResource::OpenObject.new(parse_json(response.body))
|
39
|
+
end
|
40
|
+
|
36
41
|
def self.put(id, data: {}, **params)
|
37
42
|
url = member_url(id, params)
|
38
43
|
|
@@ -17,6 +17,11 @@ module RestfulResource
|
|
17
17
|
Response.new(body: response.body, headers: response.headers, status: response.code)
|
18
18
|
end
|
19
19
|
|
20
|
+
def delete(url)
|
21
|
+
response = RestClient.delete(url, :accept => :json, authorization: @authorization)
|
22
|
+
Response.new(body: response.body, headers: response.headers, status: response.code)
|
23
|
+
end
|
24
|
+
|
20
25
|
def put(url, data: {})
|
21
26
|
begin
|
22
27
|
response = RestClient.put(url, data, :accept => :json, authorization: @authorization)
|
@@ -189,6 +189,17 @@ describe RestfulResource::Base do
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
|
+
describe "#delete" do
|
193
|
+
it "should delete to the member url" do
|
194
|
+
expected_response = RestfulResource::Response.new(body: {deleted: true}.to_json, status: 200)
|
195
|
+
expect_delete('http://api.carwow.co.uk/makes/1', expected_response)
|
196
|
+
|
197
|
+
object = Make.delete(1)
|
198
|
+
|
199
|
+
expect(object.deleted).to be_truthy
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
192
203
|
describe ".as_json" do
|
193
204
|
before :each do
|
194
205
|
expected_response = RestfulResource::Response.new(body: [{name: 'Audi', slug: 'Audi-Slug'}, {name: 'Fiat', slug: 'Fiat-Slug'}].to_json)
|
@@ -22,6 +22,11 @@ describe RestfulResource::HttpClient do
|
|
22
22
|
expect(response.status).to eq 200
|
23
23
|
end
|
24
24
|
|
25
|
+
it 'should execute delete' do
|
26
|
+
response = @http_client.delete('http://httpbin.org/delete')
|
27
|
+
expect(response.status).to eq 200
|
28
|
+
end
|
29
|
+
|
25
30
|
it 'put should raise error 422' do
|
26
31
|
expect { @http_client.put('http://httpbin.org/status/422', data: { name: 'Mad cow' }) }.to raise_error(RestfulResource::HttpClient::UnprocessableEntity)
|
27
32
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,6 +12,10 @@ def expect_get(url, response)
|
|
12
12
|
expect(@mock_http).to receive(:get).with(url).and_return(response)
|
13
13
|
end
|
14
14
|
|
15
|
+
def expect_delete(url, response)
|
16
|
+
expect(@mock_http).to receive(:delete).with(url).and_return(response)
|
17
|
+
end
|
18
|
+
|
15
19
|
def expect_put(url, response, data: {})
|
16
20
|
expect(@mock_http).to receive(:put).with(url, data: data).and_return(response)
|
17
21
|
end
|