restful_resource 0.8.25 → 0.8.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc8f7f1648017b8b876ddaf37fd968705aa40eea
4
- data.tar.gz: ffd91357a0da48580f4d6e476ce5ad843679fbdf
3
+ metadata.gz: 497d9ea8fabfad7bf1476db40238c550d76b07d8
4
+ data.tar.gz: a2a22720cda6d80f92722dbbf916819ddadf5242
5
5
  SHA512:
6
- metadata.gz: b517ceea2ba8d78682b2e1ae38333d5086aba45e60d15572afceb8985023edf821b086da41e797df93dfb77ca2e8a38dac2a0baa01d3b45dab464951a39c13d8
7
- data.tar.gz: 581fe30e0e727446150bdb5349582c9fd321b00e71b969719c588b9cfa029129f02ece8cff24fa0f7858b4a7014fd56c3e71390d4d434e217ec77059e7a4795f
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)
@@ -1,3 +1,3 @@
1
1
  module RestfulResource
2
- VERSION = "0.8.25"
2
+ VERSION = "0.8.26"
3
3
  end
@@ -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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.25
4
+ version: 0.8.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Santoro