yt 0.22.2 → 0.23.0

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.
@@ -13,72 +13,166 @@ describe Yt::Video, :partner do
13
13
  it { expect{video.advertising_options_set}.not_to raise_error }
14
14
  end
15
15
 
16
- describe 'earnings can be retrieved for a specific day' do
17
- context 'in which the video made any money' do
18
- let(:earnings) {video.earnings_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
19
- it { expect(earnings).to be_a Float }
20
- end
16
+ [:views, :uniques, :comments, :likes, :dislikes, :shares,
17
+ :subscribers_gained, :subscribers_lost, :favorites_added,
18
+ :favorites_removed, :estimated_minutes_watched, :average_view_duration,
19
+ :average_view_percentage, :impressions, :monetized_playbacks,
20
+ :annotation_clicks, :annotation_click_through_rate,
21
+ :annotation_close_rate, :earnings].each do |metric|
22
+ describe "#{metric} can be retrieved for a range of days" do
23
+ let(:date_in) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
24
+ let(:date_out) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
25
+ let(:metric) { metric }
26
+ let(:result) { video.public_send metric, options }
27
+
28
+ context 'with a given start and end (:since/:until option)' do
29
+ let(:options) { {by: :day, since: date_in, until: date_out} }
30
+ it { expect(result.keys.min).to eq date_in.to_date }
31
+ it { expect(result.keys.max).to eq date_out.to_date }
32
+ end
21
33
 
22
- context 'in the future' do
23
- let(:earnings) { video.earnings_on 5.days.from_now}
24
- it { expect(earnings).to be_nil }
34
+ context 'with a given start and end (:from/:to option)' do
35
+ let(:options) { {by: :day, from: date_in, to: date_out} }
36
+ it { expect(result.keys.min).to eq date_in.to_date }
37
+ it { expect(result.keys.max).to eq date_out.to_date }
38
+ end
25
39
  end
26
40
  end
27
41
 
28
- describe 'earnings can be retrieved for a single country' do
29
- let(:country_code) { 'US' }
30
- let(:earnings) { video.earnings since: date, by: by, in: location }
31
- let(:date) { 4.days.ago }
42
+ {views: Integer, comments: Integer, dislikes: Integer,
43
+ estimated_minutes_watched: Float, average_view_duration: Float,
44
+ average_view_percentage: Float, impressions: Integer,
45
+ subscribers_lost: Integer, subscribers_gained: Integer, likes: Integer,
46
+ monetized_playbacks: Integer, earnings: Float}.each do |metric, type|
47
+ describe "#{metric} can be retrieved for a specific day" do
48
+ let(:metric) { metric }
49
+ let(:result) { video.public_send "#{metric}_on", date }
32
50
 
33
- context 'and grouped by day' do
34
- let(:by) { :day }
51
+ context 'in which the video had data' do
52
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
53
+ it { expect(result).to be_a type }
54
+ end
55
+
56
+ context 'in the future' do
57
+ let(:date) { 5.days.from_now }
58
+ it { expect(result).to be_nil }
59
+ end
60
+ end
61
+ end
62
+
63
+ {views: Integer, comments: Integer, likes: Integer, dislikes: Integer,
64
+ shares: Integer, subscribers_gained: Integer, subscribers_lost: Integer,
65
+ favorites_added: Integer,
66
+ estimated_minutes_watched: Float, average_view_duration: Float,
67
+ average_view_percentage: Float, impressions: Integer,
68
+ monetized_playbacks: Integer, annotation_clicks: Integer,
69
+ annotation_click_through_rate: Float, annotation_close_rate: Float,
70
+ earnings: Float}.each do |metric, type|
71
+ describe "#{metric} can be grouped by range" do
72
+ let(:metric) { metric }
35
73
 
36
- context 'with the :in option set to the country code' do
37
- let(:location) { country_code }
38
- it { expect(earnings.keys.min).to eq date.to_date }
74
+ context 'without a :by option (default)' do
75
+ let(:result) { video.public_send metric }
76
+ it { expect(result.size).to be 1 }
77
+ it { expect(result[:total]).to be_a type }
39
78
  end
40
79
 
41
- context 'with the :in option set to {country: country code}' do
42
- let(:location) { {country: country_code} }
43
- it { expect(earnings.keys.min).to eq date.to_date }
80
+ context 'with the :by option set to :range' do
81
+ let(:result) { video.public_send metric, by: :range }
82
+ it { expect(result.size).to be 1 }
83
+ it { expect(result[:total]).to be_a type }
44
84
  end
45
85
  end
86
+ end
46
87
 
47
- context 'and grouped by country' do
48
- let(:by) { :country }
88
+ {favorites_removed: Integer}.each do |metric, type|
89
+ describe "#{metric} can be grouped by range" do
90
+ let(:id) { 'NeMlqbX2Ifg' }
91
+ let(:metric) { metric }
49
92
 
50
- context 'with the :in option set to the country code' do
51
- let(:location) { country_code }
52
- it { expect(earnings.keys).to eq [country_code] }
93
+ context 'without a :by option (default)' do
94
+ let(:result) { video.public_send metric }
95
+ it { expect(result.size).to be 1 }
96
+ it { expect(result[:total]).to be_a type }
53
97
  end
54
98
 
55
- context 'with the :in option set to {country: country code}' do
56
- let(:location) { {country: country_code} }
57
- it { expect(earnings.keys).to eq [country_code] }
99
+ context 'with the :by option set to :range' do
100
+ let(:result) { video.public_send metric, by: :range }
101
+ it { expect(result.size).to be 1 }
102
+ it { expect(result[:total]).to be_a type }
58
103
  end
59
104
  end
60
105
  end
61
106
 
62
- describe 'earnings can be retrieved for a range of days' do
63
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
107
+ [:views, :uniques, :comments, :likes, :dislikes, :shares,
108
+ :subscribers_gained, :subscribers_lost, :favorites_added,
109
+ :favorites_removed, :estimated_minutes_watched, :average_view_duration,
110
+ :average_view_percentage, :impressions, :monetized_playbacks,
111
+ :annotation_clicks, :annotation_click_through_rate,
112
+ :annotation_close_rate, :earnings].each do |metric|
113
+ describe "#{metric} can be retrieved for a single country" do
114
+ let(:result) { video.public_send metric, options }
64
115
 
65
- specify 'with a given start and end (:since / :until option)' do
66
- expect(video.earnings(since: date, until: date).keys.min).to eq date.to_date
116
+ context 'and grouped by day' do
117
+ let(:date_in) { 5.days.ago }
118
+ let(:options) { {by: :day, since: date_in, in: location} }
119
+
120
+ context 'with the :in option set to the country code' do
121
+ let(:location) { 'US' }
122
+ it { expect(result.keys.min).to eq date_in.to_date }
123
+ end
124
+
125
+ context 'with the :in option set to {country: country code}' do
126
+ let(:location) { {country: 'US'} }
127
+ it { expect(result.keys.min).to eq date_in.to_date }
128
+ end
129
+ end
67
130
  end
131
+ end
68
132
 
69
- specify 'with a given start and end (:from / :to option)' do
70
- expect(video.earnings(from: date, to: date).keys.min).to eq date.to_date
133
+ [:views, :comments, :likes, :dislikes, :shares,
134
+ :subscribers_gained, :subscribers_lost, :favorites_added,
135
+ :estimated_minutes_watched, :average_view_duration,
136
+ :average_view_percentage, :impressions, :monetized_playbacks,
137
+ :annotation_clicks, :annotation_click_through_rate,
138
+ :annotation_close_rate, :earnings].each do |metric|
139
+ describe "#{metric} can be retrieved for a single country" do
140
+ let(:result) { video.public_send metric, options }
141
+
142
+ context 'and grouped by country' do
143
+ let(:options) { {by: :country, in: location} }
144
+
145
+ context 'with the :in option set to the country code' do
146
+ let(:location) { 'US' }
147
+ it { expect(result.keys).to eq ['US'] }
148
+ end
149
+
150
+ context 'with the :in option set to {country: country code}' do
151
+ let(:location) { {country: 'US'} }
152
+ it { expect(result.keys).to eq ['US'] }
153
+ end
154
+ end
71
155
  end
72
156
  end
73
157
 
74
- describe 'earnings can be grouped by range' do
75
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
76
- let(:keys) { range.values }
158
+ [:views, :annotation_clicks, :annotation_click_through_rate,
159
+ :annotation_close_rate].each do |metric|
160
+ describe "#{metric} can be retrieved for a single country" do
161
+ let(:result) { video.public_send metric, options }
162
+
163
+ context 'and grouped by state' do
164
+ let(:options) { {by: :state, in: location} }
165
+
166
+ context 'with the :in option set to the country code' do
167
+ let(:location) { 'US' }
168
+ it { expect(result.keys.map(&:length).uniq).to eq [2] }
169
+ end
77
170
 
78
- specify 'with the :by option set to :range' do
79
- earnings = video.earnings range.merge by: :range
80
- expect(earnings.size).to be 1
81
- expect(earnings[:total]).to be_a Float
171
+ context 'with the :in option set to {country: country code}' do
172
+ let(:location) { {country: 'US'} }
173
+ it { expect(result.keys.map(&:length).uniq).to eq [2] }
174
+ end
175
+ end
82
176
  end
83
177
  end
84
178
 
@@ -86,11 +180,6 @@ describe Yt::Video, :partner do
86
180
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
87
181
  let(:keys) { range.values }
88
182
 
89
- specify 'without a :by option (default)' do
90
- earnings = video.earnings range
91
- expect(earnings.keys).to eq range.values
92
- end
93
-
94
183
  specify 'with the :by option set to :day' do
95
184
  earnings = video.earnings range.merge by: :day
96
185
  expect(earnings.keys).to eq range.values
@@ -108,70 +197,10 @@ describe Yt::Video, :partner do
108
197
  end
109
198
  end
110
199
 
111
- describe 'views can be retrieved for a specific day' do
112
- context 'in which the video was partnered' do
113
- let(:views) { video.views_on 5.days.ago}
114
- it { expect(views).to be_an Integer }
115
- end
116
-
117
- context 'in which the video was not partnered' do
118
- let(:views) { video.views_on 20.years.ago}
119
- it { expect(views).to be_nil }
120
- end
121
- end
122
-
123
- describe 'views can be retrieved for a single country' do
124
- let(:country_code) { 'US' }
125
- let(:views) { video.views since: date, by: by, in: location }
126
- let(:date) { 4.days.ago }
127
-
128
- context 'and grouped by day' do
129
- let(:by) { :day }
130
-
131
- context 'with the :in option set to the country code' do
132
- let(:location) { country_code }
133
- it { expect(views.keys.min).to eq date.to_date }
134
- end
135
-
136
- context 'with the :in option set to {country: country code}' do
137
- let(:location) { {country: country_code} }
138
- it { expect(views.keys.min).to eq date.to_date }
139
- end
140
- end
141
-
142
- context 'and grouped by country' do
143
- let(:by) { :country }
144
-
145
- context 'with the :in option set to the country code' do
146
- let(:location) { country_code }
147
- it { expect(views.keys).to eq [country_code] }
148
- end
149
-
150
- context 'with the :in option set to {country: country code}' do
151
- let(:location) { {country: country_code} }
152
- it { expect(views.keys).to eq [country_code] }
153
- end
154
- end
155
-
156
- context 'and grouped by state' do
157
- let(:by) { :state }
158
-
159
- context 'with the :in option set to the country code' do
160
- let(:location) { country_code }
161
- it { expect(views.keys.map(&:length).uniq).to eq [2] }
162
- end
163
-
164
- context 'with the :in option set to {country: country code}' do
165
- let(:location) { {country: country_code} }
166
- it { expect(views.keys.map(&:length).uniq).to eq [2] }
167
- end
168
- end
169
- end
170
-
171
200
  describe 'views can be retrieved for a single US state' do
172
201
  let(:state_code) { 'NY' }
173
202
  let(:views) { video.views since: date, by: by, in: location }
174
- let(:date) { 4.days.ago }
203
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
175
204
 
176
205
  context 'and grouped by day' do
177
206
  let(:by) { :day }
@@ -202,45 +231,10 @@ describe Yt::Video, :partner do
202
231
  end
203
232
  end
204
233
 
205
- describe 'views can be retrieved for a range of days' do
206
- let(:date) { 4.days.ago }
207
-
208
- specify 'with a given start (:since option)' do
209
- expect(video.views(since: date).keys.min).to eq date.to_date
210
- end
211
-
212
- specify 'with a given end (:until option)' do
213
- expect(video.views(until: date).keys.max).to eq date.to_date
214
- end
215
-
216
- specify 'with a given start (:from option)' do
217
- expect(video.views(from: date).keys.min).to eq date.to_date
218
- end
219
-
220
- specify 'with a given end (:to option)' do
221
- expect(video.views(to: date).keys.max).to eq date.to_date
222
- end
223
- end
224
-
225
- describe 'views can be grouped by range' do
226
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
227
-
228
- specify 'with the :by option set to :range' do
229
- views = video.views range.merge by: :range
230
- expect(views.size).to be 1
231
- expect(views[:total]).to be_an Integer
232
- end
233
- end
234
-
235
234
  describe 'views can be grouped by day' do
236
235
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
237
236
  let(:keys) { range.values }
238
237
 
239
- specify 'without a :by option (default)' do
240
- views = video.views range
241
- expect(views.keys).to eq range.values
242
- end
243
-
244
238
  specify 'with the :by option set to :day' do
245
239
  views = video.views range.merge by: :day
246
240
  expect(views.keys).to eq range.values
@@ -326,26 +320,6 @@ describe Yt::Video, :partner do
326
320
  end
327
321
  end
328
322
 
329
- describe 'uniques can be retrieved for a single country' do
330
- let(:country_code) { 'US' }
331
- let(:uniques) { video.uniques since: date, by: by, in: location }
332
- let(:date) { 4.days.ago }
333
-
334
- context 'and grouped by day' do
335
- let(:by) { :day }
336
-
337
- context 'with the :in option set to the country code' do
338
- let(:location) { country_code }
339
- it { expect(uniques.keys.min).to eq date.to_date }
340
- end
341
-
342
- context 'with the :in option set to {country: country code}' do
343
- let(:location) { {country: country_code} }
344
- it { expect(uniques.keys.min).to eq date.to_date }
345
- end
346
- end
347
- end
348
-
349
323
  describe 'uniques can be retrieved for a single US state' do
350
324
  let(:state_code) { 'NY' }
351
325
  let(:result) { video.uniques since: date, by: by, in: location }
@@ -366,127 +340,20 @@ describe Yt::Video, :partner do
366
340
  end
367
341
  end
368
342
 
369
- describe 'uniques can be retrieved for a range of days' do
370
- let(:date) { 4.days.ago }
371
-
372
- specify 'with a given start (:since option)' do
373
- expect(video.uniques(since: date).keys.min).to eq date.to_date
374
- end
375
-
376
- specify 'with a given end (:until option)' do
377
- expect(video.uniques(until: date).keys.max).to eq date.to_date
378
- end
379
-
380
- specify 'with a given start (:from option)' do
381
- expect(video.uniques(from: date).keys.min).to eq date.to_date
382
- end
383
-
384
- specify 'with a given end (:to option)' do
385
- expect(video.uniques(to: date).keys.max).to eq date.to_date
386
- end
387
- end
388
-
389
343
  describe 'uniques can be grouped by day' do
390
344
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
391
345
  let(:keys) { range.values }
392
346
 
393
- specify 'without a :by option (default)' do
394
- uniques = video.uniques range
395
- expect(uniques.keys).to eq range.values
396
- end
397
-
398
347
  specify 'with the :by option set to :day' do
399
348
  uniques = video.uniques range.merge by: :day
400
349
  expect(uniques.keys).to eq range.values
401
350
  end
402
351
  end
403
352
 
404
- describe 'comments can be retrieved for a specific day' do
405
- context 'in which the video was partnered' do
406
- let(:comments) { video.comments_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
407
- it { expect(comments).to be_an Integer }
408
- end
409
-
410
- context 'in which the video was not partnered' do
411
- let(:comments) { video.comments_on 20.years.ago}
412
- it { expect(comments).to be_nil }
413
- end
414
- end
415
-
416
-
417
- describe 'comments can be retrieved for a single country' do
418
- let(:country_code) { 'US' }
419
- let(:comments) { video.comments since: date, by: by, in: location }
420
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
421
-
422
- context 'and grouped by day' do
423
- let(:by) { :day }
424
-
425
- context 'with the :in option set to the country code' do
426
- let(:location) { country_code }
427
- it { expect(comments.keys.min).to eq date.to_date }
428
- end
429
-
430
- context 'with the :in option set to {country: country code}' do
431
- let(:location) { {country: country_code} }
432
- it { expect(comments.keys.min).to eq date.to_date }
433
- end
434
- end
435
-
436
- context 'and grouped by country' do
437
- let(:by) { :country }
438
-
439
- context 'with the :in option set to the country code' do
440
- let(:location) { country_code }
441
- it { expect(comments.keys).to eq [country_code] }
442
- end
443
-
444
- context 'with the :in option set to {country: country code}' do
445
- let(:location) { {country: country_code} }
446
- it { expect(comments.keys).to eq [country_code] }
447
- end
448
- end
449
- end
450
-
451
- describe 'comments can be retrieved for a range of days' do
452
- let(:date) { 4.days.ago }
453
-
454
- specify 'with a given start (:since option)' do
455
- expect(video.comments(since: date).keys.min).to eq date.to_date
456
- end
457
-
458
- specify 'with a given end (:until option)' do
459
- expect(video.comments(until: date).keys.max).to eq date.to_date
460
- end
461
-
462
- specify 'with a given start (:from option)' do
463
- expect(video.comments(from: date).keys.min).to eq date.to_date
464
- end
465
-
466
- specify 'with a given end (:to option)' do
467
- expect(video.comments(to: date).keys.max).to eq date.to_date
468
- end
469
- end
470
-
471
- describe 'comments can be grouped by range' do
472
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
473
-
474
- specify 'with the :by option set to :range' do
475
- comments = video.comments range.merge by: :range
476
- expect(comments.size).to be 1
477
- expect(comments[:total]).to be_an Integer
478
- end
479
- end
480
-
481
353
  describe 'comments can be grouped by day' do
482
354
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
483
355
  let(:keys) { range.values }
484
356
 
485
- specify 'without a :by option (default)' do
486
- comments = video.comments range
487
- expect(comments.keys).to eq range.values
488
- end
489
-
490
357
  specify 'with the :by option set to :day' do
491
358
  comments = video.comments range.merge by: :day
492
359
  expect(comments.keys).to eq range.values
@@ -504,91 +371,10 @@ describe Yt::Video, :partner do
504
371
  end
505
372
  end
506
373
 
507
- describe 'likes can be retrieved for a specific day' do
508
- context 'in which the video was partnered' do
509
- let(:likes) { video.likes_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
510
- it { expect(likes).to be_an Integer }
511
- end
512
-
513
- context 'in which the video was not partnered' do
514
- let(:likes) { video.likes_on 20.years.ago}
515
- it { expect(likes).to be_nil }
516
- end
517
- end
518
-
519
- describe 'likes can be retrieved for a single country' do
520
- let(:country_code) { 'US' }
521
- let(:likes) { video.likes since: date, by: by, in: location }
522
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
523
-
524
- context 'and grouped by day' do
525
- let(:by) { :day }
526
-
527
- context 'with the :in option set to the country code' do
528
- let(:location) { country_code }
529
- it { expect(likes.keys.min).to eq date.to_date }
530
- end
531
-
532
- context 'with the :in option set to {country: country code}' do
533
- let(:location) { {country: country_code} }
534
- it { expect(likes.keys.min).to eq date.to_date }
535
- end
536
- end
537
-
538
- context 'and grouped by country' do
539
- let(:by) { :country }
540
-
541
- context 'with the :in option set to the country code' do
542
- let(:location) { country_code }
543
- it { expect(likes.keys).to eq [country_code] }
544
- end
545
-
546
- context 'with the :in option set to {country: country code}' do
547
- let(:location) { {country: country_code} }
548
- it { expect(likes.keys).to eq [country_code] }
549
- end
550
- end
551
- end
552
-
553
- describe 'likes can be retrieved for a range of days' do
554
- let(:date) { 4.days.ago }
555
-
556
- specify 'with a given start (:since option)' do
557
- expect(video.likes(since: date).keys.min).to eq date.to_date
558
- end
559
-
560
- specify 'with a given end (:until option)' do
561
- expect(video.likes(until: date).keys.max).to eq date.to_date
562
- end
563
-
564
- specify 'with a given start (:from option)' do
565
- expect(video.likes(from: date).keys.min).to eq date.to_date
566
- end
567
-
568
- specify 'with a given end (:to option)' do
569
- expect(video.likes(to: date).keys.max).to eq date.to_date
570
- end
571
- end
572
-
573
- describe 'likes can be grouped by range' do
574
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
575
-
576
- specify 'with the :by option set to :range' do
577
- likes = video.likes range.merge by: :range
578
- expect(likes.size).to be 1
579
- expect(likes[:total]).to be_an Integer
580
- end
581
- end
582
-
583
374
  describe 'likes can be grouped by day' do
584
375
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
585
376
  let(:keys) { range.values }
586
377
 
587
- specify 'without a :by option (default)' do
588
- likes = video.likes range
589
- expect(likes.keys).to eq range.values
590
- end
591
-
592
378
  specify 'with the :by option set to :day' do
593
379
  likes = video.likes range.merge by: :day
594
380
  expect(likes.keys).to eq range.values
@@ -606,91 +392,10 @@ describe Yt::Video, :partner do
606
392
  end
607
393
  end
608
394
 
609
- describe 'dislikes can be retrieved for a specific day' do
610
- context 'in which the video was partnered' do
611
- let(:dislikes) { video.dislikes_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
612
- it { expect(dislikes).to be_an Integer }
613
- end
614
-
615
- context 'in which the video was not partnered' do
616
- let(:dislikes) { video.dislikes_on 20.years.ago}
617
- it { expect(dislikes).to be_nil }
618
- end
619
- end
620
-
621
- describe 'dislikes can be retrieved for a single country' do
622
- let(:country_code) { 'US' }
623
- let(:dislikes) { video.dislikes since: date, by: by, in: location }
624
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
625
-
626
- context 'and grouped by day' do
627
- let(:by) { :day }
628
-
629
- context 'with the :in option set to the country code' do
630
- let(:location) { country_code }
631
- it { expect(dislikes.keys.min).to eq date.to_date }
632
- end
633
-
634
- context 'with the :in option set to {country: country code}' do
635
- let(:location) { {country: country_code} }
636
- it { expect(dislikes.keys.min).to eq date.to_date }
637
- end
638
- end
639
-
640
- context 'and grouped by country' do
641
- let(:by) { :country }
642
-
643
- context 'with the :in option set to the country code' do
644
- let(:location) { country_code }
645
- it { expect(dislikes.keys).to eq [country_code] }
646
- end
647
-
648
- context 'with the :in option set to {country: country code}' do
649
- let(:location) { {country: country_code} }
650
- it { expect(dislikes.keys).to eq [country_code] }
651
- end
652
- end
653
- end
654
-
655
- describe 'dislikes can be retrieved for a range of days' do
656
- let(:date) { 4.days.ago }
657
-
658
- specify 'with a given start (:since option)' do
659
- expect(video.dislikes(since: date).keys.min).to eq date.to_date
660
- end
661
-
662
- specify 'with a given end (:until option)' do
663
- expect(video.dislikes(until: date).keys.max).to eq date.to_date
664
- end
665
-
666
- specify 'with a given start (:from option)' do
667
- expect(video.dislikes(from: date).keys.min).to eq date.to_date
668
- end
669
-
670
- specify 'with a given end (:to option)' do
671
- expect(video.dislikes(to: date).keys.max).to eq date.to_date
672
- end
673
- end
674
-
675
- describe 'dislikes can be grouped by range' do
676
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
677
-
678
- specify 'with the :by option set to :range' do
679
- dislikes = video.dislikes range.merge by: :range
680
- expect(dislikes.size).to be 1
681
- expect(dislikes[:total]).to be_an Integer
682
- end
683
- end
684
-
685
395
  describe 'dislikes can be grouped by day' do
686
396
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
687
397
  let(:keys) { range.values }
688
398
 
689
- specify 'without a :by option (default)' do
690
- dislikes = video.dislikes range
691
- expect(dislikes.keys).to eq range.values
692
- end
693
-
694
399
  specify 'with the :by option set to :day' do
695
400
  dislikes = video.dislikes range.merge by: :day
696
401
  expect(dislikes.keys).to eq range.values
@@ -708,100 +413,18 @@ describe Yt::Video, :partner do
708
413
  end
709
414
  end
710
415
 
711
- describe 'shares can be retrieved for a specific day' do
712
- context 'in which the video was partnered' do
713
- let(:date) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 95 }
714
- let(:shares) { video.shares_on date }
715
- it { expect(shares).to be_an Integer }
716
- end
416
+ describe 'shares can be grouped by day' do
417
+ let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
418
+ let(:keys) { range.values }
717
419
 
718
- context 'in which the video was not partnered' do
719
- let(:shares) { video.shares_on 20.years.ago}
720
- it { expect(shares).to be_nil }
420
+ specify 'with the :by option set to :day' do
421
+ shares = video.shares range.merge by: :day
422
+ expect(shares.keys).to eq range.values
721
423
  end
722
424
  end
723
425
 
724
- describe 'shares can be retrieved for a single country' do
725
- let(:country_code) { 'PT' }
726
- let(:shares) { video.shares since: date, by: by, in: location }
727
- let(:date) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 95 }
728
-
729
- context 'and grouped by day' do
730
- let(:by) { :day }
731
-
732
- context 'with the :in option set to the country code' do
733
- let(:location) { country_code }
734
- it { expect(shares.keys.min).to eq date.to_date }
735
- end
736
-
737
- context 'with the :in option set to {country: country code}' do
738
- let(:location) { {country: country_code} }
739
- it { expect(shares.keys.min).to eq date.to_date }
740
- end
741
- end
742
-
743
- context 'and grouped by country' do
744
- let(:by) { :country }
745
-
746
- context 'with the :in option set to the country code' do
747
- let(:location) { country_code }
748
- it { expect(shares.keys).to eq [country_code] }
749
- end
750
-
751
- context 'with the :in option set to {country: country code}' do
752
- let(:location) { {country: country_code} }
753
- it { expect(shares.keys).to eq [country_code] }
754
- end
755
- end
756
- end
757
-
758
- describe 'shares can be retrieved for a range of days' do
759
- let(:date) { 4.days.ago }
760
-
761
- specify 'with a given start (:since option)' do
762
- expect(video.shares(since: date).keys.min).to eq date.to_date
763
- end
764
-
765
- specify 'with a given end (:until option)' do
766
- expect(video.shares(until: date).keys.max).to eq date.to_date
767
- end
768
-
769
- specify 'with a given start (:from option)' do
770
- expect(video.shares(from: date).keys.min).to eq date.to_date
771
- end
772
-
773
- specify 'with a given end (:to option)' do
774
- expect(video.shares(to: date).keys.max).to eq date.to_date
775
- end
776
- end
777
-
778
- describe 'shares can be grouped by range' do
779
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
780
-
781
- specify 'with the :by option set to :range' do
782
- shares = video.shares range.merge by: :range
783
- expect(shares.size).to be 1
784
- expect(shares[:total]).to be_an Integer
785
- end
786
- end
787
-
788
- describe 'shares can be grouped by day' do
789
- let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
790
- let(:keys) { range.values }
791
-
792
- specify 'without a :by option (default)' do
793
- shares = video.shares range
794
- expect(shares.keys).to eq range.values
795
- end
796
-
797
- specify 'with the :by option set to :day' do
798
- shares = video.shares range.merge by: :day
799
- expect(shares.keys).to eq range.values
800
- end
801
- end
802
-
803
- describe 'shares can be grouped by country' do
804
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
426
+ describe 'shares can be grouped by country' do
427
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
805
428
 
806
429
  specify 'with the :by option set to :country' do
807
430
  shares = video.shares range.merge by: :country
@@ -811,91 +434,10 @@ describe Yt::Video, :partner do
811
434
  end
812
435
  end
813
436
 
814
- describe 'gained subscribers can be retrieved for a specific day' do
815
- context 'in which the video was partnered' do
816
- let(:subscribers_gained) { video.subscribers_gained_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
817
- it { expect(subscribers_gained).to be_an Integer }
818
- end
819
-
820
- context 'in which the video was not partnered' do
821
- let(:subscribers_gained) { video.subscribers_gained_on 20.years.ago}
822
- it { expect(subscribers_gained).to be_nil }
823
- end
824
- end
825
-
826
- describe 'gained subscribers can be retrieved for a single country' do
827
- let(:country_code) { 'US' }
828
- let(:subscribers_gained) { video.subscribers_gained since: date, by: by, in: location }
829
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
830
-
831
- context 'and grouped by day' do
832
- let(:by) { :day }
833
-
834
- context 'with the :in option set to the country code' do
835
- let(:location) { country_code }
836
- it { expect(subscribers_gained.keys.min).to eq date.to_date }
837
- end
838
-
839
- context 'with the :in option set to {country: country code}' do
840
- let(:location) { {country: country_code} }
841
- it { expect(subscribers_gained.keys.min).to eq date.to_date }
842
- end
843
- end
844
-
845
- context 'and grouped by country' do
846
- let(:by) { :country }
847
-
848
- context 'with the :in option set to the country code' do
849
- let(:location) { country_code }
850
- it { expect(subscribers_gained.keys).to eq [country_code] }
851
- end
852
-
853
- context 'with the :in option set to {country: country code}' do
854
- let(:location) { {country: country_code} }
855
- it { expect(subscribers_gained.keys).to eq [country_code] }
856
- end
857
- end
858
- end
859
-
860
- describe 'gained subscribers can be retrieved for a range of days' do
861
- let(:date) { 4.days.ago }
862
-
863
- specify 'with a given start (:since option)' do
864
- expect(video.subscribers_gained(since: date).keys.min).to eq date.to_date
865
- end
866
-
867
- specify 'with a given end (:until option)' do
868
- expect(video.subscribers_gained(until: date).keys.max).to eq date.to_date
869
- end
870
-
871
- specify 'with a given start (:from option)' do
872
- expect(video.subscribers_gained(from: date).keys.min).to eq date.to_date
873
- end
874
-
875
- specify 'with a given end (:to option)' do
876
- expect(video.subscribers_gained(to: date).keys.max).to eq date.to_date
877
- end
878
- end
879
-
880
- describe 'gained subscribers can be grouped by range' do
881
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
882
-
883
- specify 'with the :by option set to :range' do
884
- subscribers_gained = video.subscribers_gained range.merge by: :range
885
- expect(subscribers_gained.size).to be 1
886
- expect(subscribers_gained[:total]).to be_an Integer
887
- end
888
- end
889
-
890
437
  describe 'gained subscribers can be grouped by day' do
891
438
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
892
439
  let(:keys) { range.values }
893
440
 
894
- specify 'without a :by option (default)' do
895
- subscribers_gained = video.subscribers_gained range
896
- expect(subscribers_gained.keys).to eq range.values
897
- end
898
-
899
441
  specify 'with the :by option set to :day' do
900
442
  subscribers_gained = video.subscribers_gained range.merge by: :day
901
443
  expect(subscribers_gained.keys).to eq range.values
@@ -913,91 +455,10 @@ describe Yt::Video, :partner do
913
455
  end
914
456
  end
915
457
 
916
- describe 'lost subscribers can be retrieved for a specific day' do
917
- context 'in which the video was partnered' do
918
- let(:subscribers_lost) { video.subscribers_lost_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
919
- it { expect(subscribers_lost).to be_an Integer }
920
- end
921
-
922
- context 'in which the video was not partnered' do
923
- let(:subscribers_lost) { video.subscribers_lost_on 20.years.ago}
924
- it { expect(subscribers_lost).to be_nil }
925
- end
926
- end
927
-
928
- describe 'lost subscribers can be retrieved for a single country' do
929
- let(:country_code) { 'BR' }
930
- let(:subscribers_lost) { video.subscribers_lost since: date, by: by, in: location }
931
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
932
-
933
- context 'and grouped by day' do
934
- let(:by) { :day }
935
-
936
- context 'with the :in option set to the country code' do
937
- let(:location) { country_code }
938
- it { expect(subscribers_lost.keys.min).to eq date.to_date }
939
- end
940
-
941
- context 'with the :in option set to {country: country code}' do
942
- let(:location) { {country: country_code} }
943
- it { expect(subscribers_lost.keys.min).to eq date.to_date }
944
- end
945
- end
946
-
947
- context 'and grouped by country' do
948
- let(:by) { :country }
949
-
950
- context 'with the :in option set to the country code' do
951
- let(:location) { country_code }
952
- it { expect(subscribers_lost.keys).to eq [country_code] }
953
- end
954
-
955
- context 'with the :in option set to {country: country code}' do
956
- let(:location) { {country: country_code} }
957
- it { expect(subscribers_lost.keys).to eq [country_code] }
958
- end
959
- end
960
- end
961
-
962
- describe 'lost subscribers can be retrieved for a range of days' do
963
- let(:date) { 4.days.ago }
964
-
965
- specify 'with a given start (:since option)' do
966
- expect(video.subscribers_lost(since: date).keys.min).to eq date.to_date
967
- end
968
-
969
- specify 'with a given end (:until option)' do
970
- expect(video.subscribers_lost(until: date).keys.max).to eq date.to_date
971
- end
972
-
973
- specify 'with a given start (:from option)' do
974
- expect(video.subscribers_lost(from: date).keys.min).to eq date.to_date
975
- end
976
-
977
- specify 'with a given end (:to option)' do
978
- expect(video.subscribers_lost(to: date).keys.max).to eq date.to_date
979
- end
980
- end
981
-
982
- describe 'lost subscribers can be grouped by range' do
983
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
984
-
985
- specify 'with the :by option set to :range' do
986
- subscribers_lost = video.subscribers_lost range.merge by: :range
987
- expect(subscribers_lost.size).to be 1
988
- expect(subscribers_lost[:total]).to be_an Integer
989
- end
990
- end
991
-
992
458
  describe 'lost subscribers can be grouped by day' do
993
459
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
994
460
  let(:keys) { range.values }
995
461
 
996
- specify 'without a :by option (default)' do
997
- subscribers_lost = video.subscribers_lost range
998
- expect(subscribers_lost.keys).to eq range.values
999
- end
1000
-
1001
462
  specify 'with the :by option set to :day' do
1002
463
  subscribers_lost = video.subscribers_lost range.merge by: :day
1003
464
  expect(subscribers_lost.keys).to eq range.values
@@ -1015,91 +476,10 @@ describe Yt::Video, :partner do
1015
476
  end
1016
477
  end
1017
478
 
1018
- describe 'added favorites can be retrieved for a specific day' do
1019
- context 'in which the video was partnered' do
1020
- let(:favorites_added) { video.favorites_added_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
1021
- it { expect(favorites_added).to be_an Integer }
1022
- end
1023
-
1024
- context 'in which the video was not partnered' do
1025
- let(:favorites_added) { video.favorites_added_on 20.years.ago}
1026
- it { expect(favorites_added).to be_nil }
1027
- end
1028
- end
1029
-
1030
- describe 'favorites added can be retrieved for a single country' do
1031
- let(:country_code) { 'US' }
1032
- let(:favorites_added) { video.favorites_added since: date, by: by, in: location }
1033
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1034
-
1035
- context 'and grouped by day' do
1036
- let(:by) { :day }
1037
-
1038
- context 'with the :in option set to the country code' do
1039
- let(:location) { country_code }
1040
- it { expect(favorites_added.keys.min).to eq date.to_date }
1041
- end
1042
-
1043
- context 'with the :in option set to {country: country code}' do
1044
- let(:location) { {country: country_code} }
1045
- it { expect(favorites_added.keys.min).to eq date.to_date }
1046
- end
1047
- end
1048
-
1049
- context 'and grouped by country' do
1050
- let(:by) { :country }
1051
-
1052
- context 'with the :in option set to the country code' do
1053
- let(:location) { country_code }
1054
- it { expect(favorites_added.keys).to eq [country_code] }
1055
- end
1056
-
1057
- context 'with the :in option set to {country: country code}' do
1058
- let(:location) { {country: country_code} }
1059
- it { expect(favorites_added.keys).to eq [country_code] }
1060
- end
1061
- end
1062
- end
1063
-
1064
- describe 'added favorites can be retrieved for a range of days' do
1065
- let(:date) { 4.days.ago }
1066
-
1067
- specify 'with a given start (:since option)' do
1068
- expect(video.favorites_added(since: date).keys.min).to eq date.to_date
1069
- end
1070
-
1071
- specify 'with a given end (:until option)' do
1072
- expect(video.favorites_added(until: date).keys.max).to eq date.to_date
1073
- end
1074
-
1075
- specify 'with a given start (:from option)' do
1076
- expect(video.favorites_added(from: date).keys.min).to eq date.to_date
1077
- end
1078
-
1079
- specify 'with a given end (:to option)' do
1080
- expect(video.favorites_added(to: date).keys.max).to eq date.to_date
1081
- end
1082
- end
1083
-
1084
- describe 'added favorites can be grouped by range' do
1085
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1086
-
1087
- specify 'with the :by option set to :range' do
1088
- favorites_added = video.favorites_added range.merge by: :range
1089
- expect(favorites_added.size).to be 1
1090
- expect(favorites_added[:total]).to be_an Integer
1091
- end
1092
- end
1093
-
1094
479
  describe 'added favorites can be grouped by day' do
1095
480
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1096
481
  let(:keys) { range.values }
1097
482
 
1098
- specify 'without a :by option (default)' do
1099
- favorites_added = video.favorites_added range
1100
- expect(favorites_added.keys).to eq range.values
1101
- end
1102
-
1103
483
  specify 'with the :by option set to :day' do
1104
484
  favorites_added = video.favorites_added range.merge by: :day
1105
485
  expect(favorites_added.keys).to eq range.values
@@ -1117,93 +497,10 @@ describe Yt::Video, :partner do
1117
497
  end
1118
498
  end
1119
499
 
1120
- describe 'removed favorites can be retrieved for a specific day' do
1121
- context 'in which the video was partnered' do
1122
- let(:favorites_removed) { video.favorites_removed_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
1123
- it { expect(favorites_removed).to be_an Integer }
1124
- end
1125
-
1126
- context 'in which the video was not partnered' do
1127
- let(:favorites_removed) { video.favorites_removed_on 20.years.ago}
1128
- it { expect(favorites_removed).to be_nil }
1129
- end
1130
- end
1131
-
1132
- describe 'favorites removed can be retrieved for a single country' do
1133
- let(:country_code) { 'US' }
1134
- let(:favorites_removed) { video.favorites_removed since: date, by: by, in: location }
1135
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1136
-
1137
- context 'and grouped by day' do
1138
- let(:by) { :day }
1139
-
1140
- context 'with the :in option set to the country code' do
1141
- let(:location) { country_code }
1142
- it { expect(favorites_removed.keys.min).to eq date.to_date }
1143
- end
1144
-
1145
- context 'with the :in option set to {country: country code}' do
1146
- let(:location) { {country: country_code} }
1147
- it { expect(favorites_removed.keys.min).to eq date.to_date }
1148
- end
1149
- end
1150
-
1151
- # TODO: Remove "removed favorites" since it’s deprecated!
1152
- # context 'and grouped by country' do
1153
- # let(:by) { :country }
1154
- #
1155
- # context 'with the :in option set to the country code' do
1156
- # let(:location) { country_code }
1157
- # it { expect(favorites_removed.keys).to eq [country_code] }
1158
- # end
1159
- #
1160
- # context 'with the :in option set to {country: country code}' do
1161
- # let(:location) { {country: country_code} }
1162
- # it { expect(favorites_removed.keys).to eq [country_code] }
1163
- # end
1164
- # end
1165
- end
1166
-
1167
- describe 'removed favorites can be retrieved for a range of days' do
1168
- let(:date) { 4.days.ago }
1169
-
1170
- specify 'with a given start (:since option)' do
1171
- expect(video.favorites_removed(since: date).keys.min).to eq date.to_date
1172
- end
1173
-
1174
- specify 'with a given end (:until option)' do
1175
- expect(video.favorites_removed(until: date).keys.max).to eq date.to_date
1176
- end
1177
-
1178
- specify 'with a given start (:from option)' do
1179
- expect(video.favorites_removed(from: date).keys.min).to eq date.to_date
1180
- end
1181
-
1182
- specify 'with a given end (:to option)' do
1183
- expect(video.favorites_removed(to: date).keys.max).to eq date.to_date
1184
- end
1185
- end
1186
-
1187
- describe 'removed favorites can be grouped by range' do
1188
- let(:id) { 'NeMlqbX2Ifg' }
1189
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1190
-
1191
- specify 'with the :by option set to :range' do
1192
- favorites_removed = video.favorites_removed range.merge by: :range
1193
- expect(favorites_removed.size).to be 1
1194
- expect(favorites_removed[:total]).to be_an Integer
1195
- end
1196
- end
1197
-
1198
500
  describe 'removed favorites can be grouped by day' do
1199
501
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1200
502
  let(:keys) { range.values }
1201
503
 
1202
- specify 'without a :by option (default)' do
1203
- favorites_removed = video.favorites_removed range
1204
- expect(favorites_removed.keys).to eq range.values
1205
- end
1206
-
1207
504
  specify 'with the :by option set to :day' do
1208
505
  favorites_removed = video.favorites_removed range.merge by: :day
1209
506
  expect(favorites_removed.keys).to eq range.values
@@ -1222,56 +519,10 @@ describe Yt::Video, :partner do
1222
519
  # end
1223
520
  # end
1224
521
 
1225
- describe 'estimated minutes watched can be retrieved for a specific day' do
1226
- context 'in which the video was partnered' do
1227
- let(:estimated_minutes_watched) { video.estimated_minutes_watched_on 5.days.ago}
1228
- it { expect(estimated_minutes_watched).to be_a Float }
1229
- end
1230
-
1231
- context 'in which the video was not partnered' do
1232
- let(:estimated_minutes_watched) { video.estimated_minutes_watched_on 20.years.ago}
1233
- it { expect(estimated_minutes_watched).to be_nil }
1234
- end
1235
- end
1236
-
1237
- describe 'estimated minutes watched can be retrieved for a single country' do
1238
- let(:country_code) { 'US' }
1239
- let(:estimated_minutes_watched) { video.estimated_minutes_watched since: date, by: by, in: location }
1240
- let(:date) { 4.days.ago }
1241
-
1242
- context 'and grouped by day' do
1243
- let(:by) { :day }
1244
-
1245
- context 'with the :in option set to the country code' do
1246
- let(:location) { country_code }
1247
- it { expect(estimated_minutes_watched.keys.min).to eq date.to_date }
1248
- end
1249
-
1250
- context 'with the :in option set to {country: country code}' do
1251
- let(:location) { {country: country_code} }
1252
- it { expect(estimated_minutes_watched.keys.min).to eq date.to_date }
1253
- end
1254
- end
1255
-
1256
- context 'and grouped by country' do
1257
- let(:by) { :country }
1258
-
1259
- context 'with the :in option set to the country code' do
1260
- let(:location) { country_code }
1261
- it { expect(estimated_minutes_watched.keys).to eq [country_code] }
1262
- end
1263
-
1264
- context 'with the :in option set to {country: country code}' do
1265
- let(:location) { {country: country_code} }
1266
- it { expect(estimated_minutes_watched.keys).to eq [country_code] }
1267
- end
1268
- end
1269
- end
1270
-
1271
522
  describe 'estimated minutes watched can be retrieved for a single US state' do
1272
523
  let(:state_code) { 'NY' }
1273
524
  let(:minutes) { video.estimated_minutes_watched since: date, by: by, in: location }
1274
- let(:date) { 4.days.ago }
525
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1275
526
 
1276
527
  context 'and grouped by day' do
1277
528
  let(:by) { :day }
@@ -1302,45 +553,10 @@ describe Yt::Video, :partner do
1302
553
  end
1303
554
  end
1304
555
 
1305
- describe 'estimated minutes watched can be retrieved for a range of days' do
1306
- let(:date) { 4.days.ago }
1307
-
1308
- specify 'with a given start (:since option)' do
1309
- expect(video.estimated_minutes_watched(since: date).keys.min).to eq date.to_date
1310
- end
1311
-
1312
- specify 'with a given end (:until option)' do
1313
- expect(video.estimated_minutes_watched(until: date).keys.max).to eq date.to_date
1314
- end
1315
-
1316
- specify 'with a given start (:from option)' do
1317
- expect(video.estimated_minutes_watched(from: date).keys.min).to eq date.to_date
1318
- end
1319
-
1320
- specify 'with a given end (:to option)' do
1321
- expect(video.estimated_minutes_watched(to: date).keys.max).to eq date.to_date
1322
- end
1323
- end
1324
-
1325
- describe 'estimated minutes watched can be grouped by range' do
1326
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1327
-
1328
- specify 'with the :by option set to :range' do
1329
- minutes = video.estimated_minutes_watched range.merge by: :range
1330
- expect(minutes.size).to be 1
1331
- expect(minutes[:total]).to be_a Float
1332
- end
1333
- end
1334
-
1335
556
  describe 'estimated minutes watched can be grouped by day' do
1336
557
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1337
558
  let(:keys) { range.values }
1338
559
 
1339
- specify 'without a :by option (default)' do
1340
- estimated_minutes_watched = video.estimated_minutes_watched range
1341
- expect(estimated_minutes_watched.keys).to eq range.values
1342
- end
1343
-
1344
560
  specify 'with the :by option set to :day' do
1345
561
  estimated_minutes_watched = video.estimated_minutes_watched range.merge by: :day
1346
562
  expect(estimated_minutes_watched.keys).to eq range.values
@@ -1426,56 +642,10 @@ describe Yt::Video, :partner do
1426
642
  end
1427
643
  end
1428
644
 
1429
- describe 'average view duration can be retrieved for a specific day' do
1430
- context 'in which the video was partnered' do
1431
- let(:average_view_duration) { video.average_view_duration_on 5.days.ago}
1432
- it { expect(average_view_duration).to be_a Float }
1433
- end
1434
-
1435
- context 'in which the video was not partnered' do
1436
- let(:average_view_duration) { video.average_view_duration_on 20.years.ago}
1437
- it { expect(average_view_duration).to be_nil }
1438
- end
1439
- end
1440
-
1441
- describe 'average view duration can be retrieved for a single country' do
1442
- let(:country_code) { 'US' }
1443
- let(:average_view_duration) { video.average_view_duration since: date, by: by, in: location }
1444
- let(:date) { 4.days.ago }
1445
-
1446
- context 'and grouped by day' do
1447
- let(:by) { :day }
1448
-
1449
- context 'with the :in option set to the country code' do
1450
- let(:location) { country_code }
1451
- it { expect(average_view_duration.keys.min).to eq date.to_date }
1452
- end
1453
-
1454
- context 'with the :in option set to {country: country code}' do
1455
- let(:location) { {country: country_code} }
1456
- it { expect(average_view_duration.keys.min).to eq date.to_date }
1457
- end
1458
- end
1459
-
1460
- context 'and grouped by country' do
1461
- let(:by) { :country }
1462
-
1463
- context 'with the :in option set to the country code' do
1464
- let(:location) { country_code }
1465
- it { expect(average_view_duration.keys).to eq [country_code] }
1466
- end
1467
-
1468
- context 'with the :in option set to {country: country code}' do
1469
- let(:location) { {country: country_code} }
1470
- it { expect(average_view_duration.keys).to eq [country_code] }
1471
- end
1472
- end
1473
- end
1474
-
1475
645
  describe 'average view duration can be retrieved for a single US state' do
1476
646
  let(:state_code) { 'NY' }
1477
647
  let(:duration) { video.average_view_duration since: date, by: by, in: location }
1478
- let(:date) { 4.days.ago }
648
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1479
649
 
1480
650
  context 'and grouped by day' do
1481
651
  let(:by) { :day }
@@ -1506,44 +676,9 @@ describe Yt::Video, :partner do
1506
676
  end
1507
677
  end
1508
678
 
1509
- describe 'average view duration can be retrieved for a range of days' do
1510
- let(:date) { 4.days.ago }
1511
-
1512
- specify 'with a given start (:since option)' do
1513
- expect(video.average_view_duration(since: date).keys.min).to eq date.to_date
1514
- end
1515
-
1516
- specify 'with a given end (:until option)' do
1517
- expect(video.average_view_duration(until: date).keys.max).to eq date.to_date
1518
- end
1519
-
1520
- specify 'with a given start (:from option)' do
1521
- expect(video.average_view_duration(from: date).keys.min).to eq date.to_date
1522
- end
1523
-
1524
- specify 'with a given end (:to option)' do
1525
- expect(video.average_view_duration(to: date).keys.max).to eq date.to_date
1526
- end
1527
- end
1528
-
1529
- describe 'average view duration can be grouped by range' do
1530
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1531
-
1532
- specify 'with the :by option set to :range' do
1533
- duration = video.average_view_duration range.merge by: :range
1534
- expect(duration.size).to be 1
1535
- expect(duration[:total]).to be_a Float
1536
- end
1537
- end
1538
-
1539
679
  describe 'average view duration can be grouped by day' do
1540
- let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1541
- let(:keys) { range.values }
1542
-
1543
- specify 'without a :by option (default)' do
1544
- average_view_duration = video.average_view_duration range
1545
- expect(average_view_duration.keys).to eq range.values
1546
- end
680
+ let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
681
+ let(:keys) { range.values }
1547
682
 
1548
683
  specify 'with the :by option set to :day' do
1549
684
  average_view_duration = video.average_view_duration range.merge by: :day
@@ -1573,56 +708,10 @@ describe Yt::Video, :partner do
1573
708
  end
1574
709
  end
1575
710
 
1576
- describe 'average view percentage can be retrieved for a specific day' do
1577
- context 'in which the video was partnered' do
1578
- let(:average_view_percentage) { video.average_view_percentage_on 5.days.ago}
1579
- it { expect(average_view_percentage).to be_a Float }
1580
- end
1581
-
1582
- context 'in which the video was not partnered' do
1583
- let(:average_view_percentage) { video.average_view_percentage_on 20.years.ago}
1584
- it { expect(average_view_percentage).to be_nil }
1585
- end
1586
- end
1587
-
1588
- describe 'average view percentage can be retrieved for a single country' do
1589
- let(:country_code) { 'US' }
1590
- let(:average_view_percentage) { video.average_view_percentage since: date, by: by, in: location }
1591
- let(:date) { 4.days.ago }
1592
-
1593
- context 'and grouped by day' do
1594
- let(:by) { :day }
1595
-
1596
- context 'with the :in option set to the country code' do
1597
- let(:location) { country_code }
1598
- it { expect(average_view_percentage.keys.min).to eq date.to_date }
1599
- end
1600
-
1601
- context 'with the :in option set to {country: country code}' do
1602
- let(:location) { {country: country_code} }
1603
- it { expect(average_view_percentage.keys.min).to eq date.to_date }
1604
- end
1605
- end
1606
-
1607
- context 'and grouped by country' do
1608
- let(:by) { :country }
1609
-
1610
- context 'with the :in option set to the country code' do
1611
- let(:location) { country_code }
1612
- it { expect(average_view_percentage.keys).to eq [country_code] }
1613
- end
1614
-
1615
- context 'with the :in option set to {country: country code}' do
1616
- let(:location) { {country: country_code} }
1617
- it { expect(average_view_percentage.keys).to eq [country_code] }
1618
- end
1619
- end
1620
- end
1621
-
1622
711
  describe 'average view percentage can be retrieved for a single US state' do
1623
712
  let(:state_code) { 'NY' }
1624
713
  let(:percentage) { video.average_view_percentage since: date, by: by, in: location }
1625
- let(:date) { 4.days.ago }
714
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1626
715
 
1627
716
  context 'and grouped by day' do
1628
717
  let(:by) { :day }
@@ -1653,45 +742,10 @@ describe Yt::Video, :partner do
1653
742
  end
1654
743
  end
1655
744
 
1656
- describe 'average view percentage can be retrieved for a range of days' do
1657
- let(:date) { 4.days.ago }
1658
-
1659
- specify 'with a given start (:since option)' do
1660
- expect(video.average_view_percentage(since: date).keys.min).to eq date.to_date
1661
- end
1662
-
1663
- specify 'with a given end (:until option)' do
1664
- expect(video.average_view_percentage(until: date).keys.max).to eq date.to_date
1665
- end
1666
-
1667
- specify 'with a given start (:from option)' do
1668
- expect(video.average_view_percentage(from: date).keys.min).to eq date.to_date
1669
- end
1670
-
1671
- specify 'with a given end (:to option)' do
1672
- expect(video.average_view_percentage(to: date).keys.max).to eq date.to_date
1673
- end
1674
- end
1675
-
1676
- describe 'average view percentage can be grouped by range' do
1677
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1678
-
1679
- specify 'with the :by option set to :range' do
1680
- percentage = video.average_view_percentage range.merge by: :range
1681
- expect(percentage.size).to be 1
1682
- expect(percentage[:total]).to be_a Float
1683
- end
1684
- end
1685
-
1686
745
  describe 'average view percentage can be grouped by day' do
1687
746
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1688
747
  let(:keys) { range.values }
1689
748
 
1690
- specify 'without a :by option (default)' do
1691
- average_view_percentage = video.average_view_percentage range
1692
- expect(average_view_percentage.keys).to eq range.values
1693
- end
1694
-
1695
749
  specify 'with the :by option set to :day' do
1696
750
  average_view_percentage = video.average_view_percentage range.merge by: :day
1697
751
  expect(average_view_percentage.keys).to eq range.values
@@ -1720,91 +774,10 @@ describe Yt::Video, :partner do
1720
774
  end
1721
775
  end
1722
776
 
1723
- describe 'impressions can be retrieved for a specific day' do
1724
- context 'in which the video was partnered' do
1725
- let(:impressions) { video.impressions_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
1726
- it { expect(impressions).to be_an Integer }
1727
- end
1728
-
1729
- context 'in which the video was not partnered' do
1730
- let(:impressions) { video.impressions_on 20.years.ago}
1731
- it { expect(impressions).to be_nil }
1732
- end
1733
- end
1734
-
1735
- describe 'impressions can be retrieved for a single country' do
1736
- let(:country_code) { 'US' }
1737
- let(:impressions) { video.impressions since: date, by: by, in: location }
1738
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1739
-
1740
- context 'and grouped by day' do
1741
- let(:by) { :day }
1742
-
1743
- context 'with the :in option set to the country code' do
1744
- let(:location) { country_code }
1745
- it { expect(impressions.keys.min).to eq date.to_date }
1746
- end
1747
-
1748
- context 'with the :in option set to {country: country code}' do
1749
- let(:location) { {country: country_code} }
1750
- it { expect(impressions.keys.min).to eq date.to_date }
1751
- end
1752
- end
1753
-
1754
- context 'and grouped by country' do
1755
- let(:by) { :country }
1756
-
1757
- context 'with the :in option set to the country code' do
1758
- let(:location) { country_code }
1759
- it { expect(impressions.keys).to eq [country_code] }
1760
- end
1761
-
1762
- context 'with the :in option set to {country: country code}' do
1763
- let(:location) { {country: country_code} }
1764
- it { expect(impressions.keys).to eq [country_code] }
1765
- end
1766
- end
1767
- end
1768
-
1769
- describe 'impressions can be retrieved for a range of days' do
1770
- let(:date) { 4.days.ago }
1771
-
1772
- specify 'with a given start (:since option)' do
1773
- expect(video.impressions(since: date).keys.min).to eq date.to_date
1774
- end
1775
-
1776
- specify 'with a given end (:until option)' do
1777
- expect(video.impressions(until: date).keys.max).to eq date.to_date
1778
- end
1779
-
1780
- specify 'with a given start (:from option)' do
1781
- expect(video.impressions(from: date).keys.min).to eq date.to_date
1782
- end
1783
-
1784
- specify 'with a given end (:to option)' do
1785
- expect(video.impressions(to: date).keys.max).to eq date.to_date
1786
- end
1787
- end
1788
-
1789
- describe 'impressions can be grouped by range' do
1790
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1791
-
1792
- specify 'with the :by option set to :range' do
1793
- impressions = video.impressions range.merge by: :range
1794
- expect(impressions.size).to be 1
1795
- expect(impressions[:total]).to be_an Integer
1796
- end
1797
- end
1798
-
1799
777
  describe 'impressions can be grouped by day' do
1800
778
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1801
779
  let(:keys) { range.values }
1802
780
 
1803
- specify 'without a :by option (default)' do
1804
- impressions = video.impressions range
1805
- expect(impressions.keys).to eq range.values
1806
- end
1807
-
1808
781
  specify 'with the :by option set to :day' do
1809
782
  impressions = video.impressions range.merge by: :day
1810
783
  expect(impressions.keys).to eq range.values
@@ -1822,91 +795,10 @@ describe Yt::Video, :partner do
1822
795
  end
1823
796
  end
1824
797
 
1825
- describe 'monetized playbacks can be retrieved for a specific day' do
1826
- context 'in which the video was partnered' do
1827
- let(:monetized_playbacks) { video.monetized_playbacks_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
1828
- it { expect(monetized_playbacks).to be_an Integer }
1829
- end
1830
-
1831
- context 'in which the video was not partnered' do
1832
- let(:monetized_playbacks) { video.monetized_playbacks_on 20.years.ago}
1833
- it { expect(monetized_playbacks).to be_nil }
1834
- end
1835
- end
1836
-
1837
- describe 'monetized playbacks can be retrieved for a single country' do
1838
- let(:country_code) { 'US' }
1839
- let(:monetized_playbacks) { video.monetized_playbacks since: date, by: by, in: location }
1840
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1841
-
1842
- context 'and grouped by day' do
1843
- let(:by) { :day }
1844
-
1845
- context 'with the :in option set to the country code' do
1846
- let(:location) { country_code }
1847
- it { expect(monetized_playbacks.keys.min).to eq date.to_date }
1848
- end
1849
-
1850
- context 'with the :in option set to {country: country code}' do
1851
- let(:location) { {country: country_code} }
1852
- it { expect(monetized_playbacks.keys.min).to eq date.to_date }
1853
- end
1854
- end
1855
-
1856
- context 'and grouped by country' do
1857
- let(:by) { :country }
1858
-
1859
- context 'with the :in option set to the country code' do
1860
- let(:location) { country_code }
1861
- it { expect(monetized_playbacks.keys).to eq [country_code] }
1862
- end
1863
-
1864
- context 'with the :in option set to {country: country code}' do
1865
- let(:location) { {country: country_code} }
1866
- it { expect(monetized_playbacks.keys).to eq [country_code] }
1867
- end
1868
- end
1869
- end
1870
-
1871
- describe 'monetized playbacks can be retrieved for a range of days' do
1872
- let(:date) { 4.days.ago }
1873
-
1874
- specify 'with a given start (:since option)' do
1875
- expect(video.monetized_playbacks(since: date).keys.min).to eq date.to_date
1876
- end
1877
-
1878
- specify 'with a given end (:until option)' do
1879
- expect(video.monetized_playbacks(until: date).keys.max).to eq date.to_date
1880
- end
1881
-
1882
- specify 'with a given start (:from option)' do
1883
- expect(video.monetized_playbacks(from: date).keys.min).to eq date.to_date
1884
- end
1885
-
1886
- specify 'with a given end (:to option)' do
1887
- expect(video.monetized_playbacks(to: date).keys.max).to eq date.to_date
1888
- end
1889
- end
1890
-
1891
- describe 'monetized playbacks can be grouped by range' do
1892
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1893
-
1894
- specify 'with the :by option set to :range' do
1895
- monetized_playbacks = video.monetized_playbacks range.merge by: :range
1896
- expect(monetized_playbacks.size).to be 1
1897
- expect(monetized_playbacks[:total]).to be_an Integer
1898
- end
1899
- end
1900
-
1901
798
  describe 'monetized_playbacks can be grouped by day' do
1902
799
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1903
800
  let(:keys) { range.values }
1904
801
 
1905
- specify 'without a :by option (default)' do
1906
- monetized_playbacks = video.monetized_playbacks range
1907
- expect(monetized_playbacks.keys).to eq range.values
1908
- end
1909
-
1910
802
  specify 'with the :by option set to :day' do
1911
803
  monetized_playbacks = video.monetized_playbacks range.merge by: :day
1912
804
  expect(monetized_playbacks.keys).to eq range.values
@@ -1924,67 +816,6 @@ describe Yt::Video, :partner do
1924
816
  end
1925
817
  end
1926
818
 
1927
- describe 'annotation clicks can be retrieved for a range of days' do
1928
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1929
- let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
1930
-
1931
- specify 'with a given start (:since option) and a given end (:until option)' do
1932
- expect(video.annotation_clicks(since: date, until: date_to).keys.min).to eq date.to_date
1933
- end
1934
-
1935
- specify 'with a given start (:from option) and a given end (:to option)' do
1936
- expect(video.annotation_clicks(from: date, to: date_to).keys.min).to eq date.to_date
1937
- end
1938
- end
1939
-
1940
- describe 'annotation clicks can be retrieved for a single country' do
1941
- let(:country_code) { 'US' }
1942
- let(:annotation_clicks) { video.annotation_clicks since: date, by: by, in: location }
1943
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1944
-
1945
- context 'and grouped by day' do
1946
- let(:by) { :day }
1947
-
1948
- context 'with the :in option set to the country code' do
1949
- let(:location) { country_code }
1950
- it { expect(annotation_clicks.keys.min).to eq date.to_date }
1951
- end
1952
-
1953
- context 'with the :in option set to {country: country code}' do
1954
- let(:location) { {country: country_code} }
1955
- it { expect(annotation_clicks.keys.min).to eq date.to_date }
1956
- end
1957
- end
1958
-
1959
- context 'and grouped by country' do
1960
- let(:by) { :country }
1961
-
1962
- context 'with the :in option set to the country code' do
1963
- let(:location) { country_code }
1964
- it { expect(annotation_clicks.keys).to eq [country_code] }
1965
- end
1966
-
1967
- context 'with the :in option set to {country: country code}' do
1968
- let(:location) { {country: country_code} }
1969
- it { expect(annotation_clicks.keys).to eq [country_code] }
1970
- end
1971
- end
1972
-
1973
- context 'and grouped by state' do
1974
- let(:by) { :state }
1975
-
1976
- context 'with the :in option set to the country code' do
1977
- let(:location) { country_code }
1978
- it { expect(annotation_clicks.keys.map(&:length).uniq).to eq [2] }
1979
- end
1980
-
1981
- context 'with the :in option set to {country: country code}' do
1982
- let(:location) { {country: country_code} }
1983
- it { expect(annotation_clicks.keys.map(&:length).uniq).to eq [2] }
1984
- end
1985
- end
1986
- end
1987
-
1988
819
  describe 'annotation clicks can be retrieved for a single US state' do
1989
820
  let(:state_code) { 'CA' }
1990
821
  let(:clicks) { video.annotation_clicks since: date, by: by, in: location }
@@ -2019,24 +850,9 @@ describe Yt::Video, :partner do
2019
850
  end
2020
851
  end
2021
852
 
2022
- describe 'annotation clicks can be grouped by range' do
2023
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
2024
-
2025
- specify 'with the :by option set to :range' do
2026
- annotation_clicks = video.annotation_clicks range.merge by: :range
2027
- expect(annotation_clicks.size).to be 1
2028
- expect(annotation_clicks[:total]).to be_an Integer
2029
- end
2030
- end
2031
-
2032
853
  describe 'annotation clicks can be grouped by day' do
2033
854
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
2034
855
 
2035
- specify 'without a :by option (default)' do
2036
- annotation_clicks = video.annotation_clicks range
2037
- expect(annotation_clicks.values).to all(be_an Integer)
2038
- end
2039
-
2040
856
  specify 'with the :by option set to :day' do
2041
857
  annotation_clicks = video.annotation_clicks range.merge by: :day
2042
858
  expect(annotation_clicks.values).to all(be_an Integer)
@@ -2065,67 +881,6 @@ describe Yt::Video, :partner do
2065
881
  end
2066
882
  end
2067
883
 
2068
- describe 'annotation click-through rate can be retrieved for a range of days' do
2069
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2070
- let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
2071
-
2072
- specify 'with a given start (:since option) and a given end (:until option)' do
2073
- expect(video.annotation_click_through_rate(since: date, until: date_to).keys.min).to eq date.to_date
2074
- end
2075
-
2076
- specify 'with a given start (:from option) and a given end (:to option)' do
2077
- expect(video.annotation_click_through_rate(from: date, to: date_to).keys.min).to eq date.to_date
2078
- end
2079
- end
2080
-
2081
- describe 'annotation click_through_rate can be retrieved for a single country' do
2082
- let(:country_code) { 'US' }
2083
- let(:annotation_click_through_rate) { video.annotation_click_through_rate since: date, by: by, in: location }
2084
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2085
-
2086
- context 'and grouped by day' do
2087
- let(:by) { :day }
2088
-
2089
- context 'with the :in option set to the country code' do
2090
- let(:location) { country_code }
2091
- it { expect(annotation_click_through_rate.keys.min).to eq date.to_date }
2092
- end
2093
-
2094
- context 'with the :in option set to {country: country code}' do
2095
- let(:location) { {country: country_code} }
2096
- it { expect(annotation_click_through_rate.keys.min).to eq date.to_date }
2097
- end
2098
- end
2099
-
2100
- context 'and grouped by country' do
2101
- let(:by) { :country }
2102
-
2103
- context 'with the :in option set to the country code' do
2104
- let(:location) { country_code }
2105
- it { expect(annotation_click_through_rate.keys).to eq [country_code] }
2106
- end
2107
-
2108
- context 'with the :in option set to {country: country code}' do
2109
- let(:location) { {country: country_code} }
2110
- it { expect(annotation_click_through_rate.keys).to eq [country_code] }
2111
- end
2112
- end
2113
-
2114
- context 'and grouped by state' do
2115
- let(:by) { :state }
2116
-
2117
- context 'with the :in option set to the country code' do
2118
- let(:location) { country_code }
2119
- it { expect(annotation_click_through_rate.keys.map(&:length).uniq).to eq [2] }
2120
- end
2121
-
2122
- context 'with the :in option set to {country: country code}' do
2123
- let(:location) { {country: country_code} }
2124
- it { expect(annotation_click_through_rate.keys.map(&:length).uniq).to eq [2] }
2125
- end
2126
- end
2127
- end
2128
-
2129
884
  describe 'annotation click_through_rate can be retrieved for a single US state' do
2130
885
  let(:state_code) { 'CA' }
2131
886
  let(:click_through_rate) { video.annotation_click_through_rate since: date, by: by, in: location }
@@ -2160,24 +915,9 @@ describe Yt::Video, :partner do
2160
915
  end
2161
916
  end
2162
917
 
2163
- describe 'annotation click-through rate can be grouped by range' do
2164
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
2165
-
2166
- specify 'with the :by option set to :range' do
2167
- rate = video.annotation_click_through_rate range.merge by: :range
2168
- expect(rate.size).to be 1
2169
- expect(rate[:total]).to be_a Float
2170
- end
2171
- end
2172
-
2173
918
  describe 'annotation click-through rate can be grouped by day' do
2174
919
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
2175
920
 
2176
- specify 'without a :by option (default)' do
2177
- annotation_click_through_rate = video.annotation_click_through_rate range
2178
- expect(annotation_click_through_rate.values).to all(be_instance_of Float)
2179
- end
2180
-
2181
921
  specify 'with the :by option set to :day' do
2182
922
  annotation_click_through_rate = video.annotation_click_through_rate range.merge by: :day
2183
923
  expect(annotation_click_through_rate.values).to all(be_instance_of Float)
@@ -2206,67 +946,6 @@ describe Yt::Video, :partner do
2206
946
  end
2207
947
  end
2208
948
 
2209
- describe 'annotation close rate can be retrieved for a range of days' do
2210
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2211
- let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
2212
-
2213
- specify 'with a given start (:since option) and a given end (:until option)' do
2214
- expect(video.annotation_close_rate(since: date, until: date_to).keys.min).to eq date.to_date
2215
- end
2216
-
2217
- specify 'with a given start (:from option) and a given end (:to option)' do
2218
- expect(video.annotation_close_rate(from: date, to: date_to).keys.min).to eq date.to_date
2219
- end
2220
- end
2221
-
2222
- describe 'annotation close_rate can be retrieved for a single country' do
2223
- let(:country_code) { 'US' }
2224
- let(:annotation_close_rate) { video.annotation_close_rate since: date, by: by, in: location }
2225
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2226
-
2227
- context 'and grouped by day' do
2228
- let(:by) { :day }
2229
-
2230
- context 'with the :in option set to the country code' do
2231
- let(:location) { country_code }
2232
- it { expect(annotation_close_rate.keys.min).to eq date.to_date }
2233
- end
2234
-
2235
- context 'with the :in option set to {country: country code}' do
2236
- let(:location) { {country: country_code} }
2237
- it { expect(annotation_close_rate.keys.min).to eq date.to_date }
2238
- end
2239
- end
2240
-
2241
- context 'and grouped by country' do
2242
- let(:by) { :country }
2243
-
2244
- context 'with the :in option set to the country code' do
2245
- let(:location) { country_code }
2246
- it { expect(annotation_close_rate.keys).to eq [country_code] }
2247
- end
2248
-
2249
- context 'with the :in option set to {country: country code}' do
2250
- let(:location) { {country: country_code} }
2251
- it { expect(annotation_close_rate.keys).to eq [country_code] }
2252
- end
2253
- end
2254
-
2255
- context 'and grouped by state' do
2256
- let(:by) { :state }
2257
-
2258
- context 'with the :in option set to the country code' do
2259
- let(:location) { country_code }
2260
- it { expect(annotation_close_rate.keys.map(&:length).uniq).to eq [2] }
2261
- end
2262
-
2263
- context 'with the :in option set to {country: country code}' do
2264
- let(:location) { {country: country_code} }
2265
- it { expect(annotation_close_rate.keys.map(&:length).uniq).to eq [2] }
2266
- end
2267
- end
2268
- end
2269
-
2270
949
  describe 'annotation close_rate can be retrieved for a single US state' do
2271
950
  let(:state_code) { 'CA' }
2272
951
  let(:close_rate) { video.annotation_close_rate since: date, by: by, in: location }
@@ -2301,24 +980,9 @@ describe Yt::Video, :partner do
2301
980
  end
2302
981
  end
2303
982
 
2304
- describe 'annotation close rate can be grouped by range' do
2305
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
2306
-
2307
- specify 'with the :by option set to :range' do
2308
- rate = video.annotation_close_rate range.merge by: :range
2309
- expect(rate.size).to be 1
2310
- expect(rate[:total]).to be_a Float
2311
- end
2312
- end
2313
-
2314
983
  describe 'annotation close rate can be grouped by day' do
2315
984
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
2316
985
 
2317
- specify 'without a :by option (default)' do
2318
- annotation_close_rate = video.annotation_close_rate range
2319
- expect(annotation_close_rate.values).to all(be_instance_of Float)
2320
- end
2321
-
2322
986
  specify 'with the :by option set to :day' do
2323
987
  annotation_close_rate = video.annotation_close_rate range.merge by: :day
2324
988
  expect(annotation_close_rate.values).to all(be_instance_of Float)