testrail-ruby 0.0.31 → 0.1.01

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.
@@ -53,7 +53,7 @@ module TestRail
53
53
 
54
54
  def _send_request(method, uri, data = {})
55
55
  url = URI.parse(@url + uri)
56
- puts "URL: #{url}"
56
+ puts url
57
57
  if method == 'POST'
58
58
  request = Net::HTTP::Post.new(url.path + '?' + url.query)
59
59
  request.body = JSON.dump(data)
@@ -1,3 +1,3 @@
1
1
  module Testrail
2
- VERSION = '0.0.31'.freeze
2
+ VERSION = '0.1.01'.freeze
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.start # Do not move. Must load before code under test.
3
3
  require 'rspec'
4
+ require 'webmock/rspec'
4
5
  require 'bundler/setup'
5
6
  require 'testrail-ruby'
6
7
 
@@ -5,97 +5,789 @@ require_relative '../../lib/testrail-ruby'
5
5
  # Must set these to run tests
6
6
  # gitlab varables, .bashrc, etc
7
7
 
8
- base_url = ENV["TESTRAIL_BASE_URL"]
9
- user = ENV["TESTRAIL_USER"]
10
- password = ENV["TESTRAIL_PASSWORD"]
8
+ base_url = "https://test/"
9
+ user = "username"
10
+ password = "password"
11
11
 
12
12
  client = TestRail::APIClient.new(base_url)
13
13
  client.user = user
14
14
  client.password = password
15
15
 
16
- RSpec.describe "get_case" do
17
- response = client.get_case(1462)
18
- it 'is not empty' do
19
- puts "Response:\n#{response}"
20
- expect(response).not_to be_empty
16
+ #### CASES ##############+++++5
17
+ RSpec.describe "get_case" do
18
+ it 'request is formatted correctly' do
19
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_case/1462").
20
+ with(headers: {
21
+ 'Accept'=>'*/*',
22
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
23
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
24
+ 'Content-Type'=>'application/json',
25
+ 'User-Agent'=>'Ruby'}).
26
+ to_return(status: 200, body: "", headers: {})
27
+
28
+ client.get_case(1462)
29
+ expect(stub).to have_been_requested
30
+ end
31
+ end #describe
32
+
33
+ RSpec.describe "get_cases" do
34
+ it 'request is formatted correctly' do
35
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_cases/1&section_id=1&suite_id=1").
36
+ with(headers: {
37
+ 'Accept'=>'*/*',
38
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
39
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
40
+ 'Content-Type'=>'application/json',
41
+ 'User-Agent'=>'Ruby'}).
42
+ to_return(status: 200, body: "", headers: {})
43
+
44
+ client.get_cases(1, {"suite_id":1, "section_id":1})
45
+ expect(stub).to have_been_requested
46
+ end
47
+ end
48
+
49
+ RSpec.describe "add_case" do
50
+ it 'request is formatted correctly' do
51
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_case/1").
52
+ with(body: "{\"title\":\"testCaseName\",\"type_id\":1}",
53
+ headers: {
54
+ 'Accept'=>'*/*',
55
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
56
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
57
+ 'Content-Type'=>'application/json',
58
+ 'User-Agent'=>'Ruby'}).
59
+ to_return(status: 200, body: "", headers: {})
60
+
61
+ client.add_case(1, {"title": "testCaseName", "type_id": 1})
62
+ expect(stub).to have_been_requested
63
+ end
64
+ end
65
+
66
+ RSpec.describe "update_case" do
67
+ it 'request is formatted correctly' do
68
+ stub = stub_request(:post, "https://test/index.php?/api/v2/update_case/1").
69
+ with(body: "{\"title\":\"testCaseName\",\"type_id\":1}",
70
+ headers: {
71
+ 'Accept'=>'*/*',
72
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
73
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
74
+ 'Content-Type'=>'application/json',
75
+ 'User-Agent'=>'Ruby'}).
76
+ to_return(status: 200, body: "", headers: {})
77
+
78
+ client.update_case(1, {"title": "testCaseName", "type_id": 1})
79
+ expect(stub).to have_been_requested
80
+ end
81
+ end #describe
82
+
83
+ RSpec.describe "delete_case" do
84
+ it 'request is formatted correctly' do
85
+ stub = stub_request(:post, "https://test/index.php?/api/v2/delete_case/1").
86
+ with(body: "{\"title\":\"testCaseName\",\"type_id\":1}",
87
+ headers: {
88
+ 'Accept'=>'*/*',
89
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
90
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
91
+ 'Content-Type'=>'application/json',
92
+ 'User-Agent'=>'Ruby'}).
93
+ to_return(status: 200, body: "", headers: {})
94
+
95
+ client.delete_case(1, {"title": "testCaseName", "type_id": 1})
96
+ expect(stub).to have_been_requested
97
+ end
98
+ end #describe
99
+
100
+ #### SUITES #############+++++5
101
+ RSpec.describe "get_suite" do
102
+ it 'is formatted correctly' do
103
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_suite/1").
104
+ with(headers: {
105
+ 'Accept'=>'*/*',
106
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
107
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
108
+ 'Content-Type'=>'application/json',
109
+ 'User-Agent'=>'Ruby'}).
110
+ to_return(status: 200, body: "", headers: {})
111
+
112
+ client.get_suite(1)
113
+ expect(stub).to have_been_requested
114
+ end
115
+ end
116
+
117
+ RSpec.describe "get_suites" do
118
+ it 'is formatted correctly' do
119
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_suites/1").
120
+ with(headers: {
121
+ 'Accept'=>'*/*',
122
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
123
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
124
+ 'Content-Type'=>'application/json',
125
+ 'User-Agent'=>'Ruby'}).
126
+ to_return(status: 200, body: "", headers: {})
127
+ client.get_suites(1)
128
+ expect(stub).to have_been_requested
129
+ end
130
+ end
131
+
132
+ RSpec.describe "add_suite" do
133
+ it 'request is formatted correctly' do
134
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_suite/1").
135
+ with(body: "{\"name\":\"suite name\",\"description\":\"description of test suite\"}",
136
+ headers: {
137
+ 'Accept'=>'*/*',
138
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
139
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
140
+ 'Content-Type'=>'application/json',
141
+ 'User-Agent'=>'Ruby'}).
142
+ to_return(status: 200, body: "", headers: {})
143
+
144
+ client.add_suite(1, {"name": "suite name", "description": "description of test suite"})
145
+ expect(stub).to have_been_requested
146
+ end
147
+ end #describe
148
+
149
+ RSpec.describe "update_suite" do
150
+ it 'request is formatted correctly' do
151
+ stub = stub_request(:post, "https://test/index.php?/api/v2/update_suite/1").
152
+ with(body: "{\"name\":\"suite name\",\"description\":\"description of test suite\"}",
153
+ headers: {
154
+ 'Accept'=>'*/*',
155
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
156
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
157
+ 'Content-Type'=>'application/json',
158
+ 'User-Agent'=>'Ruby'}).
159
+ to_return(status: 200, body: "", headers: {})
160
+
161
+ client.update_suite(1, {"name": "suite name", "description": "description of test suite"})
162
+ expect(stub).to have_been_requested
163
+ end
164
+ end #describe
165
+
166
+ RSpec.describe "delete_suite" do
167
+ it 'request is formatted correctly' do
168
+ stub = stub_request(:post, "https://test/index.php?/api/v2/delete_suite/1").
169
+ with(body: "{}",
170
+ headers: {
171
+ 'Accept'=>'*/*',
172
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
173
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
174
+ 'Content-Type'=>'application/json',
175
+ 'User-Agent'=>'Ruby'}).
176
+ to_return(status: 200, body: "", headers: {})
177
+
178
+ client.delete_suite(1)
179
+ expect(stub).to have_been_requested
180
+ end
181
+ end #describe
182
+
183
+ #### SECTIONS ###########+++++5
184
+ RSpec.describe "get_section" do
185
+ it 'request is formatted correctly' do
186
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_section/1").
187
+ with(headers: {
188
+ 'Accept'=>'*/*',
189
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
190
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
191
+ 'Content-Type'=>'application/json',
192
+ 'User-Agent'=>'Ruby'}).
193
+ to_return(status: 200, body: "", headers: {})
194
+
195
+ client.get_section(1)
196
+
197
+ expect(stub).to have_been_requested
198
+ end
199
+ end
200
+
201
+ RSpec.describe "get_sections" do
202
+ it 'is formatted correctly' do
203
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_sections/1&section_id=1&suite_id=1").
204
+ with(headers: {
205
+ 'Accept'=>'*/*',
206
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
207
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
208
+ 'Content-Type'=>'application/json',
209
+ 'User-Agent'=>'Ruby'}).
210
+ to_return(status: 200, body: "", headers: {})
211
+ client.get_sections(1, {
212
+ "suite_id":1,
213
+ "section_id":1
214
+ })
215
+
216
+ expect(stub).to have_been_requested
217
+ end
218
+ end
219
+
220
+ RSpec.describe "add_section" do
221
+ it 'is formatted correctly' do
222
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_section/1").
223
+ with(body: "{\"suite_id\":1,\"name\":\"SectionName\",\"description\":\"sectionDesc\",\"parent_id\":1,\"section_id\":1}",
224
+ headers: {
225
+ 'Accept'=>'*/*',
226
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
227
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
228
+ 'Content-Type'=>'application/json',
229
+ 'User-Agent'=>'Ruby'}).
230
+ to_return(status: 200, body: "", headers: {})
231
+
232
+ client.add_section(1, {
233
+ "suite_id":1,
234
+ "name": "SectionName",
235
+ "description": "sectionDesc",
236
+ "parent_id": 1,
237
+ "section_id":1
238
+ })
239
+
240
+ expect(stub).to have_been_requested
241
+ end
242
+ end
243
+
244
+ RSpec.describe "update_section" do
245
+ it 'is formatted correctly' do
246
+ stub = stub_request(:post, "https://test/index.php?/api/v2/update_section/1").
247
+ with(body: "{\"name\":\"SectionName\",\"description\":\"sectionDesc\"}",
248
+ headers: {
249
+ 'Accept'=>'*/*',
250
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
251
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
252
+ 'Content-Type'=>'application/json',
253
+ 'User-Agent'=>'Ruby'}).
254
+ to_return(status: 200, body: "", headers: {})
255
+
256
+ client.update_section(1, {
257
+ "name": "SectionName",
258
+ "description": "sectionDesc",
259
+ })
260
+
261
+ expect(stub).to have_been_requested
262
+ end
263
+ end
264
+
265
+ RSpec.describe "delete_section" do
266
+ it 'is formatted correctly' do
267
+ stub = stub_request(:post, "https://test/index.php?/api/v2/delete_section/1").
268
+ with(body: "{}",
269
+ headers: {
270
+ 'Accept'=>'*/*',
271
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
272
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
273
+ 'Content-Type'=>'application/json',
274
+ 'User-Agent'=>'Ruby'}).
275
+ to_return(status: 200, body: "", headers: {})
276
+
277
+ client.delete_section(1)
278
+
279
+ expect(stub).to have_been_requested
280
+ end # it block
281
+ end
282
+
283
+ #### MILESTONES #########+++++5
284
+ RSpec.describe "get_milestone" do
285
+ it 'request is formatted correctly' do
286
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_milestone/1").
287
+ with(headers: {
288
+ 'Accept'=>'*/*',
289
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
290
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
291
+ 'Content-Type'=>'application/json',
292
+ 'User-Agent'=>'Ruby'}).
293
+ to_return(status: 200, body: "", headers: {})
294
+
295
+ client.get_milestone(1)
296
+
297
+ expect(stub).to have_been_requested
298
+ end
299
+ end
300
+
301
+ RSpec.describe "get_milestones" do
302
+ it 'request is formatted correctly' do
303
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_milestones/1&is_completed=0&is_started=1").
304
+ with(headers: {
305
+ 'Accept'=>'*/*',
306
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
307
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
308
+ 'Content-Type'=>'application/json',
309
+ 'User-Agent'=>'Ruby'}).
310
+ to_return(status: 200, body: "", headers: {})
311
+
312
+ client.get_milestones(1, {"is_completed": 0, "is_started": 1})
313
+
314
+ expect(stub).to have_been_requested
315
+ end
316
+ end
317
+
318
+ RSpec.describe "add_milestone" do
319
+ it 'request is formatted correctly' do
320
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_milestone/1").
321
+ with(
322
+ body: "{\"name\":\"Release 2.0\",\"due_on\":1394596385}",
323
+ headers: {
324
+ 'Accept'=>'*/*',
325
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
326
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
327
+ 'Content-Type'=>'application/json',
328
+ 'User-Agent'=>'Ruby'}).
329
+ to_return(status: 200, body: "", headers: {})
330
+
331
+ client.add_milestone(1, {"name": "Release 2.0", "due_on": 1394596385})
332
+
333
+ expect(stub).to have_been_requested
334
+ end
335
+ end
336
+
337
+ RSpec.describe "update_milestone" do
338
+ it 'request is formatted correctly' do
339
+ stub = stub_request(:post, "https://test/index.php?/api/v2/update_milestone/1").
340
+ with(body: "{\"is_completed\":false,\"is_started\":false,\"parent_id\":1,\"start_on\":1394596385}",
341
+ headers: {
342
+ 'Accept'=>'*/*',
343
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
344
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
345
+ 'Content-Type'=>'application/json',
346
+ 'User-Agent'=>'Ruby'}).
347
+ to_return(status: 200, body: "", headers: {})
348
+
349
+ client.update_milestone(1, {"is_completed": false, "is_started": false, "parent_id": 1, "start_on": 1394596385})
350
+
351
+ expect(stub).to have_been_requested
352
+ end
353
+ end
354
+
355
+ RSpec.describe "delete_milestone" do
356
+ it 'request is formatted correctly' do
357
+ stub = stub_request(:post, "https://test/index.php?/api/v2/delete_milestone/1").
358
+ with(body: "{}",
359
+ headers: {
360
+ 'Accept'=>'*/*',
361
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
362
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
363
+ 'Content-Type'=>'application/json',
364
+ 'User-Agent'=>'Ruby'}).
365
+ to_return(status: 200, body: "", headers: {})
366
+
367
+ client.delete_milestone(1)
368
+
369
+ expect(stub).to have_been_requested
370
+ end
371
+ end
372
+
373
+ #### PLANS ##########+++++++++9
374
+ RSpec.describe "get_plan" do
375
+ it 'is formatted correctly' do
376
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_plan/21").
377
+ with(headers: {
378
+ 'Accept'=>'*/*',
379
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
380
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
381
+ 'Content-Type'=>'application/json',
382
+ 'User-Agent'=>'Ruby'}).
383
+ to_return(status: 200, body: "", headers: {})
384
+ client.get_plan(21)
385
+ expect(stub).to have_been_requested
386
+ end
387
+ end
388
+
389
+ RSpec.describe "get_plans" do
390
+ it 'request is formatted correctly' do
391
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_plans/1&is_completed=1&milestone_id=1").
392
+ with(
393
+ headers: {'Accept'=>'*/*',
394
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
395
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
396
+ 'Content-Type'=>'application/json',
397
+ 'User-Agent'=>'Ruby'}).
398
+ to_return(status: 200, body: "", headers: {})
399
+
400
+ client.get_plans(1, {"is_completed":1, "milestone_id": 1 })
401
+ expect(stub).to have_been_requested
402
+ end
21
403
  end
