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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e80b3bef680e2c1352adc07802719b9721cb49b
4
- data.tar.gz: 794761dff30b57acb13261d180e68c61a52792e6
3
+ metadata.gz: 684b3fcaa4ab0f5f3ad32ec7296601f71e549e4a
4
+ data.tar.gz: f6026fcc1c013dd12ef05c53fe1e4ff2964fb4a8
5
5
  SHA512:
6
- metadata.gz: c5b1dc5b9561f1f3645f762ae0a532f38606f6fcff7d989465a6f0eef11a253ad268f573285b5491f45d84de67309f081ca393fc55b24b67549a9913624521ee
7
- data.tar.gz: 26d7305449a311a6ca0e04b62d33be2c6d114879dab273b995db20e34d1e52c1621f2d255b6d495f4d94c7e32d406a0dc7fc3a32f229b437f1f2f2eb36418403
6
+ metadata.gz: c050616344cebcb10223924565f11d1c00f6d06900afb7c955e8a5ed6f999c96c3af6860402007b433769a1d5ddcdbae221ad4f93de8e35f18e2b0924d7dc62b
7
+ data.tar.gz: e3d73c055a6cd8a2ffba67fc90066b0e412e7aa2a2c968fbf349892e18ade346b1758d73bf96d33b73033cfacef87b7846bffc94bd26e9e863020ed75390d807
@@ -6,6 +6,32 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.23.0 - 2015-05-18
10
+
11
+ **How to upgrade**
12
+
13
+ If your code expects reports to return results **by day** then you **must** add
14
+ the `by: :day` option to your report method. The new default is `by: :range`.
15
+ For instance `channel.views` would return
16
+
17
+ {Wed, 8 May 2014 => 12.4, Thu, 9 May 2014 => 3.2, Fri, 10 May 2014 => …}
18
+
19
+ and now returns the same as calling `channel.views by: :range`:
20
+
21
+ {total: 3450}
22
+
23
+ Additionally, if you expect reports **by day** then you **must** specify the
24
+ `:since` option to your report method. Previously, this value was set to
25
+ `5.days.ago`, but now is required. `:until` still defaults to `Date.today`.
26
+
27
+ Finally, if you expect reports for the entire range, notice that the default
28
+ `:since` option is now set to the date when YouTube opened. Therefore calling a
29
+ method like `channel.views` now returns the **lifetime** views of a channel.
30
+
31
+ * [ENHANCEMENT] Change default from `by: :day` to `by: :range`.
32
+ * [ENHANCEMENT] Require `:since` options for any report by day.
33
+ * [ENHANCEMENT] Change default range for reports by range to lifetime.
34
+
9
35
  ## 0.22.2 - 2015-05-15
10
36
 
11
37
  * [FEATURE] New `by: :search_term` option for reports.
data/README.md CHANGED
@@ -41,7 +41,7 @@ To install on your system, run
41
41
 
42
42
  To use inside a bundled Ruby project, add this line to the Gemfile:
43
43
 
44
- gem 'yt', '~> 0.22.2'
44
+ gem 'yt', '~> 0.23.0'
45
45
 
46
46
  Since the gem follows [Semantic Versioning](http://semver.org),
47
47
  indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
@@ -187,20 +187,20 @@ module Yt
187
187
 
188
188
  def define_metric_on_method(metric)
189
189
  define_method "#{metric}_on" do |date|
190
- send(metric, from: date, to: date).values.first
190
+ send(metric, from: date, to: date, by: :day).values.first
191
191
  end
192
192
  end
193
193
 
194
194
  def define_metric_method(metric)
195
195
  define_method metric do |options = {}|
196
- from = options[:since] || options[:from] || (metric == :viewer_percentage ? 3.months.ago : 5.days.ago)
197
- to = options[:until] || options[:to] || (metric == :viewer_percentage ? Date.today : 1.day.ago)
196
+ from = options[:since] || options[:from] || (options[:by] == :day ? 5.days.ago : '2005-02-01')
197
+ to = options[:until] || options[:to] || Date.today
198
198
  location = options[:in]
199
199
  country = location.is_a?(Hash) ? location[:country] : location
200
200
  state = location[:state] if location.is_a?(Hash)
201
201
 
202
202
  range = Range.new *[from, to].map(&:to_date)
203
- dimension = options[:by] || (metric == :viewer_percentage ? :gender_age_group : :day)
203
+ dimension = options[:by] || (metric == :viewer_percentage ? :gender_age_group : :range)
204
204
 
205
205
  ivar = instance_variable_get "@#{metric}_#{dimension}_#{country}_#{state}"
206
206
  instance_variable_set "@#{metric}_#{dimension}_#{country}_#{state}", ivar || {}
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.22.2'
2
+ VERSION = '0.23.0'
3
3
  end
@@ -10,12 +10,83 @@ describe Yt::Channel, :partner do
10
10
  context 'managed by the authenticated Content Owner' do
11
11
  let(:id) { ENV['YT_TEST_PARTNER_CHANNEL_ID'] }
12
12
 
13
- describe 'earnings can be retrieved for a specific day' do
14
- context 'in which the channel made any money' do
15
- let(:earnings) { channel.earnings_on 5.days.ago}
16
- it { expect(earnings).to be_a Float }
13
+ [:views, :uniques, :comments, :likes, :dislikes, :shares,
14
+ :subscribers_gained, :subscribers_lost, :favorites_added,
15
+ :favorites_removed, :estimated_minutes_watched, :average_view_duration,
16
+ :average_view_percentage, :impressions, :monetized_playbacks,
17
+ :annotation_clicks, :annotation_click_through_rate,
18
+ :annotation_close_rate, :earnings].each do |metric|
19
+ describe "#{metric} can be retrieved for a range of days" do
20
+ let(:date_in) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
21
+ let(:date_out) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
22
+ let(:metric) { metric }
23
+ let(:result) { channel.public_send metric, options }
24
+
25
+ context 'with a given start and end (:since/:until option)' do
26
+ let(:options) { {by: :day, since: date_in, until: date_out} }
27
+ it { expect(result.keys.min).to eq date_in.to_date }
28
+ it { expect(result.keys.max).to eq date_out.to_date }
29
+ end
30
+
31
+ context 'with a given start and end (:from/:to option)' do
32
+ let(:options) { {by: :day, from: date_in, to: date_out} }
33
+ it { expect(result.keys.min).to eq date_in.to_date }
34
+ it { expect(result.keys.max).to eq date_out.to_date }
35
+ end
36
+ end
37
+ end
38
+
39
+ {views: Integer, comments: Integer, likes: Integer, dislikes: Integer,
40
+ subscribers_gained: Integer, subscribers_lost: Integer,
41
+ estimated_minutes_watched: Float, average_view_duration: Float,
42
+ annotation_clicks: Integer, annotation_click_through_rate: Float,
43
+ favorites_added: Integer, favorites_removed: Integer,
44
+ average_view_percentage: Float, impressions: Integer,
45
+ shares: Integer,
46
+ monetized_playbacks: Integer, annotation_close_rate: Float,
47
+ earnings: Float}.each do |metric, type|
48
+ describe "#{metric} can be retrieved for a specific day" do
49
+ let(:metric) { metric }
50
+ let(:result) { channel.public_send "#{metric}_on", date }
51
+
52
+ context 'in which the channel had data for the report' do
53
+ let(:date) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 95 }
54
+ it { expect(result).to be_a type }
55
+ end
56
+
57
+ context 'in which the channel was not partnered' do
58
+ let(:date) { 5.days.from_now }
59
+ it { expect(result).to be_nil }
60
+ end
61
+ end
62
+ end
63
+
64
+ {views: Integer, comments: Integer, likes: Integer, dislikes: Integer,
65
+ shares: Integer, subscribers_gained: Integer, subscribers_lost: Integer,
66
+ favorites_added: Integer, favorites_removed: Integer,
67
+ estimated_minutes_watched: Float, average_view_duration: Float,
68
+ average_view_percentage: Float, impressions: Integer,
69
+ monetized_playbacks: Integer, annotation_clicks: Integer,
70
+ annotation_click_through_rate: Float, annotation_close_rate: Float,
71
+ earnings: Float}.each do |metric, type|
72
+ describe "#{metric} can be grouped by range" do
73
+ let(:metric) { metric }
74
+
75
+ context 'without a :by option (default)' do
76
+ let(:result) { channel.public_send metric }
77
+ it { expect(result.size).to be 1 }
78
+ it { expect(result[:total]).to be_a type }
79
+ end
80
+
81
+ context 'with the :by option set to :range' do
82
+ let(:result) { channel.public_send metric, by: :range }
83
+ it { expect(result.size).to be 1 }
84
+ it { expect(result[:total]).to be_a type }
85
+ end
17
86
  end
