restful_resource 0.8.7 → 0.8.8

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: 1c8ff7b54b6bd02de7fac411b98da3cb79a71fc6
4
- data.tar.gz: b31fe25509aef7e1f623d17321be1c29f91def57
3
+ metadata.gz: cc4d1bbfdde924c3b2091f258b2ae0291fa95137
4
+ data.tar.gz: 2fed2298a294dabe54584bf05aa49f9c4ed51e3e
5
5
  SHA512:
6
- metadata.gz: bd6688502d7c5a67dfe6b31e6e83af5b358c76b69e105c20a23c241fce60fa7e68fb2b0bc554784817f1eb6448a6ab61c58ed6e657f64ffb5a9026ba268bed56
7
- data.tar.gz: 88913d9d3bac4ef6a7e68c73e8a10b375191cb9086b2c3e577cf77dc4262d091fe20d5fdc6f8780bd5248171ad536cf77c1838e504d1fa90703951f8094e906b
6
+ metadata.gz: 834ce402bc491c69f8def4d3cba41adfa5e837a3e83265ac1b2520f3f0133624753521f3f4f2008551ea783c62d731c341d81a8799e88f40b9df11c1b5c68031
7
+ data.tar.gz: f322f3af95316c4b5e470ffa0115015f7bc4495aba2c71fe83716db8a55adfa4d6336104073386ca0d83b98ed1d76fc933338c9347f2f1b2c7eb16826bcbc7be
@@ -38,7 +38,9 @@ module RestfulResource
38
38
  end
39
39
 
40
40
  def self.put(id, data: {}, **params)
41
- response = http.put(member_url(id, params), data)
41
+ url = member_url(id, params)
42
+
43
+ response = http.put(url, data: data)
42
44
  self.new(parse_json(response.body))
43
45
  end
44
46
 
@@ -71,7 +73,7 @@ module RestfulResource
71
73
 
72
74
  private
73
75
  def self.merge_url_paths(uri, *paths)
74
- uri.merge(paths.compact.join('/')).to_s
76
+ uri.merge(paths.compact.join('/')).to_s
75
77
  end
76
78
 
77
79
  def self.member_url(id, params)
@@ -80,7 +82,7 @@ module RestfulResource
80
82
  end
81
83
 
82
84
  def self.collection_url(params)
83
- url = merge_url_paths(superclass.base_url, @resource_path, @action_prefix)
85
+ url = merge_url_paths(superclass.base_url, @resource_path, @action_prefix)
84
86
  replace_parameters(url, params)
85
87
  end
86
88
 
@@ -1,3 +1,3 @@
1
1
  module RestfulResource
2
- VERSION = "0.8.7"
2
+ VERSION = "0.8.8"
3
3
  end
@@ -139,18 +139,18 @@ describe RestfulResource::Base do
139
139
  end
140
140
 
141
141
  it 'should put data with no params passed' do
142
- data = {make_slug: 'Audi'}.to_json
142
+ data = {make_slug: 'Audi'}
143
143
 
144
144
  expected_response = RestfulResource::Response.new(body: {name: 'Audi'}.to_json, status: 200)
145
145
  expect_put('http://api.carwow.co.uk/makes/1', expected_response, data: data)
146
146
 
147
- object = Make.put(1, data: data)
147
+ object = Make.put(1, data: {make_slug: 'Audi'})
148
148
 
149
149
  expect(object.name).to eq 'Audi'
150
150
  end
151
151
 
152
152
  it 'should put data with params passed' do
153
- data = {make_slug: 'Audi'}.to_json
153
+ data = {make_slug: 'Audi'}
154
154
 
155
155
  expected_response = RestfulResource::Response.new(body: {name: 'Audi'}.to_json, status: 200)
156
156
  expect_put('http://api.carwow.co.uk/makes/1?make_slug=Volkswagen', expected_response, data: data)
@@ -183,4 +183,3 @@ describe RestfulResource::Base do
183
183
  headers: { links: '<http://api.carwow.co.uk/makes/Volkswagen/models.json?page=6>;rel="last",<http://api.carwow.co.uk/makes/Volkswagen/models.json?page=2>;rel="next"'})
184
184
  end
185
185
  end
186
-
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@ require_relative 'fixtures'
4
4
 
5
5
  RSpec.configure do |config|
6
6
  config.color = true
7
- config.formatter = :progress
7
+ config.formatter = :progress
8
8
  end
9
9
 
10
10
 
@@ -13,11 +13,11 @@ def expect_get(url, response)
13
13
  end
14
14
 
15
15
  def expect_put(url, response, data: {})
16
- expect(@mock_http).to receive(:put).with(url, data).and_return(response)
16
+ expect(@mock_http).to receive(:put).with(url, data: data).and_return(response)
17
17
  end
18
18
 
19
19
  def expect_put_with_unprocessable_entity(url, response, data: {})
20
20
  rest_client_response = OpenStruct.new({body: response.body, headers: response.headers, code: response.status})
21
21
  exception = RestfulResource::HttpClient::UnprocessableEntity.new(rest_client_response)
22
- expect(@mock_http).to receive(:put).with(url, data).and_raise(exception)
22
+ expect(@mock_http).to receive(:put).with(url, data: data).and_raise(exception)
23
23
  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.7
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Santoro