workos 0.10.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.ruby-version +1 -1
  4. data/.semaphore/semaphore.yml +8 -2
  5. data/Gemfile.lock +49 -36
  6. data/lib/workos.rb +3 -0
  7. data/lib/workos/client.rb +3 -3
  8. data/lib/workos/connection.rb +8 -1
  9. data/lib/workos/directory.rb +53 -0
  10. data/lib/workos/directory_group.rb +44 -0
  11. data/lib/workos/directory_sync.rb +63 -7
  12. data/lib/workos/directory_user.rb +63 -0
  13. data/lib/workos/portal.rb +1 -1
  14. data/lib/workos/profile.rb +1 -2
  15. data/lib/workos/sso.rb +33 -6
  16. data/lib/workos/types.rb +3 -0
  17. data/lib/workos/types/connection_struct.rb +2 -0
  18. data/lib/workos/types/directory_group_struct.rb +13 -0
  19. data/lib/workos/types/directory_struct.rb +16 -0
  20. data/lib/workos/types/directory_user_struct.rb +19 -0
  21. data/lib/workos/types/intent_enum.rb +1 -0
  22. data/lib/workos/version.rb +1 -1
  23. data/sorbet/rbi/gems/addressable.rbi +199 -0
  24. data/sorbet/rbi/gems/ast.rbi +49 -0
  25. data/sorbet/rbi/gems/codecov.rbi +37 -0
  26. data/sorbet/rbi/gems/crack.rbi +62 -0
  27. data/sorbet/rbi/gems/docile.rbi +36 -0
  28. data/sorbet/rbi/gems/hashdiff.rbi +66 -0
  29. data/sorbet/rbi/gems/parallel.rbi +83 -0
  30. data/sorbet/rbi/gems/parser.rbi +1429 -0
  31. data/sorbet/rbi/gems/public_suffix.rbi +104 -0
  32. data/sorbet/rbi/gems/rainbow.rbi +118 -0
  33. data/sorbet/rbi/gems/rake.rbi +644 -0
  34. data/sorbet/rbi/gems/regexp_parser.rbi +926 -0
  35. data/sorbet/rbi/gems/rexml.rbi +628 -0
  36. data/sorbet/rbi/gems/rspec-core.rbi +1898 -0
  37. data/sorbet/rbi/gems/rspec-expectations.rbi +1127 -0
  38. data/sorbet/rbi/gems/rspec-mocks.rbi +1099 -0
  39. data/sorbet/rbi/gems/rspec-support.rbi +280 -0
  40. data/sorbet/rbi/gems/rspec.rbi +15 -0
  41. data/sorbet/rbi/gems/rubocop-ast.rbi +1355 -0
  42. data/sorbet/rbi/gems/rubocop.rbi +7253 -0
  43. data/sorbet/rbi/gems/ruby-progressbar.rbi +304 -0
  44. data/sorbet/rbi/gems/simplecov-html.rbi +35 -0
  45. data/sorbet/rbi/gems/simplecov.rbi +406 -0
  46. data/sorbet/rbi/gems/unicode-display_width.rbi +17 -0
  47. data/sorbet/rbi/gems/vcr.rbi +572 -0
  48. data/sorbet/rbi/gems/webmock.rbi +556 -0
  49. data/sorbet/rbi/gems/yard.rbi +1165 -0
  50. data/sorbet/rbi/sorbet-typed/lib/rake/all/rake.rbi +645 -0
  51. data/sorbet/rbi/sorbet-typed/lib/rspec-core/all/rspec-core.rbi +1891 -0
  52. data/sorbet/rbi/sorbet-typed/lib/rubocop/~>0.85/rubocop.rbi +2072 -0
  53. data/sorbet/rbi/sorbet-typed/lib/yard/all/yard.rbi +1214 -0
  54. data/sorbet/rbi/todo.rbi +1 -3
  55. data/spec/lib/workos/audit_trail_spec.rb +0 -8
  56. data/spec/lib/workos/directory_sync_spec.rb +347 -40
  57. data/spec/lib/workos/passwordless_spec.rb +0 -8
  58. data/spec/lib/workos/portal_spec.rb +18 -11
  59. data/spec/lib/workos/sso_spec.rb +150 -71
  60. data/spec/spec_helper.rb +2 -1
  61. data/spec/support/fixtures/vcr_cassettes/directory_sync/delete_directory.yml +72 -0
  62. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections.yml → directory_sync/list_directories/with_after.yml} +7 -7
  63. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_limit_param.yml → directory_sync/list_directories/with_before.yml} +8 -8
  64. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_connection_type_param.yml → directory_sync/list_directories/with_domain.yml} +11 -10
  65. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_limit.yml +74 -0
  66. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_directories.yml → list_directories/with_no_options.yml} +1 -1
  67. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_search.yml +73 -0
  68. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_after.yml +76 -0
  69. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_before.yml +74 -0
  70. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_directory.yml +78 -0
  71. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_limit.yml +74 -0
  72. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_groups.yml → list_groups/with_no_options.yml} +16 -6
  73. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_user.yml +72 -0
  74. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_after.yml +86 -0
  75. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_before.yml +75 -0
  76. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_directory.yml +93 -0
  77. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_group.yml +76 -0
  78. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_limit.yml +75 -0
  79. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_users.yml → list_users/with_no_options.yml} +16 -6
  80. data/spec/support/fixtures/vcr_cassettes/portal/generate_link_dsync.yml +72 -0
  81. data/spec/support/fixtures/vcr_cassettes/portal/{generate_link.yml → generate_link_sso.yml} +1 -1
  82. data/spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml +3 -3
  83. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_after.yml +73 -0
  84. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_before.yml +73 -0
  85. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_connection_type.yml +73 -0
  86. data/spec/support/fixtures/vcr_cassettes/sso/{list_connections_with_domain_param.yml → list_connections/with_domain.yml} +6 -6
  87. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_limit.yml +74 -0
  88. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_no_options.yml +73 -0
  89. data/spec/support/fixtures/vcr_cassettes/sso/{list_connections_with_before_param.yml → list_connections/with_organization_id.yml} +7 -8
  90. data/workos.gemspec +2 -0
  91. metadata +101 -40
  92. data/sorbet/rbi/hidden-definitions/errors.txt +0 -24896
  93. data/sorbet/rbi/hidden-definitions/hidden.rbi +0 -38411
  94. data/sorbet/rbi/sorbet-typed/lib/bundler/all/bundler.rbi +0 -8684
  95. data/sorbet/rbi/sorbet-typed/lib/ruby/all/gem.rbi +0 -4222
  96. data/sorbet/rbi/sorbet-typed/lib/ruby/all/open3.rbi +0 -111
  97. data/sorbet/rbi/sorbet-typed/lib/ruby/all/resolv.rbi +0 -543
  98. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories_with_domain_param.yml +0 -63
  99. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups_with_directory_param.yml +0 -62
  100. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users_with_directory_param.yml +0 -62
  101. data/spec/support/fixtures/vcr_cassettes/sso/list_connections_with_after_param.yml +0 -72