87
+ end
18
88
 
89
+ describe 'earnings can be retrieved for a specific day' do
19
90
  # NOTE: This test sounds redundant, but it’s actually a reflection of
20
91
  # another irrational behavior of YouTube API. In short, if you ask for
21
92
  # the "earnings" metric of a day in which a channel made 0 USD, then
@@ -28,11 +99,6 @@ describe Yt::Channel, :partner do
28
99
  let(:earnings) { channel.earnings_on zero_date}
29
100
  it { expect(earnings).to eq 0 }
30
101
  end
31
-
32
- context 'in the future' do
33
- let(:earnings) { channel.earnings_on 5.days.from_now}
34
- it { expect(earnings).to be_nil }
35
- end
36
102
  end
37
103
 
38
104
  describe 'earnings can be retrieved for a single country' do
@@ -69,46 +135,10 @@ describe Yt::Channel, :partner do
69
135
  end
70
136
  end
71
137
 
72
- describe 'earnings can be retrieved for a range of days' do
73
- let(:date) { 4.days.ago }
74
-
75
- specify 'with a given start (:since option)' do
76
- expect(channel.earnings(since: date).keys.min).to eq date.to_date
77
- end
78
-
79
- specify 'with a given end (:until option)' do
80
- expect(channel.earnings(until: date).keys.max).to eq date.to_date
81
- end
82
-
83
- specify 'with a given start (:from option)' do
84
- expect(channel.earnings(from: date).keys.min).to eq date.to_date
85
- end
86
-
87
- specify 'with a given end (:to option)' do
88
- expect(channel.earnings(to: date).keys.max).to eq date.to_date
89
- end
90
- end
91
-
92
- describe 'earnings can be grouped by range' do
93
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
94
- let(:keys) { range.values }
95
-
96
- specify 'with the :by option set to :range' do
97
- earnings = channel.earnings range.merge by: :range
98
- expect(earnings.size).to be 1
99
- expect(earnings[:total]).to be_a Float
100
- end
101
- end
102
-
103
138
  describe 'earnings can be grouped by day' do
104
139
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
105
140
  let(:keys) { range.values }
106
141
 
107
- specify 'without a :by option (default)' do
108
- earnings = channel.earnings range
109
- expect(earnings.keys).to eq range.values
110
- end
111
-
112
142
  specify 'with the :by option set to :day' do
113
143
  earnings = channel.earnings range.merge by: :day
114
144
  expect(earnings.keys).to eq range.values
@@ -126,18 +156,6 @@ describe Yt::Channel, :partner do
126
156
  end
127
157
  end
128
158
 
129
- describe 'views can be retrieved for a specific day' do
130
- context 'in which the channel was partnered' do
131
- let(:views) { channel.views_on 5.days.ago}
132
- it { expect(views).to be_an Integer }
133
- end
134
-
135
- context 'in which the channel was not partnered' do
136
- let(:views) { channel.views_on 20.years.ago}
137
- it { expect(views).to be_nil }
138
- end
139
- end
140
-
141
159
  describe 'views can be retrieved for a single country' do
142
160
  let(:country_code) { 'US' }
143
161
  let(:views) { channel.views since: date, by: by, in: location }
@@ -220,45 +238,10 @@ describe Yt::Channel, :partner do
220
238
  end
221
239
  end
222
240
 
223
- describe 'views can be retrieved for a range of days' do
224
- let(:date) { 4.days.ago }
225
-
226
- specify 'with a given start (:since option)' do
227
- expect(channel.views(since: date).keys.min).to eq date.to_date
228
- end
229
-
230
- specify 'with a given end (:until option)' do
231
- expect(channel.views(until: date).keys.max).to eq date.to_date
232
- end
233
-
234
- specify 'with a given start (:from option)' do
235
- expect(channel.views(from: date).keys.min).to eq date.to_date
236
- end
237
-
238
- specify 'with a given end (:to option)' do
239
- expect(channel.views(to: date).keys.max).to eq date.to_date
240
- end
241
- end
242
-
243
- describe 'views can be grouped by range' do
244
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
245
-
246
- specify 'with the :by option set to :range' do
247
- views = channel.views range.merge by: :range
248
- expect(views.size).to be 1
249
- expect(views[:total]).to be_an Integer
250
- end
251
- end
252
-
253
241
  describe 'views can be grouped by day' do
254
242
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
255
243
  let(:keys) { range.values }
256
244
 
257
- specify 'without a :by option (default)' do
258
- views = channel.views range
259
- expect(views.keys).to eq range.values
260
- end
261
-
262
245
  specify 'with the :by option set to :day' do
263
246
  views = channel.views range.merge by: :day
264
247
  expect(views.keys).to eq range.values
@@ -402,53 +385,16 @@ describe Yt::Channel, :partner do
402
385
  end
403
386
  end
404
387
 
