groupdocs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/.travis.yml +5 -0
  2. data/Gemfile +3 -0
  3. data/README.md +141 -0
  4. data/Rakefile +9 -0
  5. data/groupdocs.gemspec +28 -0
  6. data/lib/groupdocs.rb +53 -0
  7. data/lib/groupdocs/api.rb +3 -0
  8. data/lib/groupdocs/api/entity.rb +113 -0
  9. data/lib/groupdocs/api/helpers.rb +5 -0
  10. data/lib/groupdocs/api/helpers/access_helper.rb +56 -0
  11. data/lib/groupdocs/api/helpers/actions_helper.rb +48 -0
  12. data/lib/groupdocs/api/helpers/rest_helper.rb +89 -0
  13. data/lib/groupdocs/api/helpers/status_helper.rb +48 -0
  14. data/lib/groupdocs/api/helpers/url_helper.rb +89 -0
  15. data/lib/groupdocs/api/request.rb +73 -0
  16. data/lib/groupdocs/api/sugar/lookup.rb +48 -0
  17. data/lib/groupdocs/datasource.rb +162 -0
  18. data/lib/groupdocs/datasource/field.rb +44 -0
  19. data/lib/groupdocs/document.rb +513 -0
  20. data/lib/groupdocs/document/annotation.rb +215 -0
  21. data/lib/groupdocs/document/annotation/reply.rb +167 -0
  22. data/lib/groupdocs/document/change.rb +35 -0
  23. data/lib/groupdocs/document/field.rb +27 -0
  24. data/lib/groupdocs/document/metadata.rb +26 -0
  25. data/lib/groupdocs/document/rectangle.rb +24 -0
  26. data/lib/groupdocs/document/view.rb +36 -0
  27. data/lib/groupdocs/errors.rb +10 -0
  28. data/lib/groupdocs/job.rb +201 -0
  29. data/lib/groupdocs/questionnaire.rb +221 -0
  30. data/lib/groupdocs/questionnaire/execution.rb +120 -0
  31. data/lib/groupdocs/questionnaire/page.rb +43 -0
  32. data/lib/groupdocs/questionnaire/question.rb +75 -0
  33. data/lib/groupdocs/questionnaire/question/answer.rb +10 -0
  34. data/lib/groupdocs/storage.rb +37 -0
  35. data/lib/groupdocs/storage/file.rb +248 -0
  36. data/lib/groupdocs/storage/folder.rb +314 -0
  37. data/lib/groupdocs/storage/package.rb +42 -0
  38. data/lib/groupdocs/user.rb +50 -0
  39. data/lib/groupdocs/version.rb +3 -0
  40. data/spec/groupdocs/api/entity_spec.rb +54 -0
  41. data/spec/groupdocs/api/helpers/access_helper_spec.rb +89 -0
  42. data/spec/groupdocs/api/helpers/actions_helper_spec.rb +51 -0
  43. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +187 -0
  44. data/spec/groupdocs/api/helpers/status_helper_spec.rb +85 -0
  45. data/spec/groupdocs/api/helpers/url_helper_spec.rb +93 -0
  46. data/spec/groupdocs/api/request_spec.rb +85 -0
  47. data/spec/groupdocs/datasource/field_spec.rb +50 -0
  48. data/spec/groupdocs/datasource_spec.rb +156 -0
  49. data/spec/groupdocs/document/annotation/reply_spec.rb +179 -0
  50. data/spec/groupdocs/document/annotation_spec.rb +226 -0
  51. data/spec/groupdocs/document/change_spec.rb +35 -0
  52. data/spec/groupdocs/document/field_spec.rb +31 -0
  53. data/spec/groupdocs/document/metadata_spec.rb +26 -0
  54. data/spec/groupdocs/document/rectangle_spec.rb +34 -0
  55. data/spec/groupdocs/document/view_spec.rb +36 -0
  56. data/spec/groupdocs/document_spec.rb +509 -0
  57. data/spec/groupdocs/errors_spec.rb +7 -0
  58. data/spec/groupdocs/job_spec.rb +196 -0
  59. data/spec/groupdocs/questionnaire/execution_spec.rb +136 -0
  60. data/spec/groupdocs/questionnaire/page_spec.rb +50 -0
  61. data/spec/groupdocs/questionnaire/question/answer_spec.rb +11 -0
  62. data/spec/groupdocs/questionnaire/question_spec.rb +84 -0
  63. data/spec/groupdocs/questionnaire_spec.rb +217 -0
  64. data/spec/groupdocs/storage/file_spec.rb +242 -0
  65. data/spec/groupdocs/storage/folder_spec.rb +310 -0
  66. data/spec/groupdocs/storage/package_spec.rb +41 -0
  67. data/spec/groupdocs/storage_spec.rb +27 -0
  68. data/spec/groupdocs/user_spec.rb +53 -0
  69. data/spec/groupdocs_spec.rb +56 -0
  70. data/spec/spec_helper.rb +46 -0
  71. data/spec/support/files/resume.pdf +0 -0
  72. data/spec/support/json/annotation_collaborators_set.json +16 -0
  73. data/spec/support/json/annotation_create.json +12 -0
  74. data/spec/support/json/annotation_list.json +32 -0
  75. data/spec/support/json/annotation_remove.json +9 -0
  76. data/spec/support/json/annotation_replies_create.json +9 -0
  77. data/spec/support/json/annotation_replies_get.json +25 -0
  78. data/spec/support/json/comparison_changes.json +46 -0
  79. data/spec/support/json/comparison_compare.json +8 -0
  80. data/spec/support/json/comparison_document.json +10 -0
  81. data/spec/support/json/datasource_add.json +8 -0
  82. data/spec/support/json/datasource_get.json +22 -0
  83. data/spec/support/json/datasource_remove.json +8 -0
  84. data/spec/support/json/datasource_update.json +8 -0
  85. data/spec/support/json/document_access_info_get.json +14 -0
  86. data/spec/support/json/document_convert.json +8 -0
  87. data/spec/support/json/document_datasource.json +10 -0
  88. data/spec/support/json/document_fields.json +34 -0
  89. data/spec/support/json/document_formats.json +8 -0
  90. data/spec/support/json/document_metadata.json +15 -0
  91. data/spec/support/json/document_questionnaire_create.json +9 -0
  92. data/spec/support/json/document_questionnaires.json +23 -0
  93. data/spec/support/json/document_sharers_remove.json +8 -0
  94. data/spec/support/json/document_sharers_set.json +16 -0
  95. data/spec/support/json/document_views.json +32 -0
  96. data/spec/support/json/file_compress.json +8 -0
  97. data/spec/support/json/file_copy.json +14 -0
  98. data/spec/support/json/file_delete.json +5 -0
  99. data/spec/support/json/file_move.json +14 -0
  100. data/spec/support/json/file_upload.json +8 -0
  101. data/spec/support/json/folder_create.json +8 -0
  102. data/spec/support/json/folder_delete.json +5 -0
  103. data/spec/support/json/folder_list.json +21 -0
  104. data/spec/support/json/folder_move.json +8 -0
  105. data/spec/support/json/folder_sharers_get.json +16 -0
  106. data/spec/support/json/folder_sharers_remove.json +8 -0
  107. data/spec/support/json/folder_sharers_set.json +16 -0
  108. data/spec/support/json/job_add_url.json +8 -0
  109. data/spec/support/json/job_create.json +8 -0
  110. data/spec/support/json/job_documents.json +39 -0
  111. data/spec/support/json/job_file_add.json +8 -0
  112. data/spec/support/json/job_update.json +7 -0
  113. data/spec/support/json/jobs_get.json +52 -0
  114. data/spec/support/json/package_create.json +7 -0
  115. data/spec/support/json/questionnaire_create.json +8 -0
  116. data/spec/support/json/questionnaire_datasources.json +26 -0
  117. data/spec/support/json/questionnaire_execution_create.json +9 -0
  118. data/spec/support/json/questionnaire_execution_status_set.json +8 -0
  119. data/spec/support/json/questionnaire_execution_update.json +8 -0
  120. data/spec/support/json/questionnaire_executions.json +24 -0
  121. data/spec/support/json/questionnaire_get.json +14 -0
  122. data/spec/support/json/questionnaire_remove.json +8 -0
  123. data/spec/support/json/questionnaire_update.json +8 -0
  124. data/spec/support/json/questionnaires_get.json +22 -0
  125. data/spec/support/json/storage_info.json +10 -0
  126. data/spec/support/shared_examples/api/entity.rb +37 -0
  127. data/spec/support/shared_examples/api/helpers/status_helper.rb +12 -0
  128. data/spec/support/shared_examples/api/sugar/lookup.rb +57 -0
  129. metadata +356 -0