data/sorbet/rbi/todo.rbi CHANGED
@@ -2,6 +2,4 @@
2
2
  # srb rbi todo
3
3
 
4
4
  # typed: strong
5
- module T::CompatibilityPatches::RecorderExtensions; end
6
- module T::Private::Methods::MethodHooks; end
7
- module T::Private::Methods::SingletonMethodHooks; end
5
+ module ::VCR; end
@@ -2,14 +2,6 @@
2
2
  # typed: false
3
3
 
4
4
  describe WorkOS::AuditTrail do
5
- before(:all) do
6
- WorkOS.key = 'key'
7
- end
8
-
9
- after(:all) do
10
- WorkOS.key = nil
11
- end
12
-
13
5
  describe '.create_event' do
14
6
  context 'with valid event payload' do
15
7
  let(:valid_event) do
@@ -2,32 +2,139 @@
2
2
  # typed: false
3
3
 
4
4
  describe WorkOS::DirectorySync do
5
- before(:all) do
6
- WorkOS.key = 'key'
7
- end
8
-
9
- after(:all) do
10
- WorkOS.key = nil
11
- end
12
-
13
5
  describe '.list_directories' do
14
6
  context 'with no options' do
15
- it 'returns directories' do
16
- VCR.use_cassette('directory_sync/list_directories') do
17
- directories = WorkOS::DirectorySync.list_directories
18
- expect(directories.size).to eq(1)
7
+ it 'returns directories and metadata' do
8
+ expected_metadata = {
9
+ 'after' => nil,
10
+ 'before' => 'before-id',
11
+ }
12
+
13
+ VCR.use_cassette 'directory_sync/list_directories/with_no_options' do
14
+ directories = described_class.list_directories
15
+
16
+ expect(directories.data.size).to eq(3)
17
+ expect(directories.list_metadata).to eq(expected_metadata)
19
18
  end
20
19
  end
21
20
  end
22
21
 
23
22
  context 'with domain option' do
24
- it 'returns directories' do
25
- VCR.use_cassette('directory_sync/list_directories_with_domain_param') do
26
- directories = WorkOS::DirectorySync.list_directories(
23
+ it 'forms the proper request to the API' do
24
+ request_args = [
25
+ '/directories?domain=foo-corp.com',
26
+ 'Content-Type' => 'application/json'
27
+ ]
28
+
29
+ expected_request = Net::HTTP::Get.new(*request_args)
30
+
31
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
32
+ and_return(expected_request)
33
+
34
+ VCR.use_cassette 'directory_sync/list_directories/with_domain' do
35
+ directories = described_class.list_directories(
27
36
  domain: 'foo-corp.com',
28
37
  )
29
38
 
30
- expect(directories.first['domain']).to eq('foo-corp.com')
39
+ expect(directories.data.size).to eq(1)
40
+ end
41
+ end
42
+ end
43
+
44
+ context 'with search option' do
45
+ it 'forms the proper request to the API' do
46
+ request_args = [
47
+ '/directories?search=Foo',
48
+ 'Content-Type' => 'application/json'
49
+ ]
50
+
51
+ expected_request = Net::HTTP::Get.new(*request_args)
52
+
53
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
54
+ and_return(expected_request)
55
+
56
+ VCR.use_cassette 'directory_sync/list_directories/with_search' do
57
+ directories = described_class.list_directories(
58
+ search: 'Foo',
59
+ )
60
+
61
+ expect(directories.data.size).to eq(1)
62
+ end
63
+ end
64
+ end
65
+
66
+ context 'with the before option' do
67
+ it 'forms the proper request to the API' do
68
+ request_args = [
69
+ '/directories?before=before-id',
70
+ 'Content-Type' => 'application/json'
71
+ ]
72
+
73
+ expected_request = Net::HTTP::Get.new(*request_args)
74
+
75
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
76
+ and_return(expected_request)
77
+
78
+ VCR.use_cassette 'directory_sync/list_directories/with_before' do
79
+ directories = described_class.list_directories(
80
+ before: 'before-id',
81
+ )
82
+
83
+ expect(directories.data.size).to eq(3)
84
+ end
85
+ end
86
+ end
87
+
88
+ context 'with the after option' do
89
+ it 'forms the proper request to the API' do
90
+ request_args = [
91
+ '/directories?after=after-id',
92
+ 'Content-Type' => 'application/json'
93
+ ]
94
+
95
+ expected_request = Net::HTTP::Get.new(*request_args)
96
+
97
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
98
+ and_return(expected_request)
99
+
100
+ VCR.use_cassette 'directory_sync/list_directories/with_after' do
101
+ directories = described_class.list_directories(after: 'after-id')
102
+
103
+ expect(directories.data.size).to eq(3)
104
+ end
105
+ end
106
+ end
107
+
108
+ context 'with the limit option' do
109
+ it 'forms the proper request to the API' do
110
+ request_args = [
111
+ '/directories?limit=2',
112
+ 'Content-Type' => 'application/json'
113
+ ]
114
+
115
+ expected_request = Net::HTTP::Get.new(*request_args)
116
+
117
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
118
+ and_return(expected_request)
119
+
120
+ VCR.use_cassette 'directory_sync/list_directories/with_limit' do
121
+ directories = described_class.list_directories(limit: 2)
122
+
123
+ expect(directories.data.size).to eq(2)
124
+ end
125
+ end
126
+ end
127
+ end
128
+
129
+ describe '.delete_directory' do
130
+ context 'with valid id' do
131
+ it 'deletes a directory' do
132
+ VCR.use_cassette('directory_sync/delete_directory') do
133
+ response = WorkOS::DirectorySync.delete_directory(
134
+ 'directory_01F2T098SKN5PCTVSJ7CWP70N5',
135
+ )
136
+
137
+ expect(response).to be(true)
31
138
  end
32
139
  end
33
140
  end
@@ -35,27 +142,127 @@ describe WorkOS::DirectorySync do
35
142
 
36
143
  describe '.list_groups' do
37
144
  context 'with no options' do
38
- it 'returns groups' do
39
- VCR.use_cassette('directory_sync/list_groups') do
145
+ it 'raises an error' do
146
+ VCR.use_cassette('directory_sync/list_groups/with_no_options') do
40
147
  expect do
41
148
  WorkOS::DirectorySync.list_groups
42
- end.to raise_error(
43
- WorkOS::InvalidRequestError,
44
- /Status 422, Validation failed/,
45
- )
149
+ end.to raise_error(WorkOS::InvalidRequestError)
46
150
  end
47
151
  end
48
152
  end
49
153
 
50
154
  context 'with directory option' do
51
- it 'returns groups' do
52
- VCR.use_cassette('directory_sync/list_groups_with_directory_param') do
53
- groups = WorkOS::DirectorySync.list_groups(
54
- directory: 'directory_edp_01E64QQVQTCB0DECJ9CFNXEWDW',
155
+ it 'forms the proper request to the API' do
156
+ request_args = [
157
+ '/directory_groups?directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
158
+ 'Content-Type' => 'application/json'
159
+ ]
160
+
161
+ expected_request = Net::HTTP::Get.new(*request_args)
162
+
163
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
164
+ and_return(expected_request)
165
+
166
+ VCR.use_cassette 'directory_sync/list_groups/with_directory' do
167
+ groups = described_class.list_groups(
168
+ directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
169
+ )
170
+
171
+ expect(groups.data.size).to eq(10)
172
+ end
173
+ end
174
+ end
175
+
176
+ context 'with user option' do
177
+ it 'forms the proper request to the API' do
178
+ request_args = [
179
+ '/directory_groups?user=directory_user_01EK2YFBC3R10MPB4W49G5QDXG',
180
+ 'Content-Type' => 'application/json'
181
+ ]
182
+
183
+ expected_request = Net::HTTP::Get.new(*request_args)
184
+
185
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
186
+ and_return(expected_request)
187
+
188
+ VCR.use_cassette 'directory_sync/list_groups/with_user' do
189
+ groups = described_class.list_groups(
190
+ user: 'directory_user_01EK2YFBC3R10MPB4W49G5QDXG',
55
191
  )
56
192
 
57
- expect(groups.size).to eq(2)
58
- expect(groups.first['name']).to eq('Walrus')
193
+ expect(groups.data.size).to eq(3)
194
+ end
195
+ end
196
+ end
197
+
198
+ context 'with the before option' do
199
+ it 'forms the proper request to the API' do
200
+ request_args = [
201
+ '/directory_groups?before=before-id&' \
202
+ 'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
203
+ 'Content-Type' => 'application/json'
204
+ ]
205
+
206
+ expected_request = Net::HTTP::Get.new(*request_args)
207
+
208
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
209
+ and_return(expected_request)
210
+
211
+ VCR.use_cassette 'directory_sync/list_groups/with_before' do
212
+ groups = described_class.list_groups(
213
+ before: 'before-id',
214
+ directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
215
+ )
216
+
217
+ expect(groups.data.size).to eq(2)
218
+ end
219
+ end
220
+ end
221
+
222
+ context 'with the after option' do
223
+ it 'forms the proper request to the API' do
224
+ request_args = [
225
+ '/directory_groups?after=after-id&' \
226
+ 'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
227
+ 'Content-Type' => 'application/json'
228
+ ]
229
+
230
+ expected_request = Net::HTTP::Get.new(*request_args)
231
+
232
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
233
+ and_return(expected_request)
234
+
235
+ VCR.use_cassette 'directory_sync/list_groups/with_after' do
236
+ groups = described_class.list_groups(
237
+ after: 'after-id',
238
+ directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
239
+ )
240
+
241
+ expect(groups.data.size).to eq(10)
242
+ end
243
+ end
244
+ end
245
+
246
+ context 'with the limit option' do
247
+ it 'forms the proper request to the API' do
248
+ request_args = [
249
+ '/directory_groups?limit=2&' \
250
+ 'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
251
+ 'Content-Type' => 'application/json'
252
+ ]
253
+
254
+ expected_request = Net::HTTP::Get.new(*request_args)
255
+
256
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
257
+ and_return(expected_request)
258
+
259
+ VCR.use_cassette 'directory_sync/list_groups/with_limit' do
260
+ groups = described_class.list_groups(
261
+ limit: 2,
262
+ directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
263
+ )
264
+
265
+ expect(groups.data.size).to eq(2)
59
266
  end
60
267
  end
61
268
  end
@@ -63,27 +270,127 @@ describe WorkOS::DirectorySync do
63
270
 
64
271
  describe '.list_users' do
65
272
  context 'with no options' do
66
- it 'returns users' do
67
- VCR.use_cassette('directory_sync/list_users') do
273
+ it 'raises an error' do
274
+ VCR.use_cassette('directory_sync/list_users/with_no_options') do
68
275
  expect do
69
276
  WorkOS::DirectorySync.list_users
70
- end.to raise_error(
71
- WorkOS::InvalidRequestError,
72
- /Status 422, Validation failed/,
73
- )
277
+ end.to raise_error(WorkOS::InvalidRequestError)
74
278
  end
75
279
  end
76
280
  end
77
281
 
78
282
  context 'with directory option' do
79
- it 'returns users' do
80
- VCR.use_cassette('directory_sync/list_users_with_directory_param') do
81
- users = WorkOS::DirectorySync.list_users(
82
- directory: 'directory_edp_01E64QQVQTCB0DECJ9CFNXEWDW',
283
+ it 'forms the proper request to the API' do
284
+ request_args = [
285
+ '/directory_users?directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
286
+ 'Content-Type' => 'application/json'
287
+ ]
288
+
289
+ expected_request = Net::HTTP::Get.new(*request_args)
290
+
291
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
292
+ and_return(expected_request)
293
+
294
+ VCR.use_cassette 'directory_sync/list_users/with_directory' do
295
+ users = described_class.list_users(
296
+ directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
297
+ )
298
+
299
+ expect(users.data.size).to eq(10)
300
+ end
301
+ end
302
+ end
303
+
304
+ context 'with group option' do
305
+ it 'forms the proper request to the API' do
306
+ request_args = [
307
+ '/directory_users?group=directory_group_01EQ7V7C6Y4RPMCH3KNB9853FF',
308
+ 'Content-Type' => 'application/json'
309
+ ]
310
+
311
+ expected_request = Net::HTTP::Get.new(*request_args)
312
+
313
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
314
+ and_return(expected_request)
315
+
316
+ VCR.use_cassette 'directory_sync/list_users/with_group' do
317
+ users = described_class.list_users(
318
+ group: 'directory_group_01EQ7V7C6Y4RPMCH3KNB9853FF',
319
+ )
320
+
321
+ expect(users.data.size).to eq(2)
322
+ end
323
+ end
324
+ end
325
+
326
+ context 'with the before option' do
327
+ it 'forms the proper request to the API' do
328
+ request_args = [
329
+ '/directory_users?before=before-id&'\
330
+ 'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
331
+ 'Content-Type' => 'application/json'
332
+ ]
333
+
334
+ expected_request = Net::HTTP::Get.new(*request_args)
335
+
336
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
337
+ and_return(expected_request)
338
+
339
+ VCR.use_cassette 'directory_sync/list_users/with_before' do
340
+ users = described_class.list_users(
341
+ before: 'before-id',
342
+ directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
343
+ )
344
+
345
+ expect(users.data.size).to eq(2)
346
+ end
347
+ end
348
+ end
349
+
350
+ context 'with the after option' do
351
+ it 'forms the proper request to the API' do
352
+ request_args = [
353
+ '/directory_users?after=after-id&' \
354
+ 'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
355
+ 'Content-Type' => 'application/json'
356
+ ]
357
+
358
+ expected_request = Net::HTTP::Get.new(*request_args)
359
+
360
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
361
+ and_return(expected_request)
362
+
363
+ VCR.use_cassette 'directory_sync/list_users/with_after' do
364
+ users = described_class.list_users(
365
+ after: 'after-id',
366
+ directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
367
+ )
368
+
369
+ expect(users.data.size).to eq(10)
370
+ end
371
+ end
372
+ end
373
+
374
+ context 'with the limit option' do
375
+ it 'forms the proper request to the API' do
376
+ request_args = [
377
+ '/directory_users?limit=2&' \
378
+ 'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
379
+ 'Content-Type' => 'application/json'
380
+ ]
381
+
382
+ expected_request = Net::HTTP::Get.new(*request_args)
383
+
384
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
385
+ and_return(expected_request)
386
+
387
+ VCR.use_cassette 'directory_sync/list_users/with_limit' do
388
+ users = described_class.list_users(
389
+ limit: 2,
390
+ directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
83
391
  )
84
392
 
85
- expect(users.size).to eq(1)
86
- expect(users.first['last_name']).to eq('Tran')
393
+ expect(users.data.size).to eq(2)
87
394
  end
88
395
  end
89
396
  end