22
- end #describe
23
404
 
24
- RSpec.describe "get_cases" do
25
- response = client.get_cases(1, {"suite_id":1, "section_id":1})
26
- it 'is not empty' do
27
- puts "Response:\n#{response}"
28
- expect(response).not_to be_empty
405
+ RSpec.describe "add_plan" do
406
+ it 'request is formatted correctly' do
407
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_plan/1").
408
+ with(
409
+ body:
410
+ "{\"name\":\"System test\",\"entries\":[{\"suite_id\":1,\"name\":\"Custom run name\",\"assignedto_id\":1},{\"suite_id\":1,\"include_all\":false,\"case_ids\":[1,2,3,5]}]}",
411
+ headers: {
412
+ 'Accept'=>'*/*',
413
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
414
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
415
+ 'Content-Type'=>'application/json',
416
+ 'User-Agent'=>'Ruby'}).
417
+ to_return(status: 200, body: "", headers: {})
418
+
419
+ options = {
420
+ "name": "System test",
421
+ "entries": [
422
+ {
423
+ "suite_id": 1,
424
+ "name": "Custom run name",
425
+ "assignedto_id": 1
426
+ },
427
+ {
428
+ "suite_id": 1,
429
+ "include_all": false,
430
+ "case_ids": [1,2,3,5]
431
+ }
432
+ ]
433
+ }
434
+ client.add_plan(1, options)
435
+
436
+ expect(stub).to have_been_requested
437
+ end
29
438
  end
30
- end
31
439
 
32
- RSpec.describe "add_case" do
33
- response = client.add_case(1, {"title":"testCaseName", "type_id":1})
34
- it 'is not empty' do
35
- puts "Response:\n#{response}"
36
- expect(response).not_to be_empty
440
+ RSpec.describe "add_plan_entry" do
441
+ it 'request is formatted correctly' do
442
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_plan_entry/1").
443
+ with(
444
+ body: "{\"suite_id\":1,\"assignedto_id\":1,\"include_all\":true,\"config_ids\":[1,2,4,5,6],\"runs\":[{\"include_all\":false,\"case_ids\":[1,2,3],\"config_ids\":[2,5]},{\"include_all\":false,\"case_ids\":[1,2,3,5,8],\"assignedto_id\":2,\"config_ids\":[2,6]}]}",
445
+ headers: {'Accept'=>'*/*',
446
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
447
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
448
+ 'Content-Type'=>'application/json',
449
+ 'User-Agent'=>'Ruby'}).
450
+ to_return(status: 200, body: "", headers: {})
451
+
452
+ options =
453
+ {
454
+ "suite_id": 1,
455
+ "assignedto_id": 1,
456
+ "include_all": true,
457
+ "config_ids": [1, 2, 4, 5, 6],
458
+ "runs": [
459
+ {
460
+ "include_all": false,
461
+ "case_ids": [1, 2, 3],
462
+ "config_ids": [2, 5]
463
+ },
464
+ {
465
+ "include_all": false,
466
+ "case_ids": [1, 2, 3, 5, 8],
467
+ "assignedto_id": 2,
468
+ "config_ids": [2, 6]
469
+ }
470
+ ]
471
+ }
472
+ client.add_plan_entry(1, options)
473
+ expect(stub).to have_been_requested
474
+ end
37
475
  end
