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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 951cf372212f60ae0f4d23e5082ef2d3f4d45d04
4
- data.tar.gz: f8e03d313b23c9056e5176d0b250ee091a82ff3a
3
+ metadata.gz: f8405538519f116448d017e5c80731bff2914fa5
4
+ data.tar.gz: faf00bbceed1434aec64b54f004d2a7f589c3621
5
5
  SHA512:
6
- metadata.gz: a5ec1cbee49c0444bf05e002d5316ace64c18edba60cf6f6e0c7d5f2eee5757fbe570415dca7643eb6304b7ad00f2ca8c07733bb1d2a3ef944f55d32807ceee2
7
- data.tar.gz: db3afefc783cc053c54c7539f5970daf07845432a304bb09d77809b7ca037d77507bf3450e6614d20e77566d574bdd0395a45fc52bfb4c96d65b3dd1396fe749
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
@@ -1,8 +1,9 @@
1
1
  class Kintone::Error < StandardError
2
2
  attr_reader :response
3
3
 
4
- def initialize(response)
5
- super(response['message'])
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
@@ -1,5 +1,5 @@
1
1
  module Kintone
2
2
  class Client
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kintone-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara