cobot_client 1.3.1 → 1.4.0
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 +4 -4
- data/lib/cobot_client/api_client.rb +4 -0
- data/lib/cobot_client/version.rb +1 -1
- data/spec/cobot_client/api_client_spec.rb +50 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13ac71d15e9711762794ea7fb9a6ff5457aa7abe
|
4
|
+
data.tar.gz: c89cdc584f0fe68265e96f1cbb5f3b5fd88bf95f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef3a440c62cbff572de3e264df0b107e77d302a0d9f214e53ab7c6edb4befdef812f03bebefa95ae5737d6c3066caacabd0109382b350c23520a8ba76139d98a
|
7
|
+
data.tar.gz: e383f6e75624c39d239ddd15c42defc3452c1b0f2c3ceeb72f6cdcc91da5b6f57f7aa220ceea19fa360cadd2b062e07a4c95d1849d8f9319c0cd708e54cfbac4
|
data/lib/cobot_client/version.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2016-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|