38
- end
39
476
 
40
- RSpec.describe "get_section" do
41
- response = client.get_section(1)
42
- it 'is not empty' do
43
- puts "Response:\n#{response}"
44
- expect(response).not_to be_empty
477
+ RSpec.describe "update_plan" do
478
+ it 'request is formatted correctly' do
479
+ stub = stub_request(:post, "https://test/index.php?/api/v2/update_plan/1").
480
+ with(
481
+ body: "{\"name\":\"foo\",\"description\":\"bar\"}",
482
+ headers: {'Accept'=>'*/*',
483
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
484
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
485
+ 'Content-Type'=>'application/json',
486
+ 'User-Agent'=>'Ruby'}).
487
+ to_return(status: 200, body: "", headers: {})
488
+
489
+ client.update_plan(1, {"name": "foo", "description": "bar"})
490
+
491
+ expect(stub).to have_been_requested
492
+ end
45
493
  end
46
- end
47
494
 
48
- RSpec.describe "get_sections" do
49
- response = client.get_sections(1, {"suite_id":1, "section_id":1})
50
- it 'is not empty' do
51
- puts "Response:\n#{response}"
52
- expect(response).not_to be_empty
495
+ RSpec.describe "update_plan_entry" do
496
+ it 'request is formatted correctly' do
497
+ stub = stub_request(:post, "https://test/index.php?/api/v2/update_plan_entry/1/1").
498
+ with(
499
+ body: "{\"name\":\"foo\",\"description\":\"bar\"}",
500
+ headers: {'Accept'=>'*/*',
501
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
502
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
503
+ 'Content-Type'=>'application/json',
504
+ 'User-Agent'=>'Ruby'}).
505
+ to_return(status: 200, body: "", headers: {})
506
+
507
+ client.update_plan_entry(1, 1, {"name": "foo", "description": "bar"})
508
+ expect(stub).to have_been_requested
509
+ end
53
510
  end
