kintone 0.1.4 → 0.1.5

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.rubocop.yml +11 -1
  4. data/.travis.yml +15 -1
  5. data/Guardfile +2 -2
  6. data/README.md +4 -0
  7. data/kintone.gemspec +3 -5
  8. data/lib/kintone/api.rb +18 -24
  9. data/lib/kintone/api/guest.rb +6 -2
  10. data/lib/kintone/command/accessor.rb +1 -1
  11. data/lib/kintone/command/guests.rb +1 -1
  12. data/lib/kintone/command/record.rb +1 -1
  13. data/lib/kintone/command/records.rb +3 -2
  14. data/lib/kintone/kintone_error.rb +11 -0
  15. data/lib/kintone/query.rb +1 -1
  16. data/lib/kintone/version.rb +1 -1
  17. data/spec/kintone/api/guest_spec.rb +98 -10
  18. data/spec/kintone/api_spec.rb +186 -75
  19. data/spec/kintone/command/apis_spec.rb +70 -8
  20. data/spec/kintone/command/app_acl_spec.rb +21 -6
  21. data/spec/kintone/command/app_spec.rb +22 -2
  22. data/spec/kintone/command/apps_spec.rb +25 -2
  23. data/spec/kintone/command/bulk_request_spec.rb +22 -2
  24. data/spec/kintone/command/field_acl_spec.rb +25 -7
  25. data/spec/kintone/command/file_spec.rb +28 -12
  26. data/spec/kintone/command/form_spec.rb +23 -6
  27. data/spec/kintone/command/guests_spec.rb +44 -4
  28. data/spec/kintone/command/record_acl_spec.rb +27 -8
  29. data/spec/kintone/command/record_spec.rb +77 -10
  30. data/spec/kintone/command/records_spec.rb +157 -15
  31. data/spec/kintone/command/space_body_spec.rb +25 -7
  32. data/spec/kintone/command/space_guests_spec.rb +22 -2
  33. data/spec/kintone/command/space_members_spec.rb +47 -13
  34. data/spec/kintone/command/space_spec.rb +49 -19
  35. data/spec/kintone/command/space_thread_spec.rb +26 -2
  36. data/spec/kintone/command/template_space_spec.rb +37 -20
  37. data/spec/kintone/kintone_error_spec.rb +22 -0
  38. data/spec/spec_helper.rb +3 -0
  39. metadata +17 -27
@@ -13,8 +13,11 @@ describe Kintone::Command::SpaceThread do
13
13
  'https://example.cybozu.com/k/v1/space/thread.json'
14
14
  )
15
15
  .with(body: request_body)
16
- .to_return(body: '{}', status: 200,
17
- headers: { 'Content-type' => 'application/json' })
16
+ .to_return(
17
+ body: '{}',
18
+ status: 200,
19
+ headers: { 'Content-type' => 'application/json' }
20
+ )
18
21
  end
19
22
 
20
23
  subject { target.update(id, name: name, body: body) }
@@ -49,5 +52,26 @@ describe Kintone::Command::SpaceThread do
49
52
  with_them do
50
53
  it { expect(subject).to be_truthy }
51
54
  end
55
+
56
+ context 'fail to request' do
57
+ before(:each) do
58
+ stub_request(
59
+ :put,
60
+ 'https://example.cybozu.com/k/v1/space/thread.json'
61
+ )
62
+ .with(body: request_body)
63
+ .to_return(
64
+ body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
65
+ status: 500,
66
+ headers: { 'Content-Type' => 'application/json' }
67
+ )
68
+ end
69
+
70
+ let(:name) { 'example thread' }
71
+ let(:body) { '<b>awesome thread!</b>' }
72
+ let(:request_body) { '{"id":1,"name":"example thread","body":"<b>awesome thread!</b>"}' }
73
+
74
+ it { expect { subject }.to raise_error Kintone::KintoneError }
75
+ end
52
76
  end
53
77
  end
@@ -7,36 +7,53 @@ describe Kintone::Command::TemplateSpace do
7
7
  let(:api) { Kintone::Api.new('example.cybozu.com', 'Administrator', 'cybozu') }
8
8
 
9
9
  describe '#create' do
10
+ before(:each) do
11
+ stub_request(
12
+ :post,
13
+ 'https://example.cybozu.com/k/v1/template/space.json'
14
+ )
15
+ .with(body: request_data.to_json)
16
+ .to_return(
17
+ body: '{"id":"1"}',
18
+ status: 200,
19
+ headers: { 'Content-type' => 'application/json' }
20
+ )
21
+ end
22
+
10
23
  subject { target.create(id, name, members, is_guest: is_guest, fixed_member: fixed_member) }
11
24
 
12
- context '' do
25
+ let(:id) { 1 }
26
+ let(:name) { 'sample space' }
27
+ let(:members) { [] }
28
+ let(:is_guest) { false }
29
+ let(:fixed_member) { false }
30
+ let(:request_data) do
31
+ {
32
+ id: id,
33
+ name: name,
34
+ members: members,
35
+ isGuest: is_guest,
36
+ fixedMember: fixed_member
37
+ }
38
+ end
39
+
40
+ it { expect(subject).to eq 'id' => '1' }
41
+
42
+ context 'fail to request' do
13
43
  before(:each) do