405
- describe 'uniques can be retrieved for a range of days' do
406
- let(:date) { 4.days.ago }
407
-
408
- specify 'with a given start (:since option)' do
409
- expect(channel.uniques(since: date).keys.min).to eq date.to_date
410
- end
411
-
412
- specify 'with a given end (:until option)' do
413
- expect(channel.uniques(until: date).keys.max).to eq date.to_date
414
- end
415
-
416
- specify 'with a given start (:from option)' do
417
- expect(channel.uniques(from: date).keys.min).to eq date.to_date
418
- end
419
-
420
- specify 'with a given end (:to option)' do
421
- expect(channel.uniques(to: date).keys.max).to eq date.to_date
422
- end
423
- end
424
-
425
388
  describe 'uniques can be grouped by day' do
426
389
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
427
390
  let(:keys) { range.values }
428
391
 
429
- specify 'without a :by option (default)' do
430
- uniques = channel.uniques range
431
- expect(uniques.keys).to eq range.values
432
- end
433
-
434
392
  specify 'with the :by option set to :day' do
435
393
  uniques = channel.uniques range.merge by: :day
436
394
  expect(uniques.keys).to eq range.values
437
395
  end
438
396
  end
439
397
 
440
- describe 'comments can be retrieved for a specific day' do
441
- context 'in which the channel was partnered' do
442
- let(:comments) { channel.comments_on 5.days.ago}
443
- it { expect(comments).to be_an Integer }
444
- end
445
-
446
- context 'in which the channel was not partnered' do
447
- let(:comments) { channel.comments_on 20.years.ago}
448
- it { expect(comments).to be_nil }
449
- end
450
- end
451
-
452
398
  describe 'comments can be retrieved for a single country' do
453
399
  let(:country_code) { 'US' }
454
400
  let(:comments) { channel.comments since: date, by: by, in: location }
@@ -483,45 +429,10 @@ describe Yt::Channel, :partner do
483
429
  end
484
430
  end
485
431
 
486
- describe 'comments can be retrieved for a range of days' do
487
- let(:date) { 4.days.ago }
488
-
489
- specify 'with a given start (:since option)' do
490
- expect(channel.comments(since: date).keys.min).to eq date.to_date
491
- end
492
-
493
- specify 'with a given end (:until option)' do
494
- expect(channel.comments(until: date).keys.max).to eq date.to_date
495
- end
496
-
497
- specify 'with a given start (:from option)' do
498
- expect(channel.comments(from: date).keys.min).to eq date.to_date
499
- end
500
-
501
- specify 'with a given end (:to option)' do
502
- expect(channel.comments(to: date).keys.max).to eq date.to_date
503
- end
504
- end
505
-
506
- describe 'comments can be grouped by range' do
507
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
508
-
509
- specify 'with the :by option set to :range' do
510
- comments = channel.comments range.merge by: :range
511
- expect(comments.size).to be 1
512
- expect(comments[:total]).to be_an Integer
513
- end
514
- end
515
-
516
432
  describe 'comments can be grouped by day' do
517
433
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
518
434
  let(:keys) { range.values }
519
435
 
520
- specify 'without a :by option (default)' do
521
- comments = channel.comments range
522
- expect(comments.keys).to eq range.values
523
- end
524
-
525
436
  specify 'with the :by option set to :day' do
526
437
  comments = channel.comments range.merge by: :day
527
438
  expect(comments.keys).to eq range.values
@@ -539,18 +450,6 @@ describe Yt::Channel, :partner do
539
450
  end
540
451
  end
541
452
 
542
- describe 'likes can be retrieved for a specific day' do
543
- context 'in which the channel was partnered' do
544
- let(:likes) { channel.likes_on 5.days.ago}
545
- it { expect(likes).to be_an Integer }
546
- end
547
-
548
- context 'in which the channel was not partnered' do
549
- let(:likes) { channel.likes_on 20.years.ago}
550
- it { expect(likes).to be_nil }
551
- end
552
- end
553
-
554
453
  describe 'likes can be retrieved for a single country' do
555
454
  let(:country_code) { 'US' }
556
455
  let(:likes) { channel.likes since: date, by: by, in: location }
@@ -585,45 +484,10 @@ describe Yt::Channel, :partner do
585
484
  end
586
485
  end
587
486
 
588
- describe 'likes can be retrieved for a range of days' do
589
- let(:date) { 4.days.ago }
590
-
591
- specify 'with a given start (:since option)' do
592
- expect(channel.likes(since: date).keys.min).to eq date.to_date
593
- end
594
-
595
- specify 'with a given end (:until option)' do
596
- expect(channel.likes(until: date).keys.max).to eq date.to_date
597
- end
598
-
599
- specify 'with a given start (:from option)' do
600
- expect(channel.likes(from: date).keys.min).to eq date.to_date
601
- end
602
-
603
- specify 'with a given end (:to option)' do
604
- expect(channel.likes(to: date).keys.max).to eq date.to_date
605
- end
606
- end
607
-
608
- describe 'likes can be grouped by range' do
609
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
610
-
611
- specify 'with the :by option set to :range' do
612
- likes = channel.likes range.merge by: :range
613
- expect(likes.size).to be 1
614
- expect(likes[:total]).to be_an Integer
615
- end
616
- end
617
-
618
487
  describe 'likes can be grouped by day' do
619
488
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
620
489
  let(:keys) { range.values }
621
490
 
622
- specify 'without a :by option (default)' do
623
- likes = channel.likes range
624
- expect(likes.keys).to eq range.values
625
- end
626
-
627
491
  specify 'with the :by option set to :day' do
628
492
  likes = channel.likes range.merge by: :day
629
493
  expect(likes.keys).to eq range.values
@@ -641,18 +505,6 @@ describe Yt::Channel, :partner do
641
505
  end
642
506
  end
643
507
 
644
- describe 'dislikes can be retrieved for a specific day' do
645
- context 'in which the channel was partnered' do
646
- let(:dislikes) { channel.dislikes_on 5.days.ago}
647
- it { expect(dislikes).to be_an Integer }
648
- end
649
-
650
- context 'in which the channel was not partnered' do
651
- let(:dislikes) { channel.dislikes_on 20.years.ago}
652
- it { expect(dislikes).to be_nil }
653
- end
654
- end
655
-
656
508
  describe 'dislikes can be retrieved for a single country' do
657
509
  let(:country_code) { 'US' }
658
510
  let(:dislikes) { channel.dislikes since: date, by: by, in: location }
@@ -687,45 +539,10 @@ describe Yt::Channel, :partner do
687
539
  end
688
540
  end
689
541
 
690
- describe 'dislikes can be retrieved for a range of days' do
691
- let(:date) { 4.days.ago }
692
-
693
- specify 'with a given start (:since option)' do
694
- expect(channel.dislikes(since: date).keys.min).to eq date.to_date
695
- end
696
-
697
- specify 'with a given end (:until option)' do
698
- expect(channel.dislikes(until: date).keys.max).to eq date.to_date
699
- end
700
-
701
- specify 'with a given start (:from option)' do
702
- expect(channel.dislikes(from: date).keys.min).to eq date.to_date
703
- end
704
-
705
- specify 'with a given end (:to option)' do
706
- expect(channel.dislikes(to: date).keys.max).to eq date.to_date
707
- end
708
- end
709
-
710
- describe 'dislikes can be grouped by range' do
711
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
712
-
713
- specify 'with the :by option set to :range' do
714
- dislikes = channel.dislikes range.merge by: :range
715
- expect(dislikes.size).to be 1
716
- expect(dislikes[:total]).to be_an Integer
717
- end
718
- end
719
-
720
542
  describe 'dislikes can be grouped by day' do
721
543
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
722
544
  let(:keys) { range.values }
723
545
 
724
- specify 'without a :by option (default)' do
725
- dislikes = channel.dislikes range
726
- expect(dislikes.keys).to eq range.values
727
- end
728
-
729
546
  specify 'with the :by option set to :day' do
730
547
  dislikes = channel.dislikes range.merge by: :day
731
548
  expect(dislikes.keys).to eq range.values
@@ -743,19 +560,6 @@ describe Yt::Channel, :partner do
743
560
  end
744
561
  end
745
562
 
746
- describe 'shares can be retrieved for a specific day' do
747
- context 'in which the channel was partnered' do
748
- let(:date) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 95 }
749
- let(:shares) { channel.shares_on date }
750
- it { expect(shares).to be_an Integer }
751
- end
752
-
753
- context 'in which the channel was not partnered' do
754
- let(:shares) { channel.shares_on 20.years.ago}
755
- it { expect(shares).to be_nil }
756
- end
757
- end
758
-
759
563
  describe 'shares can be retrieved for a single country' do
760
564
  let(:country_code) { 'US' }
761
565
  let(:shares) { channel.shares since: date, by: by, in: location }
@@ -790,45 +594,10 @@ describe Yt::Channel, :partner do
790
594
  end
791
595
  end
792
596
 
793
- describe 'shares can be retrieved for a range of days' do
794
- let(:date) { 4.days.ago }
795
-
796
- specify 'with a given start (:since option)' do
797
- expect(channel.shares(since: date).keys.min).to eq date.to_date
798
- end
799
-
800
- specify 'with a given end (:until option)' do
801
- expect(channel.shares(until: date).keys.max).to eq date.to_date
802
- end
803
-
804
- specify 'with a given start (:from option)' do
805
- expect(channel.shares(from: date).keys.min).to eq date.to_date
806
- end
807
-
808
- specify 'with a given end (:to option)' do
809
- expect(channel.shares(to: date).keys.max).to eq date.to_date
810
- end
811
- end
812
-
813
- describe 'shares can be grouped by range' do
814
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
815
-
816
- specify 'with the :by option set to :range' do
817
- shares = channel.shares range.merge by: :range
818
- expect(shares.size).to be 1
819
- expect(shares[:total]).to be_an Integer
820
- end
821
- end
822
-
823
597
  describe 'shares can be grouped by day' do
824
598
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
825
599
  let(:keys) { range.values }
826
600
 
827
- specify 'without a :by option (default)' do
828
- shares = channel.shares range
829
- expect(shares.keys).to eq range.values
830
- end
831
-
832
601
  specify 'with the :by option set to :day' do
833
602
  shares = channel.shares range.merge by: :day
834
603
  expect(shares.keys).to eq range.values
@@ -846,18 +615,6 @@ describe Yt::Channel, :partner do
846
615
  end
847
616
  end
848
617
 
849
- describe 'gained subscribers can be retrieved for a specific day' do
850
- context 'in which the channel was partnered' do
851
- let(:subscribers_gained) { channel.subscribers_gained_on 5.days.ago}
852
- it { expect(subscribers_gained).to be_an Integer }
853
- end
854
-
855
- context 'in which the channel was not partnered' do
856
- let(:subscribers_gained) { channel.subscribers_gained_on 20.years.ago}
857
- it { expect(subscribers_gained).to be_nil }
858
- end
859
- end
860
-
861
618
  describe 'gained subscribers can be retrieved for a single country' do
862
619
  let(:country_code) { 'US' }
863
620
  let(:subscribers_gained) { channel.subscribers_gained since: date, by: by, in: location }
@@ -892,45 +649,10 @@ describe Yt::Channel, :partner do
892
649
  end
893
650
  end
894
651
 
895
- describe 'gained subscribers can be retrieved for a range of days' do
896
- let(:date) { 4.days.ago }
897
-
898
- specify 'with a given start (:since option)' do
899
- expect(channel.subscribers_gained(since: date).keys.min).to eq date.to_date
900
- end
901
-
902
- specify 'with a given end (:until option)' do
903
- expect(channel.subscribers_gained(until: date).keys.max).to eq date.to_date
904
- end
905
-
906
- specify 'with a given start (:from option)' do
907
- expect(channel.subscribers_gained(from: date).keys.min).to eq date.to_date
908
- end
909
-
910
- specify 'with a given end (:to option)' do
911
- expect(channel.subscribers_gained(to: date).keys.max).to eq date.to_date
912
- end
913
- end
914
-
915
- describe 'gained subscribers can be grouped by range' do
916
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
917
-
918
- specify 'with the :by option set to :range' do
919
- subscribers_gained = channel.subscribers_gained range.merge by: :range
920
- expect(subscribers_gained.size).to be 1
921
- expect(subscribers_gained[:total]).to be_an Integer
922
- end
923
- end
924
-
925
652
  describe 'gained subscribers can be grouped by day' do
926
653
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
927
654
  let(:keys) { range.values }
928
655
 
929
- specify 'without a :by option (default)' do
930
- subscribers_gained = channel.subscribers_gained range
931
- expect(subscribers_gained.keys).to eq range.values
932
- end
933
-
934
656
  specify 'with the :by option set to :day' do
935
657
  subscribers_gained = channel.subscribers_gained range.merge by: :day
936
658
  expect(subscribers_gained.keys).to eq range.values
@@ -948,18 +670,6 @@ describe Yt::Channel, :partner do
948
670
  end
949
671
  end
950
672
 
951
- describe 'lost subscribers can be retrieved for a specific day' do
952
- context 'in which the channel was partnered' do
953
- let(:subscribers_lost) { channel.subscribers_lost_on 5.days.ago}
954
- it { expect(subscribers_lost).to be_an Integer }
955
- end
956
-
957
- context 'in which the channel was not partnered' do
958
- let(:subscribers_lost) { channel.subscribers_lost_on 20.years.ago}
959
- it { expect(subscribers_lost).to be_nil }
960
- end
961
- end
962
-
963
673
  describe 'lost subscribers can be retrieved for a single country' do
964
674
  let(:country_code) { 'US' }
