cobot_client 1.3.1 → 1.4.0

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: 3e188955232fa00887f8ddabbe4abed63cfd85eb
4
- data.tar.gz: 181f88d1cba96c0f82b2c4a21447e2dec24adc8f
3
+ metadata.gz: 13ac71d15e9711762794ea7fb9a6ff5457aa7abe
4
+ data.tar.gz: c89cdc584f0fe68265e96f1cbb5f3b5fd88bf95f
5
5
  SHA512:
6
- metadata.gz: a7bccd4b1af3eda2ab8fa400c011706e8f35ea83acf1318d07660726ff3e83863f6b8b8e046edf0c693e9ee8cb0fe0784aae0870ea760ed4b3eae0e281757a69
7
- data.tar.gz: 8030ca5db582cd4e3377c782a7430ba01fbe8d86f4ac1aee0fe14a2198624b5bea31d09b440dfaf78f12fba8a956e59932f521aee77ad65f28acacbe0b5d8c71
6
+ metadata.gz: ef3a440c62cbff572de3e264df0b107e77d302a0d9f214e53ab7c6edb4befdef812f03bebefa95ae5737d6c3066caacabd0109382b350c23520a8ba76139d98a
7
+ data.tar.gz: e383f6e75624c39d239ddd15c42defc3452c1b0f2c3ceeb72f6cdcc91da5b6f57f7aa220ceea19fa360cadd2b062e07a4c95d1849d8f9319c0cd708e54cfbac4
@@ -40,6 +40,10 @@ module CobotClient
40
40
  request :put, *args
41
41
  end
42
42
 
43
+ def patch(*args)
44
+ request :patch, *args
45
+ end
46
+
43
47
  # args: either a full URL or subdomain, path, plus an optional params hash
44
48
  def get(*args)
45
49
  url, subdomain, path, params = parse_args(*args)
@@ -1,3 +1,3 @@
1
1
  module CobotClient
2
- VERSION = "1.3.1"
2
+ VERSION = '1.4.0'
3
3
  end
@@ -124,6 +124,56 @@ describe CobotClient::ApiClient do
124
124
  end
125
125
  end
126
126
 
127
+ context '#patch' do
128
+ it 'calls rest client' do
129
+ expect(RestClient).to receive(:patch).with(
130
+ 'https://co-up.cobot.me/api/invoices',
131
+ {id: '1'}.to_json,
132
+ 'Content-Type' => 'application/json',
133
+ 'User-Agent' => 'test agent',
134
+ 'Authorization' => 'Bearer token-123') { default_response }
135
+
136
+ api_client.patch 'co-up', '/invoices', {id: '1'}
137
+ end
138
+
139
+ it 'accepts a url' do
140
+ expect(RestClient).to receive(:patch).with(
141
+ 'https://co-up.cobot.me/api/invoices',
142
+ {id: '1'}.to_json,
143
+ 'Content-Type' => 'application/json',
144
+ 'User-Agent' => 'test agent',
145
+ 'Authorization' => 'Bearer token-123') { default_response }
146
+
147
+ api_client.patch 'https://co-up.cobot.me/api/invoices', {id: '1'}
148
+ end
149
+
150
+ it 'returns the response json' do
151
+ allow(RestClient).to receive(:patch) { double(:response, code: 200, body: [{number: 1}].to_json) }
152
+
153
+ expect(api_client.patch('co-up', '/invoices', {})).to eql([{number: 1}])
154
+ end
155
+
156
+ it 'returns nil when the status code is 204' do
157
+ allow(RestClient).to receive(:patch) { double(:response, body: '', code: 204) }
158
+
159
+ expect(api_client.patch('co-up', '/invoices', {})).to be_nil
160
+ end
161
+
162
+ it 'retries a 502 error' do
163
+ @times = 0
164
+ allow(RestClient).to receive(:patch) do
165
+ if @times < 3
166
+ @times += 1
167
+ fail RestClient::BadGateway
168
+ else
169
+ double(code: 200, body: {success: true}.to_json)
170
+ end
171
+ end
172
+
173
+ expect(api_client.patch('co-up', '/invoices', {})).to eql(success: true)
174
+ end
175
+ end
176
+
127
177
  context '#post' do
128
178
  it 'calls rest client' do
129
179
  expect(RestClient).to receive(:post).with(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobot_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Lang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-05 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus