kintone-client 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kintone/client/client.rb +1 -1
- data/lib/kintone/client/error.rb +3 -2
- data/lib/kintone/client/version.rb +1 -1
- data/spec/kintone/client/record_post_spec.rb +25 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8405538519f116448d017e5c80731bff2914fa5
|
4
|
+
data.tar.gz: faf00bbceed1434aec64b54f004d2a7f589c3621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9335cace6fe308ed569b8578c430e23fcc2d40bdfa7caf69c51437ccfc28fb258695bbc6ae8eac420d6801570a993e959ef546c38402a1bf9181ef5c2c554067
|
7
|
+
data.tar.gz: b5607d1e1afb62d4b58819fd147642badb3fddf12abebfb4abaaa814532c4f16dbe66c8a1e6033e3abba9ff9c65a6dff93b83553e602176df3a06cf2f94bea5a
|
@@ -74,7 +74,7 @@ class Kintone::Client
|
|
74
74
|
body = response.body
|
75
75
|
|
76
76
|
if response.status != 200
|
77
|
-
raise body.kind_of?(Hash) ? Kintone::Error.new(body) : body.inspect
|
77
|
+
raise body.kind_of?(Hash) ? Kintone::Error.new(body, @path, method_name, params) : body.inspect
|
78
78
|
end
|
79
79
|
|
80
80
|
body
|
data/lib/kintone/client/error.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
class Kintone::Error < StandardError
|
2
2
|
attr_reader :response
|
3
3
|
|
4
|
-
def initialize(response)
|
5
|
-
|
4
|
+
def initialize(response, path, method_name, params)
|
5
|
+
message = [response['message'], path, method_name, params].join(' ')
|
6
|
+
super(message)
|
6
7
|
@response = response
|
7
8
|
end
|
8
9
|
end
|
@@ -60,5 +60,30 @@ describe Kintone::Client do
|
|
60
60
|
result = client.record.post_json(unexpanded_request)
|
61
61
|
expect(result).to eq response
|
62
62
|
end
|
63
|
+
|
64
|
+
context 'when error happens' do
|
65
|
+
let(:request) do
|
66
|
+
{"app"=>1972}
|
67
|
+
end
|
68
|
+
|
69
|
+
let(:response) do
|
70
|
+
{"message"=>"不正なJSON文字列です。", "id"=>"1505999166-897850006", "code"=>"CB_IJ01"}
|
71
|
+
end
|
72
|
+
|
73
|
+
it do
|
74
|
+
client = kintone_client do |stub|
|
75
|
+
stub.post('/k/v1/record.json') do |env|
|
76
|
+
expect(env.body).to eq JSON.dump(request)
|
77
|
+
expect(env.request_headers['X-Cybozu-Authorization']).to eq TEST_AUTH_HEADER
|
78
|
+
expect(env.request_headers['Content-Type']).to eq 'application/json'
|
79
|
+
[400, {'Content-Type' => 'json'}, JSON.dump(response)]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
expect {
|
84
|
+
client.record.post_json(request)
|
85
|
+
}.to raise_error(Kintone::Error, [response['message'], 'record', 'post', request].join(' '))
|
86
|
+
end
|
87
|
+
end
|
63
88
|
end
|
64
89
|
end
|