965
675
  let(:subscribers_lost) { channel.subscribers_lost since: date, by: by, in: location }
@@ -994,45 +704,10 @@ describe Yt::Channel, :partner do
994
704
  end
995
705
  end
996
706
 
997
- describe 'lost subscribers can be retrieved for a range of days' do
998
- let(:date) { 4.days.ago }
999
-
1000
- specify 'with a given start (:since option)' do
1001
- expect(channel.subscribers_lost(since: date).keys.min).to eq date.to_date
1002
- end
1003
-
1004
- specify 'with a given end (:until option)' do
1005
- expect(channel.subscribers_lost(until: date).keys.max).to eq date.to_date
1006
- end
1007
-
1008
- specify 'with a given start (:from option)' do
1009
- expect(channel.subscribers_lost(from: date).keys.min).to eq date.to_date
1010
- end
1011
-
1012
- specify 'with a given end (:to option)' do
1013
- expect(channel.subscribers_lost(to: date).keys.max).to eq date.to_date
1014
- end
1015
- end
1016
-
1017
- describe 'lost subscribers can be grouped by range' do
1018
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1019
-
1020
- specify 'with the :by option set to :range' do
1021
- subscribers_lost = channel.subscribers_lost range.merge by: :range
1022
- expect(subscribers_lost.size).to be 1
1023
- expect(subscribers_lost[:total]).to be_an Integer
1024
- end
1025
- end
1026
-
1027
707
  describe 'lost subscribers can be grouped by day' do
1028
708
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1029
709
  let(:keys) { range.values }
1030
710
 
1031
- specify 'without a :by option (default)' do
1032
- subscribers_lost = channel.subscribers_lost range
1033
- expect(subscribers_lost.keys).to eq range.values
1034
- end
1035
-
1036
711
  specify 'with the :by option set to :day' do
1037
712
  subscribers_lost = channel.subscribers_lost range.merge by: :day
1038
713
  expect(subscribers_lost.keys).to eq range.values
@@ -1050,18 +725,6 @@ describe Yt::Channel, :partner do
1050
725
  end
1051
726
  end
1052
727
 
1053
- describe 'added favorites can be retrieved for a specific day' do
1054
- context 'in which the channel was partnered' do
1055
- let(:favorites_added) { channel.favorites_added_on 5.days.ago}
1056
- it { expect(favorites_added).to be_an Integer }
1057
- end
1058
-
1059
- context 'in which the channel was not partnered' do
1060
- let(:favorites_added) { channel.favorites_added_on 20.years.ago}
1061
- it { expect(favorites_added).to be_nil }
1062
- end
1063
- end
1064
-
1065
728
  describe 'favorites added can be retrieved for a single country' do
1066
729
  let(:country_code) { 'US' }
1067
730
  let(:favorites_added) { channel.favorites_added since: date, by: by, in: location }
@@ -1096,45 +759,10 @@ describe Yt::Channel, :partner do
1096
759
  end
1097
760
  end
1098
761
 
1099
- describe 'added favorites can be retrieved for a range of days' do
1100
- let(:date) { 4.days.ago }
1101
-
1102
- specify 'with a given start (:since option)' do
1103
- expect(channel.favorites_added(since: date).keys.min).to eq date.to_date
1104
- end
1105
-
1106
- specify 'with a given end (:until option)' do
1107
- expect(channel.favorites_added(until: date).keys.max).to eq date.to_date
1108
- end
1109
-
1110
- specify 'with a given start (:from option)' do
1111
- expect(channel.favorites_added(from: date).keys.min).to eq date.to_date
1112
- end
1113
-
1114
- specify 'with a given end (:to option)' do
1115
- expect(channel.favorites_added(to: date).keys.max).to eq date.to_date
1116
- end
1117
- end
1118
-
1119
- describe 'added favorites can be grouped by range' do
1120
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1121
-
1122
- specify 'with the :by option set to :range' do
1123
- favorites_added = channel.favorites_added range.merge by: :range
1124
- expect(favorites_added.size).to be 1
1125
- expect(favorites_added[:total]).to be_an Integer
1126
- end
1127
- end
1128
-
1129
762
  describe 'added favorites can be grouped by day' do
1130
763
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1131
764
  let(:keys) { range.values }
1132
765
 
1133
- specify 'without a :by option (default)' do
1134
- favorites_added = channel.favorites_added range
1135
- expect(favorites_added.keys).to eq range.values
1136
- end
1137
-
1138
766
  specify 'with the :by option set to :day' do
1139
767
  favorites_added = channel.favorites_added range.merge by: :day
1140
768
  expect(favorites_added.keys).to eq range.values
@@ -1152,22 +780,10 @@ describe Yt::Channel, :partner do
1152
780
  end
1153
781
  end
1154
782
 
1155
- describe 'removed favorites can be retrieved for a specific day' do
1156
- context 'in which the channel was partnered' do
1157
- let(:favorites_removed) { channel.favorites_removed_on 5.days.ago}
1158
- it { expect(favorites_removed).to be_an Integer }
1159
- end
1160
-
1161
- context 'in which the channel was not partnered' do
1162
- let(:favorites_removed) { channel.favorites_removed_on 20.years.ago}
1163
- it { expect(favorites_removed).to be_nil }
1164
- end
1165
- end
1166
-
1167
783
  describe 'favorites removed can be retrieved for a single country' do
1168
784
  let(:country_code) { 'US' }
1169
785
  let(:favorites_removed) { channel.favorites_removed since: date, by: by, in: location }
1170
- let(:date) { 4.days.ago }
786
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1171
787
 
1172
788
  context 'and grouped by day' do
1173
789
  let(:by) { :day }
@@ -1198,45 +814,10 @@ describe Yt::Channel, :partner do
1198
814
  end
1199
815
  end
1200
816
 
1201
- describe 'removed favorites can be retrieved for a range of days' do
1202
- let(:date) { 4.days.ago }
1203
-
1204
- specify 'with a given start (:since option)' do
1205
- expect(channel.favorites_removed(since: date).keys.min).to eq date.to_date
1206
- end
1207
-
1208
- specify 'with a given end (:until option)' do
1209
- expect(channel.favorites_removed(until: date).keys.max).to eq date.to_date
1210
- end
1211
-
1212
- specify 'with a given start (:from option)' do
1213
- expect(channel.favorites_removed(from: date).keys.min).to eq date.to_date
1214
- end
1215
-
1216
- specify 'with a given end (:to option)' do
1217
- expect(channel.favorites_removed(to: date).keys.max).to eq date.to_date
1218
- end
1219
- end
1220
-
1221
- describe 'removed favorites can be grouped by range' do
1222
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1223
-
1224
- specify 'with the :by option set to :range' do
1225
- favorites_removed = channel.favorites_removed range.merge by: :range
1226
- expect(favorites_removed.size).to be 1
1227
- expect(favorites_removed[:total]).to be_an Integer
1228
- end
1229
- end
1230
-
1231
817
  describe 'removed favorites can be grouped by day' do