54
- end
55
511
 
56
- RSpec.describe "get_suite" do
57
- response = client.get_suite(1)
58
- it 'is not empty' do
59
- puts "Response:\n#{response}"
60
- expect(response).not_to be_empty
512
+ RSpec.describe "close_plan" do
513
+ it 'request is formatted correctly' do
514
+ stub = stub_request(:post, "https://test/index.php?/api/v2/close_plan/1").
515
+ with(body: "{}",
516
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
517
+ to_return(status: 200, body: "", headers: {})
518
+
519
+ client.close_plan(1)
520
+ expect(stub).to have_been_requested
521
+ end
61
522
  end
62
- end
63
523
 
64
- RSpec.describe "get_suites" do
65
- response = client.get_suites(1)
66
- it 'is not empty' do
67
- puts "Response:\n#{response}"
68
- expect(response).not_to be_empty
524
+ RSpec.describe "delete_plan" do
525
+ it 'request is formatted correctly' do
526
+ stub = stub_request(:post, "https://test/index.php?/api/v2/delete_plan/1").
527
+ with(body: "{}",
528
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
529
+ to_return(status: 200, body: "", headers: {})
530
+
531
+ client.delete_plan(1)
532
+ expect(stub).to have_been_requested
533
+ end
69
534
  end
70
- end
71
535
 
72
- RSpec.describe "get_plan" do
73
- response = client.get_plan(21)
74
- it 'is not empty' do
75
- puts "Response:\n#{response}"
76
- expect(response).not_to be_empty
536
+ RSpec.describe "delete_plan_entry" do
537
+ it 'request is formatted correctly' do
538
+ stub = stub_request(:post, "https://test/index.php?/api/v2/delete_plan_entry/1/1").
539
+ with(body: "{}",
540
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
541
+ to_return(status: 200, body: "", headers: {})
542
+
543
+ client.delete_plan_entry(1, 1)
544
+ expect(stub).to have_been_requested
545
+ end
77
546
  end
78
- end
79
547
 
80
- RSpec.describe "get_project" do
81
- response = client.get_project(1)
82
- it 'is not empty' do
83
- puts "Response:\n#{response}"
84
- expect(response).not_to be_empty
548
+ #### PROJECTS ###########+++++5
549
+ RSpec.describe "get_project" do
550
+ it 'is formatted correctly' do
551
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_project/1").
552
+ with(headers: {
553
+ 'Accept'=>'*/*',
554
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
555
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
556
+ 'Content-Type'=>'application/json',
557
+ 'User-Agent'=>'Ruby'}).
558
+ to_return(status: 200, body: "", headers: {})
559
+ client.get_project(1)
560
+ expect(stub).to have_been_requested
561
+ end
85
562
  end
86
- end
87
563
 
88
- RSpec.describe "get_projects" do
564
+ RSpec.describe "get_projects" do
565
+ it 'is passes options correctly ' do
566
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_projects&is_completed=0").
567
+ with(headers: {
568
+ 'Accept'=>'*/*',
569
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
570
+ 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
571
+ 'Content-Type'=>'application/json',
572
+ 'User-Agent'=>'Ruby'}).
573
+ to_return(status: 200, body: "", headers: {})
574
+
575
+ client.get_projects({"is_completed":0})
576
+ expect(stub).to have_been_requested
577
+ end
578
+ end
579
+
580
+ RSpec.describe "add_project" do
581
+ it 'request is formatted correctly' do
582
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_project").
583
+ with(body: "{\"name\":\"foo\",\"announcement\":\"bar\",\"show_announcement\":true,\"suite_mode\":1}",
584
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
585
+ to_return(status: 200, body: "", headers: {})
586
+
587
+ client.add_project({"name": "foo", "announcement": "bar", "show_announcement": true, "suite_mode": 1})
588
+ expect(stub).to have_been_requested
589
+ end
590
+ end
591
+
592
+ RSpec.describe "update_project" do
593
+ it 'request is formatted correctly' do
594
+ stub = stub_request(:post, "https://test/index.php?/api/v2/update_project/1").
595
+ with(body: "{\"name\":\"foo\",\"announcement\":\"bar\",\"show_announcement\":true,\"suite_mode\":1,\"is_completed\":true}",
596
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
597
+ to_return(status: 200, body: "", headers: {})
598
+
599
+ client.update_project(1, {"name": "foo", "announcement": "bar", "show_announcement": true, "suite_mode": 1, "is_completed": true})
600
+ expect(stub).to have_been_requested
601
+ end
602
+ end
603
+
604
+ RSpec.describe "delete_project" do
605
+ it 'request is formatted correctly' do
606
+ stub = stub_request(:post, "https://test/index.php?/api/v2/delete_project/1").
607
+ with(body: "{}",
608
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
609
+ to_return(status: 200, body: "", headers: {})
610
+
611
+
612
+ client.delete_project(1)
613
+ expect(stub).to have_been_requested
614
+ end
615
+ end
616
+
617
+ #### RESULTS ##########+++++++7
618
+ RSpec.describe "get_results" do
619
+ it 'request is formatted correctly' do
620
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_results/1&limit=10&status_id=4").
621
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
622
+ to_return(status: 200, body: "", headers: {})
623
+
624
+ client.get_results(1, {"status_id": 4, "limit": 10})
625
+ expect(stub).to have_been_requested
626
+ end
627
+ end
628
+
629
+ RSpec.describe "get_results_for_case" do
630
+ it 'request is formatted correctly' do
631
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_results_for_case/1/2&limit=10&status_id=4").
632
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
633
+ to_return(status: 200, body: "", headers: {})
634
+
635
+ client.get_results_for_case(1, 2, {"status_id": 4, "limit": 10})
636
+ expect(stub).to have_been_requested
637
+ end
638
+ end
639
+
640
+ RSpec.describe "get_results_for_run" do
641
+ it 'request is formatted correctly' do
642
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_results_for_run/1&created_after=12345&created_before=12345&created_by=1&limit=5&status_id=1").
643
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
644
+ to_return(status: 200, body: "", headers: {})
645
+
646
+ client.get_results_for_run(1, {"created_after": 12345, "created_before": 12345, "created_by": 1, "limit": 5, "status_id": 1})
647
+ expect(stub).to have_been_requested
648
+ end
649
+ end
650
+
651
+ RSpec.describe "add_result" do
652
+ it 'request is formatted correctly' do
653
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_result/1").
654
+ with(body: "{\"status_id\":5}",
655
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
656
+ to_return(status: 200, body: "", headers: {})
657
+
658
+ client.add_result(1, {"status_id": 5})
659
+ expect(stub).to have_been_requested
660
+ end
661
+ end
662
+
663
+ RSpec.describe "add_result_for_case" do
664
+ it 'request is formatted correctly' do
665
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_result_for_case/1/1").
666
+ with(body: "{\"status_id\":5}",
667
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
668
+ to_return(status: 200, body: "", headers: {})
669
+
670
+ client.add_result_for_case(1, 1, {"status_id": 5})
671
+ expect(stub).to have_been_requested
672
+ end
673
+ end
674
+
675
+ RSpec.describe "add_results" do
676
+ it 'request is formatted correctly' do
677
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_results/1").
678
+ with(body: "{\"foo\":\"bar\"}",
679
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
680
+ to_return(status: 200, body: "", headers: {})
681
+
682
+ client.add_results(1, {"foo": "bar"})
683
+ expect(stub).to have_been_requested
684
+ end
685
+ end
686
+
687
+ RSpec.describe "add_results_for_cases" do
688
+ it 'request is formatted correctly' do
689
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_results_for_cases/1").
690
+ with(body: "{\"foo\":\"bar\"}",
691
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
692
+ to_return(status: 200, body: "", headers: {})
693
+
694
+ client.add_results_for_cases(1, {"foo": "bar"})
695
+ expect(stub).to have_been_requested
696
+ end
697
+ end
698
+
699
+ #### RUNS ##############++++++6
700
+
701
+ RSpec.describe "get_run" do
702
+ it 'request is formatted correctly' do
703
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_run/1").
704
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
705
+ to_return(status: 200, body: "", headers: {})
706
+
707
+ client.get_run(1)
708
+ expect(stub).to have_been_requested
709
+ end
710
+ end
711
+
712
+ RSpec.describe "get_runs" do
713
+ it 'request is formatted correctly' do
714
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_runs/1&biz=baz&foo=bar").
715
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
716
+ to_return(status: 200, body: "", headers: {})
717
+
718
+ client.get_runs(1, {"foo": "bar", "biz": "baz"})
719
+ expect(stub).to have_been_requested
720
+ end
721
+ end
722
+
723
+ RSpec.describe "add_run" do
724
+ it 'request is formatted correctly' do
725
+ stub = stub_request(:post, "https://test/index.php?/api/v2/add_run/1").
726
+ with(body: "{\"foo\":\"bar\",\"biz\":\"baz\"}",
727
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
728
+ to_return(status: 200, body: "", headers: {})
729
+
730
+ client.add_run(1, {"foo": "bar", "biz": "baz"})
731
+ expect(stub).to have_been_requested
732
+ end
733
+ end
734
+
735
+ RSpec.describe "update_run" do
736
+ it 'request is formatted correctly' do
737
+ stub = stub_request(:post, "https://test/index.php?/api/v2/update_run/1").
738
+ with(body: "{\"foo\":\"bar\",\"biz\":\"baz\"}",
739
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
740
+ to_return(status: 200, body: "", headers: {})
741
+
742
+ client.update_run(1, {"foo": "bar", "biz": "baz"})
743
+ expect(stub).to have_been_requested
744
+ end
745
+ end
746
+
747
+ RSpec.describe "close_run" do
748
+ it 'request is formatted correctly' do
749
+ stub = stub_request(:post, "https://test/index.php?/api/v2/close_run/1").
750
+ with(body: "{}",
751
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
752
+ to_return(status: 200, body: "", headers: {})
753
+
754
+ client.close_run(1)
755
+ expect(stub).to have_been_requested
756
+ end
757
+ end
758
+
759
+ RSpec.describe "delete_run" do
760
+ it 'request is formatted correctly' do
761
+ stub = stub_request(:post, "https://test/index.php?/api/v2/delete_run/1").
762
+ with(body: "{}",
763
+ headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
764
+ to_return(status: 200, body: "", headers: {})
765
+
766
+ client.delete_run(1)
767
+ expect(stub).to have_been_requested
768
+ end
769
+ end
770
+
771
+ #### TESTS #################--2
772
+
773
+ RSpec.describe "get_test" do
774
+ it 'request is formatted correctly' do
775
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_test/1").
776
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
777
+ to_return(status: 200, body: "", headers: {})
778
+
779
+ client.get_test(1)
780
+ expect(stub).to have_been_requested
781
+ end
782
+ end
89
783
 
90
- # it 'is_complete 1 (true) is not empty' do
91
- # response = client.get_projects({"is_completed":1})
92
- # puts "Response:\n#{response}"
93
- # expect(response).not_to be_empty
94
- # end
784
+ RSpec.describe "get_tests" do
785
+ it 'request is formatted correctly' do
786
+ stub = stub_request(:get, "https://test/index.php?/api/v2/get_tests/1&status_id=1").
787
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
788
+ to_return(status: 200, body: "", headers: {})
95
789
 
96
- it 'is_complete(false) is not empty' do
97
- response = client.get_projects({"is_completed":0})
98
- puts "Response:\n#{response}"
99
- expect(response).not_to be_empty
790
+ client.get_tests(1, {"status_id": 1})
791
+ expect(stub).to have_been_requested
792
+ end
100
793
  end
101
- end