14
44
  stub_request(
15
45
  :post,
16
46
  'https://example.cybozu.com/k/v1/template/space.json'
17
47
  )
18
48
  .with(body: request_data.to_json)
19
- .to_return(body: "{\"id\":\"1\"}", status: 200,
20
- headers: { 'Content-type' => 'application/json' })
21
- end
22
-
23
- let(:id) { 1 }
24
- let(:name) { 'sample space' }
25
- let(:members) { [] }
26
- let(:is_guest) { false }
27
- let(:fixed_member) { false }
28
-
29
- def request_data
30
- {
31
- id: id,
32
- name: name,
33
- members: members,
34
- isGuest: is_guest,
35
- fixedMember: fixed_member
36
- }
49
+ .to_return(
50
+ body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
51
+ status: 500,
52
+ headers: { 'Content-Type' => 'application/json' }
53
+ )
37
54
  end
38
55
 
39
- it { expect(subject).to eq 'id' => '1' }
56
+ it { expect { subject }.to raise_error Kintone::KintoneError }
40
57
  end
41
58
  end
42
59
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'kintone/kintone_error'
3
+
4
+ describe Kintone::KintoneError do
5
+ let(:target) { Kintone::KintoneError.new(messages, http_status) }
6
+
7
+ describe '#message' do
8
+ subject { target.message }
9
+
10
+ let(:messages) do
11
+ {
12
+ 'message' => '不正なJSON文字列です。',
13
+ 'id' => '1505999166-897850006',
14
+ 'code' => 'CB_IJ01'
15
+ }
16
+ end
17
+
18
+ let(:http_status) { 500 }
19
+
20
+ it { is_expected.to eq '500 [CB_IJ01] 不正なJSON文字列です。(1505999166-897850006)' }
21
+ end
22
+ end
@@ -2,3 +2,6 @@ require 'rubygems'
2
2
  require 'kintone'
3
3
  require 'webmock/rspec'
4
4
  require 'rspec-parameterized'
5
+ require 'coveralls'
6
+
7
+ Coveralls.wear!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kintone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rikiya Kawakami
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-07 00:00:00.000000000 Z
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 3.0.0
75
+ version: '3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 3.0.0
82
+ version: '3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.24.1
89
+ version: 0.44.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.24.1
96
+ version: 0.44.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: webmock
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -109,21 +109,21 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.18'
111
111
  - !ruby/object:Gem::Dependency
112
- name: guard-rspec
112
+ name: rspec-parameterized
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 0.1.2
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 0.1.2
125
125
  - !ruby/object:Gem::Dependency
126
- name: guard-rubocop
126
+ name: coveralls
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -136,20 +136,6 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: rspec-parameterized
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 0.1.2
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 0.1.2
153
139
  description: kintone API client for Ruby.
154
140
  email:
155
141
  - ricky.k.yang@gmail.com
@@ -157,6 +143,7 @@ executables: []
157
143
  extensions: []
158
144
  extra_rdoc_files: []
159
145
  files:
146
+ - ".coveralls.yml"
160
147
  - ".gitignore"
161
148
  - ".rspec"
162
149
  - ".rubocop.yml"
@@ -190,6 +177,7 @@ files:
190
177
  - lib/kintone/command/space_members.rb
191
178
  - lib/kintone/command/space_thread.rb
192
179
  - lib/kintone/command/template_space.rb
180
+ - lib/kintone/kintone_error.rb
193
181
  - lib/kintone/query.rb
194
182
  - lib/kintone/query/extension.rb
195
183
  - lib/kintone/type.rb
@@ -218,6 +206,7 @@ files:
218
206
  - spec/kintone/command/space_spec.rb
219
207
  - spec/kintone/command/space_thread_spec.rb
220
208
  - spec/kintone/command/template_space_spec.rb
209
+ - spec/kintone/kintone_error_spec.rb
221
210
  - spec/kintone/query_spec.rb
222
211
  - spec/kintone/type/record_spec.rb
223
212
  - spec/spec_helper.rb
@@ -241,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
230
  version: '0'
242
231
  requirements: []
243
232
  rubyforge_project:
244
- rubygems_version: 2.2.2
233
+ rubygems_version: 2.6.8
245
234
  signing_key:
246
235
  specification_version: 4
247
236
  summary: kintone API client for Ruby.
@@ -266,6 +255,7 @@ test_files:
266
255
  - spec/kintone/command/space_spec.rb
267
256
  - spec/kintone/command/space_thread_spec.rb
268
257
  - spec/kintone/command/template_space_spec.rb
258
+ - spec/kintone/kintone_error_spec.rb
269
259
  - spec/kintone/query_spec.rb
270
260
  - spec/kintone/type/record_spec.rb
271
261
  - spec/spec_helper.rb