1232
818
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1233
819
  let(:keys) { range.values }
1234
820
 
1235
- specify 'without a :by option (default)' do
1236
- favorites_removed = channel.favorites_removed range
1237
- expect(favorites_removed.keys).to eq range.values
1238
- end
1239
-
1240
821
  specify 'with the :by option set to :day' do
1241
822
  favorites_removed = channel.favorites_removed range.merge by: :day
1242
823
  expect(favorites_removed.keys).to eq range.values
@@ -1244,7 +825,7 @@ describe Yt::Channel, :partner do
1244
825
  end
1245
826
 
1246
827
  describe 'removed favorites can be grouped by country' do
1247
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
828
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
1248
829
 
1249
830
  specify 'with the :by option set to :country' do
1250
831
  favorites_removed = channel.favorites_removed range.merge by: :country
@@ -1254,18 +835,6 @@ describe Yt::Channel, :partner do
1254
835
  end
1255
836
  end
1256
837
 
1257
- describe 'estimated minutes watched can be retrieved for a specific day' do
1258
- context 'in which the channel was partnered' do
1259
- let(:estimated_minutes_watched) { channel.estimated_minutes_watched_on 5.days.ago}
1260
- it { expect(estimated_minutes_watched).to be_a Float }
1261
- end
1262
-
1263
- context 'in which the channel was not partnered' do
1264
- let(:estimated_minutes_watched) { channel.estimated_minutes_watched_on 20.years.ago}
1265
- it { expect(estimated_minutes_watched).to be_nil }
1266
- end
1267
- end
1268
-
1269
838
  describe 'estimated minutes watched can be retrieved for a single country' do
1270
839
  let(:country_code) { 'US' }
1271
840
  let(:estimated_minutes_watched) { channel.estimated_minutes_watched since: date, by: by, in: location }
@@ -1334,45 +903,10 @@ describe Yt::Channel, :partner do
1334
903
  end
1335
904
  end
1336
905
 
1337
- describe 'estimated minutes watched can be retrieved for a range of days' do
1338
- let(:date) { 4.days.ago }
1339
-
1340
- specify 'with a given start (:since option)' do
1341
- expect(channel.estimated_minutes_watched(since: date).keys.min).to eq date.to_date
1342
- end
1343
-
1344
- specify 'with a given end (:until option)' do
1345
- expect(channel.estimated_minutes_watched(until: date).keys.max).to eq date.to_date
1346
- end
1347
-
1348
- specify 'with a given start (:from option)' do
1349
- expect(channel.estimated_minutes_watched(from: date).keys.min).to eq date.to_date
1350
- end
1351
-
1352
- specify 'with a given end (:to option)' do
1353
- expect(channel.estimated_minutes_watched(to: date).keys.max).to eq date.to_date
1354
- end
1355
- end
1356
-
1357
- describe 'estimated minutes watched can be grouped by range' do
1358
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1359
-
1360
- specify 'with the :by option set to :range' do
1361
- minutes = channel.estimated_minutes_watched range.merge by: :range
1362
- expect(minutes.size).to be 1
1363
- expect(minutes[:total]).to be_a Float
1364
- end
1365
- end
1366
-
1367
906
  describe 'estimated minutes watched can be grouped by day' do
1368
907
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1369
908
  let(:keys) { range.values }
1370
909
 
1371
- specify 'without a :by option (default)' do
1372
- estimated_minutes_watched = channel.estimated_minutes_watched range
1373
- expect(estimated_minutes_watched.keys).to eq range.values
1374
- end
1375
-
1376
910
  specify 'with the :by option set to :day' do
1377
911
  estimated_minutes_watched = channel.estimated_minutes_watched range.merge by: :day
1378
912
  expect(estimated_minutes_watched.keys).to eq range.values
@@ -1476,18 +1010,6 @@ describe Yt::Channel, :partner do
1476
1010
  end
1477
1011
  end
1478
1012
 
1479
- describe 'average view duration can be retrieved for a specific day' do
1480
- context 'in which the channel was partnered' do
1481
- let(:average_view_duration) { channel.average_view_duration_on 5.days.ago}
1482
- it { expect(average_view_duration).to be_a Float }
1483
- end
1484
-
1485
- context 'in which the channel was not partnered' do
1486
- let(:average_view_duration) { channel.average_view_duration_on 20.years.ago}
1487
- it { expect(average_view_duration).to be_nil }
1488
- end
1489
- end
1490
-
1491
1013
  describe 'average view duration can be retrieved for a single country' do
1492
1014
  let(:country_code) { 'US' }
1493
1015
  let(:average_view_duration) { channel.average_view_duration since: date, by: by, in: location }
@@ -1556,45 +1078,10 @@ describe Yt::Channel, :partner do
1556
1078
  end
1557
1079
  end
1558
1080
 
1559
- describe 'average view duration can be retrieved for a range of days' do
1560
- let(:date) { 4.days.ago }
1561
-
1562
- specify 'with a given start (:since option)' do
1563
- expect(channel.average_view_duration(since: date).keys.min).to eq date.to_date
1564
- end
1565
-
1566
- specify 'with a given end (:until option)' do
1567
- expect(channel.average_view_duration(until: date).keys.max).to eq date.to_date
1568
- end
1569
-
1570
- specify 'with a given start (:from option)' do
1571
- expect(channel.average_view_duration(from: date).keys.min).to eq date.to_date
1572
- end
1573
-
1574
- specify 'with a given end (:to option)' do
1575
- expect(channel.average_view_duration(to: date).keys.max).to eq date.to_date
1576
- end
1577
- end
1578
-
1579
- describe 'average view duration can be grouped by range' do
1580
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1581
-
1582
- specify 'with the :by option set to :range' do
1583
- duration = channel.average_view_duration range.merge by: :range
1584
- expect(duration.size).to be 1
1585
- expect(duration[:total]).to be_a Float
1586
- end
1587
- end
1588
-
1589
1081
  describe 'average view duration can be grouped by day' do
1590
1082
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1591
1083
  let(:keys) { range.values }
1592
1084
 
1593
- specify 'without a :by option (default)' do
1594
- average_view_duration = channel.average_view_duration range
1595
- expect(average_view_duration.keys).to eq range.values
1596
- end
1597
-
1598
1085
  specify 'with the :by option set to :day' do
1599
1086
  average_view_duration = channel.average_view_duration range.merge by: :day
1600
1087
  expect(average_view_duration.keys).to eq range.values
@@ -1623,18 +1110,6 @@ describe Yt::Channel, :partner do
1623
1110
  end
1624
1111
  end
1625
1112
 