@@ -0,0 +1,310 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Storage::Folder do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+ include_examples GroupDocs::Api::Sugar::Lookup
7
+
8
+ describe '.create!' do
9
+ before(:each) do
10
+ mock_api_server(load_json('folder_create'))
11
+ end
12
+
13
+ it 'accepts access credentials hash' do
14
+ lambda do
15
+ described_class.create!('/Test', client_id: 'client_id', private_key: 'private_key')
16
+ end.should_not raise_error(ArgumentError)
17
+ end
18
+
19
+ it 'raises error if path does not start with /' do
20
+ -> { described_class.create!('Test') }.should raise_error(ArgumentError)
21
+ end
22
+
23
+ it 'returns GroupDocs::Storage::Folder object' do
24
+ described_class.stub(find!: described_class.new(id: 1))
25
+ folder = described_class.create!('/Test')
26
+ folder.should be_a(GroupDocs::Storage::Folder)
27
+ end
28
+ end
29
+
30
+ describe '.list!' do
31
+ before(:each) do
32
+ mock_api_server(load_json('folder_list'))
33
+ end
34
+
35
+ it 'accepts access credentials hash' do
36
+ lambda do
37
+ described_class.list!('/', {}, client_id: 'client_id', private_key: 'private_key')
38
+ end.should_not raise_error(ArgumentError)
39
+ end
40
+
41
+ it 'allows passing path' do
42
+ -> { described_class.list!('/test') }.should_not raise_error(ArgumentError)
43
+ end
44
+
45
+ it 'allows passing options' do
46
+ -> { described_class.list!('/', page: 1, count: 1) }.should_not raise_error(ArgumentError)
47
+ end
48
+
49
+ it 'creates new instance of GroupDocs::Storage::Folder and calls #list!' do
50
+ folder = stub('folder')
51
+ GroupDocs::Storage::Folder.should_receive(:new).with(path: '/').and_return(folder)
52
+ folder.should_receive(:list!).with({}, {})
53
+ described_class.list!
54
+ end
55
+ end
56
+
57
+ it { should respond_to(:id) }
58
+ it { should respond_to(:id=) }
59
+ it { should respond_to(:size) }
60
+ it { should respond_to(:size=) }
61
+ it { should respond_to(:folder_count) }
62
+ it { should respond_to(:folder_count=) }
63
+ it { should respond_to(:file_count) }
64
+ it { should respond_to(:file_count=) }
65
+ it { should respond_to(:created_on) }
66
+ it { should respond_to(:created_on=) }
67
+ it { should respond_to(:modified_on) }
68
+ it { should respond_to(:modified_on=) }
69
+ it { should respond_to(:url) }
70
+ it { should respond_to(:url=) }
71
+ it { should respond_to(:name) }
72
+ it { should respond_to(:name=) }
73
+ it { should respond_to(:version) }
74
+ it { should respond_to(:version=) }
75
+ it { should respond_to(:type) }
76
+ it { should respond_to(:type=) }
77
+ it { should respond_to(:access) }
78
+ it { should respond_to(:access=) }
79
+
80
+ describe '#created_on' do
81
+ it 'returns converted to Time object Unix timestamp' do
82
+ subject.created_on = 1330450135
83
+ subject.created_on.should be_a(Time)
84
+ end
85
+ end
86
+
87
+ describe '#modified_on' do
88
+ it 'returns converted to Time object Unix timestamp' do
89
+ subject.modified_on = 1330450135
90
+ subject.modified_on.should be_a(Time)
91
+ end
92
+ end
93
+
94
+ describe '#access' do
95
+ it 'returns converted to human-readable format access mode' do
96
+ subject.should_receive(:parse_access_mode).with(0).and_return(:private)
97
+ subject.access = 0
98
+ subject.access.should == :private
99
+ end
100
+ end
101
+
102
+ describe '#move!' do
103
+ it 'accepts access credentials hash' do
104
+ lambda do
105
+ subject.move!('/Test', client_id: 'client_id', private_key: 'private_key')
106
+ end.should_not raise_error(ArgumentError)
107
+ end
108
+
109
+ it 'raises error if path does not start with /' do
110
+ -> { subject.move!('Test2') }.should raise_error(ArgumentError)
111
+ end
112
+
113
+ it 'sends "Groupdocs-Move" header' do
114
+ mock_api_server(load_json('folder_move'), :'Groupdocs-Move' => 'Test1')
115
+ subject.stub(name: 'Test1')
116
+ subject.move!('/Test2')
117
+ end
118
+
119
+ it 'returns moved to folder path' do
120
+ mock_api_server(load_json('folder_move'))
121
+ moved = subject.move!('/Test2')
122
+ moved.should be_a(String)
123
+ moved.should == '/Test2'
124
+ end
125
+ end
126
+
127
+ describe '#rename!' do
128
+ it 'accepts access credentials hash' do
129
+ lambda do
130
+ subject.rename!('Test2', client_id: 'client_id', private_key: 'private_key')
131
+ end.should_not raise_error(ArgumentError)
132
+ end
133
+
134
+ it 'uses #move! to rename directory' do
135
+ subject.should_receive(:move!).with('/Test2', {}).and_return('/Test2')
136
+ subject.rename!('Test2')
137
+ end
138
+
139
+ it 'strips leading / symbol from new name' do
140
+ subject.stub(move!: '/Test2')
141
+ renamed = subject.rename!('Test2')
142
+ renamed.should be_a(String)
143
+ renamed.should == 'Test2'
144
+ end
145
+ end
146
+
147
+ describe '#copy!' do
148
+ it 'accepts access credentials hash' do
149
+ lambda do
150
+ subject.copy!('/Test2', client_id: 'client_id', private_key: 'private_key')
151
+ end.should_not raise_error(ArgumentError)
152
+ end
153
+
154
+ it 'raises error if path does not start with /' do
155
+ -> { subject.copy!('Test2') }.should raise_error(ArgumentError)
156
+ end
157
+
158
+ it 'sends "Groupdocs-Copy" header' do
159
+ mock_api_server(load_json('folder_move'), :'Groupdocs-Copy' => 'Test1')
160
+ subject.stub(name: 'Test1')
161
+ subject.copy!('/Test2')
162
+ end
163
+
164
+ it 'returns moved to folder path' do
165
+ mock_api_server(load_json('folder_move'))
166
+ moved = subject.copy!('/Test2')
167
+ moved.should be_a(String)
168
+ moved.should == '/Test2'
169
+ end
170
+ end
171
+
172
+ describe '#list!' do
173
+ before(:each) do
174
+ mock_api_server(load_json('folder_list'))
175
+ subject.stub(path: '/Test1')
176
+ end
177
+
178
+ it 'accepts access credentials hash' do
179
+ lambda do
180
+ subject.list!({}, client_id: 'client_id', private_key: 'private_key')
181
+ end.should_not raise_error(ArgumentError)
182
+ end
183
+
184
+ it 'allows passing options' do
185
+ -> { subject.list!(page: 1, count: 1) }.should_not raise_error(ArgumentError)
186
+ end
187
+
188
+ it 'returns array' do
189
+ subject.list!.should be_an(Array)
190
+ end
191
+
192
+ it 'returns empty array if nothing is listed in directory' do
193
+ mock_api_server('{"result": {"entities": []}, "status": "Ok"}')
194
+ subject.list!.should be_empty
195
+ end
196
+
197
+ it 'determines folders in response' do
198
+ subject.list!.detect do |entity|
199
+ entity.id == 1
200
+ end.should be_a(GroupDocs::Storage::Folder)
201
+ end
202
+
203
+ it 'determines files in response' do
204
+ subject.list!.detect do |entity|
205
+ entity.id == 2
206
+ end.should be_a(GroupDocs::Storage::File)
207
+ end
208
+ end
209
+
210
+ describe '#create!' do
211
+ before(:each) do
212
+ mock_api_server(load_json('folder_create'))
213
+ end
214
+
215
+ it 'accepts access credentials hash' do
216
+ lambda do
217
+ subject.create!(client_id: 'client_id', private_key: 'private_key')
218
+ end.should_not raise_error(ArgumentError)
219
+ end
220
+
221
+ it 'calls create! class method and pass parameters to it' do
222
+ subject = described_class.new(name: 'Test1')
223
+ described_class.should_receive(:create!).with('/Test1', {})
224
+ subject.create!
225
+ end
226
+ end
227
+
228
+ describe '#delete!' do
229
+ before(:each) do
230
+ mock_api_server(load_json('folder_delete'))
231
+ end
232
+
233
+ it 'accepts access credentials hash' do
234
+ lambda do
235
+ subject.delete!(client_id: 'client_id', private_key: 'private_key')
236
+ end.should_not raise_error(ArgumentError)
237
+ end
238
+
239
+ it 'determines path by name' do
240
+ subject.should_receive(:name).and_return('Test1')
241
+ subject.delete!
242
+ end
243
+ end
244
+
245
+ describe '#sharers!' do
246
+ before(:each) do
247
+ mock_api_server(load_json('folder_sharers_get'))
248
+ end
249
+
250
+ it 'accepts access credentials hash' do
251
+ lambda do
252
+ subject.sharers!(client_id: 'client_id', private_key: 'private_key')
253
+ end.should_not raise_error(ArgumentError)
254
+ end
255
+
256
+ it 'returns an array of GroupDocs::User objects' do
257
+ users = subject.sharers!
258
+ users.should be_an(Array)
259
+ users.each do |user|
260
+ user.should be_a(GroupDocs::User)
261
+ end
262
+ end
263
+ end
264
+
265
+ describe '#sharers_set!' do
266
+ before(:each) do
267
+ mock_api_server(load_json('folder_sharers_set'))
268
+ end
269
+
270
+ it 'accepts access credentials hash' do
271
+ lambda do
272
+ subject.sharers_set!(%w(test1@email.com), client_id: 'client_id', private_key: 'private_key')
273
+ end.should_not raise_error(ArgumentError)
274
+ end
275
+
276
+ it 'returns an array of GroupDocs::User objects' do
277
+ users = subject.sharers_set!(%w(test1@email.com))
278
+ users.should be_an(Array)
279
+ users.each do |user|
280
+ user.should be_a(GroupDocs::User)
281
+ end
282
+ end
283
+
284
+ it 'clears sharers if empty array is passed' do
285
+ subject.should_receive(:sharers_clear!)
286
+ subject.sharers_set!([])
287
+ end
288
+
289
+ it 'clears sharers if nil is passed' do
290
+ subject.should_receive(:sharers_clear!)
291
+ subject.sharers_set!(nil)
292
+ end
293
+ end
294
+
295
+ describe '#sharers_clear!' do
296
+ before(:each) do
297
+ mock_api_server(load_json('folder_sharers_remove'))
298
+ end
299
+
300
+ it 'accepts access credentials hash' do
301
+ lambda do
302
+ subject.sharers_clear!(client_id: 'client_id', private_key: 'private_key')
303
+ end.should_not raise_error(ArgumentError)
304
+ end
305
+
306
+ it 'clears sharers list and returns nil' do
307
+ subject.sharers_clear!.should be_nil
308
+ end
309
+ end
310
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Storage::Package do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ it { should respond_to(:name) }
8
+ it { should respond_to(:name=) }
9
+ it { should respond_to(:objects) }
10
+ it { should respond_to(:objects=) }
11
+
12
+ describe '#add' do
13
+ it 'adds objects to be packed later' do
14
+ subject.objects = ['object 1']
15
+ subject.objects.should_receive(:<<).with('object 2')
16
+ subject.add('object 2')
17
+ end
18
+
19
+ it 'is aliased to #<<' do
20
+ subject.should respond_to(:<<)
21
+ subject.method(:<<).should == subject.method(:add)
22
+ end
23
+ end
24
+
25
+ describe '#create!' do
26
+ before(:each) do
27
+ mock_api_server(load_json('package_create'))
28
+ subject.objects = [stub(name: 'object 1')]
29
+ end
30
+
31
+ it 'accepts access credentials hash' do
32
+ lambda do
33
+ subject.create!(client_id: 'client_id', private_key: 'private_key')
34
+ end.should_not raise_error(ArgumentError)
35
+ end
36
+
37
+ it 'returns URL for package downloading' do
38
+ subject.create!.should be_a(String)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Storage do
4
+ describe '.info!' do
5
+ before(:each) do
6
+ mock_api_server(load_json('storage_info'))
7
+ end
8
+
9
+ it 'accepts access credentials hash' do
10
+ lambda do
11
+ described_class.info!(client_id: 'client_id', private_key: 'private_key')
12
+ end.should_not raise_error(ArgumentError)
13
+ end
14
+
15
+ it 'returns a hash of information' do
16
+ described_class.info!.should be_a(Hash)
17
+ end
18
+
19
+ it 'converts total space to MB' do
20
+ described_class.info![:total_space].should == '1024 MB'
21
+ end
22
+
23
+ it 'converts available space to MB' do
24
+ described_class.info![:available_space].should == '1020 MB'
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::User do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ it { should respond_to(:id) }
8
+ it { should respond_to(:id=) }
9
+ it { should respond_to(:guid) }
10
+ it { should respond_to(:guid=) }
11
+ it { should respond_to(:nickname) }
12
+ it { should respond_to(:nickname=) }
13
+ it { should respond_to(:first_name) }
14
+ it { should respond_to(:first_name=) }
15
+ it { should respond_to(:last_name) }
16
+ it { should respond_to(:last_name=) }
17
+ it { should respond_to(:primary_email) }
18
+ it { should respond_to(:primary_email=) }
19
+ it { should respond_to(:private_key) }
20
+ it { should respond_to(:private_key=) }
21
+ it { should respond_to(:password_salt) }
22
+ it { should respond_to(:password_salt=) }
23
+ it { should respond_to(:claimed_id) }
24
+ it { should respond_to(:claimed_id=) }
25
+ it { should respond_to(:token) }
26
+ it { should respond_to(:token=) }
27
+ it { should respond_to(:storage) }
28
+ it { should respond_to(:storage=) }
29
+ it { should respond_to(:photo) }
30
+ it { should respond_to(:photo=) }
31
+ it { should respond_to(:active) }
32
+ it { should respond_to(:active=) }
33
+ it { should respond_to(:news_enabled) }
34
+ it { should respond_to(:news_enabled=) }
35
+ it { should respond_to(:signed_up_on) }
36
+ it { should respond_to(:signed_up_on=) }
37
+
38
+ it 'is compatible with response JSON' do
39
+ subject.should respond_to(:pkey=)
40
+ subject.should respond_to(:pswd_salt=)
41
+ subject.should respond_to(:signedupOn=)
42
+ subject.method(:pkey=).should == subject.method(:private_key=)
43
+ subject.method(:pswd_salt=).should == subject.method(:password_salt=)
44
+ subject.method(:signedupOn=).should == subject.method(:signed_up_on=)
45
+ end
46
+
47
+ describe '#signed_up_on' do
48
+ it 'returns converted to Time object Unix timestamp' do
49
+ subject.signed_up_on = 1330450135
50
+ subject.signed_up_on.should be_a(Time)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs do
4
+
5
+ subject { described_class }
6
+ let(:client_id) { '07aaaf95f8eb33a4' }
7
+ let(:private_key) { '5cb711b3a52ffc5d90ee8a0f79206f5a' }
8
+
9
+ describe '.configure' do
10
+ it { should respond_to(:configure) }
11
+
12
+ it 'calls block for self' do
13
+ subject.should_receive(:configure).and_yield(subject)
14
+ subject.configure do |api|
15
+ api.client_id = client_id
16
+ api.private_key = private_key
17
+ end
18
+ end
19
+
20
+ it 'saves client ID for further access' do
21
+ subject.should_receive(:client_id=).with(client_id).and_return(client_id)
22
+ subject.configure do |api|
23
+ api.client_id = client_id
24
+ end
25
+ subject.client_id.should == client_id
26
+ end
27
+
28
+ it 'saves private key for further access' do
29
+ subject.should_receive(:private_key=).with(private_key).and_return(private_key)
30
+ subject.configure do |api|
31
+ api.private_key = private_key
32
+ end
33
+ subject.private_key.should == private_key
34
+ end
35
+ end
36
+
37
+ it { should respond_to(:client_id) }
38
+ it { should respond_to(:client_id=) }
39
+ it { should respond_to(:private_key) }
40
+ it { should respond_to(:private_key=) }
41
+ it { should respond_to(:api_server) }
42
+ it { should respond_to(:api_server=) }
43
+ it { should respond_to(:api_version) }
44
+ it { should respond_to(:api_version=) }
45
+
46
+ describe '#api_server' do
47
+ it 'returns default URL if it has not been overwritten' do
48
+ subject.api_server.should == 'https://api.groupdocs.com'
49
+ end
50
+
51
+ it 'returns custom overwritten URL' do
52
+ subject.api_server = 'https://dev-api.groupdocs.com'
53
+ subject.api_server.should == 'https://dev-api.groupdocs.com'
54
+ end
55
+ end
56
+ end