1626
- describe 'average view percentage can be retrieved for a specific day' do
1627
- context 'in which the channel was partnered' do
1628
- let(:average_view_percentage) { channel.average_view_percentage_on 5.days.ago}
1629
- it { expect(average_view_percentage).to be_a Float }
1630
- end
1631
-
1632
- context 'in which the channel was not partnered' do
1633
- let(:average_view_percentage) { channel.average_view_percentage_on 20.years.ago}
1634
- it { expect(average_view_percentage).to be_nil }
1635
- end
1636
- end
1637
-
1638
1113
  describe 'average view percentage can be retrieved for a single country' do
1639
1114
  let(:country_code) { 'US' }
1640
1115
  let(:average_view_percentage) { channel.average_view_percentage since: date, by: by, in: location }
@@ -1703,45 +1178,10 @@ describe Yt::Channel, :partner do
1703
1178
  end
1704
1179
  end
1705
1180
 
1706
- describe 'average view percentage can be retrieved for a range of days' do
1707
- let(:date) { 4.days.ago }
1708
-
1709
- specify 'with a given start (:since option)' do
1710
- expect(channel.average_view_percentage(since: date).keys.min).to eq date.to_date
1711
- end
1712
-
1713
- specify 'with a given end (:until option)' do
1714
- expect(channel.average_view_percentage(until: date).keys.max).to eq date.to_date
1715
- end
1716
-
1717
- specify 'with a given start (:from option)' do
1718
- expect(channel.average_view_percentage(from: date).keys.min).to eq date.to_date
1719
- end
1720
-
1721
- specify 'with a given end (:to option)' do
1722
- expect(channel.average_view_percentage(to: date).keys.max).to eq date.to_date
1723
- end
1724
- end
1725
-
1726
- describe 'average view percentage can be grouped by range' do
1727
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1728
-
1729
- specify 'with the :by option set to :range' do
1730
- percentage = channel.average_view_percentage range.merge by: :range
1731
- expect(percentage.size).to be 1
1732
- expect(percentage[:total]).to be_a Float
1733
- end
1734
- end
1735
-
1736
1181
  describe 'average view percentage can be grouped by day' do
1737
1182
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1738
1183
  let(:keys) { range.values }
1739
1184
 
1740
- specify 'without a :by option (default)' do
1741
- average_view_percentage = channel.average_view_percentage range
1742
- expect(average_view_percentage.keys).to eq range.values
1743
- end
1744
-
1745
1185
  specify 'with the :by option set to :day' do
1746
1186
  average_view_percentage = channel.average_view_percentage range.merge by: :day
1747
1187
  expect(average_view_percentage.keys).to eq range.values
@@ -1770,18 +1210,6 @@ describe Yt::Channel, :partner do
1770
1210
  end
1771
1211
  end
1772
1212
 
1773
- describe 'impressions can be retrieved for a specific day' do
1774
- context 'in which the channel was partnered' do
1775
- let(:impressions) { channel.impressions_on 20.days.ago}
1776
- it { expect(impressions).to be_an Integer }
1777
- end
1778
-
1779
- context 'in which the channel was not partnered' do
1780
- let(:impressions) { channel.impressions_on 20.years.ago}
1781
- it { expect(impressions).to be_nil }
1782
- end
1783
- end
1784
-
1785
1213
  describe 'impressions can be retrieved for a single country' do
1786
1214
  let(:country_code) { 'US' }
1787
1215
  let(:impressions) { channel.impressions since: date, by: by, in: location }
@@ -1816,45 +1244,10 @@ describe Yt::Channel, :partner do
1816
1244
  end
1817
1245
  end
1818
1246
 
1819
- describe 'impressions can be retrieved for a range of days' do
1820
- let(:date) { 4.days.ago }
1821
-
1822
- specify 'with a given start (:since option)' do
1823
- expect(channel.impressions(since: date).keys.min).to eq date.to_date
1824
- end
1825
-
1826
- specify 'with a given end (:until option)' do
1827
- expect(channel.impressions(until: date).keys.max).to eq date.to_date
1828
- end
1829
-
1830
- specify 'with a given start (:from option)' do
1831
- expect(channel.impressions(from: date).keys.min).to eq date.to_date
1832
- end
1833
-
1834
- specify 'with a given end (:to option)' do
1835
- expect(channel.impressions(to: date).keys.max).to eq date.to_date
1836
- end
1837
- end
1838
-
1839
- describe 'impressions can be grouped by range' do
1840
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1841
-
1842
- specify 'with the :by option set to :range' do
1843
- impressions = channel.impressions range.merge by: :range
1844
- expect(impressions.size).to be 1
1845
- expect(impressions[:total]).to be_an Integer
1846
- end
1847
- end
1848
-
1849
1247
  describe 'impressions can be grouped by day' do
1850
1248
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1851
1249
  let(:keys) { range.values }
1852
1250
 
1853
- specify 'without a :by option (default)' do
1854
- impressions = channel.impressions range
1855
- expect(impressions.keys).to eq range.values
1856
- end
1857
-
1858
1251
  specify 'with the :by option set to :day' do
1859
1252
  impressions = channel.impressions range.merge by: :day
1860
1253
  expect(impressions.keys).to eq range.values
@@ -1872,18 +1265,6 @@ describe Yt::Channel, :partner do
1872
1265
  end
1873
1266
  end
1874
1267
 
1875
- describe 'monetized playbacks can be retrieved for a specific day' do
1876
- context 'in which the channel was partnered' do
1877
- let(:monetized_playbacks) { channel.monetized_playbacks_on 20.days.ago}
1878
- it { expect(monetized_playbacks).to be_an Integer }
1879
- end
1880
-
1881
- context 'in which the channel was not partnered' do
1882
- let(:monetized_playbacks) { channel.monetized_playbacks_on 20.years.ago}
1883
- it { expect(monetized_playbacks).to be_nil }
1884
- end
1885
- end
1886
-
1887
1268
  describe 'monetized playbacks can be retrieved for a single country' do
1888
1269
  let(:country_code) { 'US' }
1889
1270
  let(:monetized_playbacks) { channel.monetized_playbacks since: date, by: by, in: location }
@@ -1918,45 +1299,10 @@ describe Yt::Channel, :partner do
1918
1299
  end
1919
1300
  end
1920
1301
 
1921
- describe 'monetized playbacks can be retrieved for a range of days' do
1922
- let(:date) { 4.days.ago }
1923
-
1924
- specify 'with a given start (:since option)' do
1925
- expect(channel.monetized_playbacks(since: date).keys.min).to eq date.to_date
1926
- end
1927
-
1928
- specify 'with a given end (:until option)' do
1929
- expect(channel.monetized_playbacks(until: date).keys.max).to eq date.to_date
1930
- end
1931
-
1932
- specify 'with a given start (:from option)' do
1933
- expect(channel.monetized_playbacks(from: date).keys.min).to eq date.to_date
1934
- end
1935
-
1936
- specify 'with a given end (:to option)' do
1937
- expect(channel.monetized_playbacks(to: date).keys.max).to eq date.to_date
1938
- end
1939
- end
1940
-
1941
- describe 'monetized playbacks can be grouped by range' do
1942
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1943
-
1944
- specify 'with the :by option set to :range' do
1945
- monetized_playbacks = channel.monetized_playbacks range.merge by: :range
1946
- expect(monetized_playbacks.size).to be 1
1947
- expect(monetized_playbacks[:total]).to be_an Integer
1948
- end
1949
- end
1950
-
1951
1302
  describe 'monetized_playbacks can be grouped by day' do
1952
1303
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1953
1304
  let(:keys) { range.values }
1954
1305
 
1955
- specify 'without a :by option (default)' do
1956
- monetized_playbacks = channel.monetized_playbacks range
1957
- expect(monetized_playbacks.keys).to eq range.values
1958
- end
1959
-
1960
1306
  specify 'with the :by option set to :day' do
1961
1307
  monetized_playbacks = channel.monetized_playbacks range.merge by: :day
1962
1308
  expect(monetized_playbacks.keys).to eq range.values
@@ -2011,7 +1357,7 @@ describe Yt::Channel, :partner do
2011
1357
  describe 'annotation clicks can be retrieved for a single US state' do
2012
1358
  let(:state_code) { 'NY' }
2013
1359
  let(:result) { channel.annotation_clicks since: date, by: by, in: location }
2014
- let(:date) { 4.days.ago }
1360
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2015
1361
 
2016
1362
  context 'and grouped by day' do
2017
1363
  let(:by) { :day }
@@ -2042,37 +1388,9 @@ describe Yt::Channel, :partner do
2042
1388
  end
2043
1389
  end
2044
1390
 
2045
- describe 'annotation clicks can be retrieved for a range of days' do
2046
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2047
- let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
2048
-
2049
- specify 'with a given start (:since option) and a given end (:until option)' do
2050
- expect(channel.annotation_clicks(since: date, until: date_to).keys.min).to eq date.to_date
2051
- end
2052
-
2053
- specify 'with a given start (:from option) and a given end (:to option)' do
2054
- expect(channel.annotation_clicks(from: date, to: date_to).keys.min).to eq date.to_date
2055
- end
2056
- end
2057
-
2058
- describe 'annotation clicks can be grouped by range' do
2059
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
2060
-
2061
- specify 'with the :by option set to :range' do
2062
- annotation_clicks = channel.annotation_clicks range.merge by: :range
2063
- expect(annotation_clicks.size).to be 1
2064
- expect(annotation_clicks[:total]).to be_an Integer
2065
- end
2066
- end
2067
-
2068
1391
  describe 'annotation clicks can be grouped by day' do
2069
1392
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
2070
1393
 
2071
- specify 'without a :by option (default)' do
2072
- annotation_clicks = channel.annotation_clicks range
2073
- expect(annotation_clicks.values).to all(be_an Integer)
2074
- end
2075
-
2076
1394
  specify 'with the :by option set to :day' do
2077
1395
  annotation_clicks = channel.annotation_clicks range.merge by: :day
2078
1396
  expect(annotation_clicks.values).to all(be_an Integer)
@@ -2138,7 +1456,7 @@ describe Yt::Channel, :partner do
2138
1456
  describe 'annotation click-through rate can be retrieved for a single US state' do
2139
1457
  let(:state_code) { 'NY' }
2140
1458
  let(:result) { channel.annotation_click_through_rate since: date, by: by, in: location }
2141
- let(:date) { 4.days.ago }
1459
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2142
1460
 
2143
1461
  context 'and grouped by day' do
2144
1462
  let(:by) { :day }
@@ -2169,37 +1487,9 @@ describe Yt::Channel, :partner do
2169
1487
  end
2170
1488
  end
2171
1489
 
2172
- describe 'annotation click-through rate can be retrieved for a range of days' do
2173
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2174
- let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
2175
-
2176
- specify 'with a given start (:since option) and a given end (:until option)' do
2177
- expect(channel.annotation_click_through_rate(since: date, until: date_to).keys.min).to eq date.to_date
2178
- end
2179
-
2180
- specify 'with a given start (:from option) and a given end (:to option)' do
2181
- expect(channel.annotation_click_through_rate(from: date, to: date_to).keys.min).to eq date.to_date
2182
- end
2183
- end
2184
-
2185
- describe 'annotation click-through rate can be grouped by range' do
2186
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
2187
-
2188
- specify 'with the :by option set to :range' do
2189
- rate = channel.annotation_click_through_rate range.merge by: :range
2190
- expect(rate.size).to be 1
2191
- expect(rate[:total]).to be_a Float
2192
- end
2193
- end
2194
-
2195
1490
  describe 'annotation click-through rate can be grouped by day' do
2196
1491
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
2197
1492
 
2198
- specify 'without a :by option (default)' do
2199
- annotation_click_through_rate = channel.annotation_click_through_rate range
2200
- expect(annotation_click_through_rate.values).to all(be_instance_of Float)
2201
- end
2202
-
2203
1493
  specify 'with the :by option set to :day' do
2204
1494
  annotation_click_through_rate = channel.annotation_click_through_rate range.merge by: :day
2205
1495
  expect(annotation_click_through_rate.values).to all(be_instance_of Float)
@@ -2296,37 +1586,9 @@ describe Yt::Channel, :partner do
2296
1586
  end
2297
1587
  end
2298
1588
 
2299
- describe 'annotation close rate can be retrieved for a range of days' do
2300
- let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2301
- let(:date_to) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
2302
-
2303
- specify 'with a given start (:since option) and a given end (:until option)' do
2304
- expect(channel.annotation_close_rate(since: date, until: date_to).keys.min).to eq date.to_date
2305
- end
2306
-
2307
- specify 'with a given start (:from option) and a given end (:to option)' do
2308
- expect(channel.annotation_close_rate(from: date, to: date_to).keys.min).to eq date.to_date
2309
- end
2310
- end
2311
-
2312
- describe 'annotation close rate can be grouped by range' do
2313
- let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
2314
-
2315
- specify 'with the :by option set to :range' do
2316
- rate = channel.annotation_close_rate range.merge by: :range
2317
- expect(rate.size).to be 1
2318
- expect(rate[:total]).to be_a Float
2319
- end
2320
- end
2321
-
2322
1589
  describe 'annotation close rate can be grouped by day' do
2323
1590
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
2324
1591
 
2325
- specify 'without a :by option (default)' do
2326
- annotation_close_rate = channel.annotation_close_rate range
2327
- expect(annotation_close_rate.values).to all(be_instance_of Float)
2328
- end
2329
-
2330
1592
  specify 'with the :by option set to :day' do
2331
1593
  annotation_close_rate = channel.annotation_close_rate range.merge by: :day
2332
1594
  expect(annotation_close_rate.values).to all(be_instance_of Float)