yt 0.32.5 → 0.33.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -4
  3. data/CHANGELOG.md +44 -0
  4. data/README.md +22 -33
  5. data/YOUTUBE_IT.md +4 -4
  6. data/lib/yt/actions/list.rb +1 -1
  7. data/lib/yt/associations/has_reports.rb +9 -14
  8. data/lib/yt/collections/playlist_items.rb +10 -1
  9. data/lib/yt/collections/reports.rb +5 -7
  10. data/lib/yt/models/account.rb +33 -3
  11. data/lib/yt/models/channel.rb +21 -5
  12. data/lib/yt/models/content_owner.rb +20 -0
  13. data/lib/yt/models/playlist.rb +12 -2
  14. data/lib/yt/models/playlist_item.rb +8 -1
  15. data/lib/yt/models/resource.rb +74 -3
  16. data/lib/yt/models/statistics_set.rb +2 -1
  17. data/lib/yt/models/status.rb +3 -1
  18. data/lib/yt/models/url.rb +2 -60
  19. data/lib/yt/models/video.rb +31 -3
  20. data/lib/yt/request.rb +7 -4
  21. data/lib/yt/version.rb +1 -1
  22. data/lib/yt.rb +1 -1
  23. data/yt.gemspec +5 -2
  24. metadata +32 -171
  25. data/spec/collections/claims_spec.rb +0 -62
  26. data/spec/collections/comment_threads_spec.rb +0 -46
  27. data/spec/collections/playlist_items_spec.rb +0 -44
  28. data/spec/collections/playlists_spec.rb +0 -27
  29. data/spec/collections/policies_spec.rb +0 -30
  30. data/spec/collections/references_spec.rb +0 -30
  31. data/spec/collections/reports_spec.rb +0 -30
  32. data/spec/collections/subscriptions_spec.rb +0 -25
  33. data/spec/collections/videos_spec.rb +0 -43
  34. data/spec/constants/geography_spec.rb +0 -16
  35. data/spec/errors/forbidden_spec.rb +0 -10
  36. data/spec/errors/missing_auth_spec.rb +0 -24
  37. data/spec/errors/no_items_spec.rb +0 -10
  38. data/spec/errors/request_error_spec.rb +0 -44
  39. data/spec/errors/server_error_spec.rb +0 -10
  40. data/spec/errors/unauthorized_spec.rb +0 -10
  41. data/spec/models/account_spec.rb +0 -138
  42. data/spec/models/annotation_spec.rb +0 -180
  43. data/spec/models/asset_spec.rb +0 -32
  44. data/spec/models/channel_spec.rb +0 -127
  45. data/spec/models/claim_event_spec.rb +0 -62
  46. data/spec/models/claim_history_spec.rb +0 -27
  47. data/spec/models/claim_spec.rb +0 -223
  48. data/spec/models/comment_spec.rb +0 -40
  49. data/spec/models/comment_thread_spec.rb +0 -93
  50. data/spec/models/configuration_spec.rb +0 -44
  51. data/spec/models/content_detail_spec.rb +0 -52
  52. data/spec/models/content_owner_detail_spec.rb +0 -6
  53. data/spec/models/file_detail_spec.rb +0 -13
  54. data/spec/models/live_streaming_detail_spec.rb +0 -6
  55. data/spec/models/ownership_spec.rb +0 -59
  56. data/spec/models/player_spec.rb +0 -13
  57. data/spec/models/playlist_item_spec.rb +0 -120
  58. data/spec/models/playlist_spec.rb +0 -138
  59. data/spec/models/policy_rule_spec.rb +0 -63
  60. data/spec/models/policy_spec.rb +0 -41
  61. data/spec/models/rating_spec.rb +0 -12
  62. data/spec/models/reference_spec.rb +0 -249
  63. data/spec/models/request_spec.rb +0 -204
  64. data/spec/models/resource_spec.rb +0 -42
  65. data/spec/models/right_owner_spec.rb +0 -71
  66. data/spec/models/snippet_spec.rb +0 -13
  67. data/spec/models/statistics_set_spec.rb +0 -13
  68. data/spec/models/status_spec.rb +0 -13
  69. data/spec/models/subscription_spec.rb +0 -30
  70. data/spec/models/url_spec.rb +0 -78
  71. data/spec/models/video_category_spec.rb +0 -21
  72. data/spec/models/video_spec.rb +0 -669
  73. data/spec/requests/as_account/account_spec.rb +0 -143
  74. data/spec/requests/as_account/authentications_spec.rb +0 -127
  75. data/spec/requests/as_account/channel_spec.rb +0 -246
  76. data/spec/requests/as_account/channels_spec.rb +0 -18
  77. data/spec/requests/as_account/playlist_item_spec.rb +0 -55
  78. data/spec/requests/as_account/playlist_spec.rb +0 -218
  79. data/spec/requests/as_account/thumbnail.jpg +0 -0
  80. data/spec/requests/as_account/video.mp4 +0 -0
  81. data/spec/requests/as_account/video_spec.rb +0 -408
  82. data/spec/requests/as_content_owner/account_spec.rb +0 -29
  83. data/spec/requests/as_content_owner/advertising_options_set_spec.rb +0 -15
  84. data/spec/requests/as_content_owner/asset_spec.rb +0 -31
  85. data/spec/requests/as_content_owner/bulk_report_job_spec.rb +0 -19
  86. data/spec/requests/as_content_owner/channel_spec.rb +0 -1836
  87. data/spec/requests/as_content_owner/claim_history_spec.rb +0 -20
  88. data/spec/requests/as_content_owner/claim_spec.rb +0 -17
  89. data/spec/requests/as_content_owner/content_owner_spec.rb +0 -370
  90. data/spec/requests/as_content_owner/match_policy_spec.rb +0 -17
  91. data/spec/requests/as_content_owner/ownership_spec.rb +0 -25
  92. data/spec/requests/as_content_owner/playlist_spec.rb +0 -767
  93. data/spec/requests/as_content_owner/video_group_spec.rb +0 -112
  94. data/spec/requests/as_content_owner/video_spec.rb +0 -1211
  95. data/spec/requests/as_server_app/channel_spec.rb +0 -54
  96. data/spec/requests/as_server_app/comment_spec.rb +0 -22
  97. data/spec/requests/as_server_app/comment_thread_spec.rb +0 -27
  98. data/spec/requests/as_server_app/comment_threads_spec.rb +0 -41
  99. data/spec/requests/as_server_app/playlist_item_spec.rb +0 -30
  100. data/spec/requests/as_server_app/playlist_spec.rb +0 -33
  101. data/spec/requests/as_server_app/url_spec.rb +0 -94
  102. data/spec/requests/as_server_app/video_spec.rb +0 -60
  103. data/spec/requests/as_server_app/videos_spec.rb +0 -40
  104. data/spec/requests/unauthenticated/video_spec.rb +0 -14
  105. data/spec/spec_helper.rb +0 -20
  106. data/spec/support/fail_matcher.rb +0 -15
  107. data/spec/support/global_hooks.rb +0 -48
@@ -1,127 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/channel'
3
-
4
- describe Yt::Channel do
5
- subject(:channel) { Yt::Channel.new attrs }
6
-
7
- describe '#title' do
8
- context 'given a snippet with a title' do
9
- let(:attrs) { {snippet: {"title"=>"Fullscreen"}} }
10
- it { expect(channel.title).to eq 'Fullscreen' }
11
- end
12
-
13
- context 'given a snippet without a title' do
14
- let(:attrs) { {snippet: {}} }
15
- it { expect(channel.title).to eq '' }
16
- end
17
- end
18
-
19
- describe '#description' do
20
- context 'given a snippet with a description' do
21
- let(:attrs) { {snippet: {"description"=>"A cool channel."}} }
22
- it { expect(channel.description).to eq 'A cool channel.' }
23
- end
24
-
25
- context 'given a snippet without a description' do
26
- let(:attrs) { {snippet: {}} }
27
- it { expect(channel.description).to eq '' }
28
- end
29
- end
30
-
31
- describe '#thumbnail_url' do
32
- context 'given a snippet with thumbnails' do
33
- let(:attrs) { {snippet: {"thumbnails"=>{
34
- "default"=>{"url"=> "http://example.com/88x88.jpg"},
35
- "medium"=>{"url"=> "http://example.com/240x240.jpg"},
36
- }}} }
37
- it { expect(channel.thumbnail_url).to eq 'http://example.com/88x88.jpg' }
38
- it { expect(channel.thumbnail_url 'default').to eq 'http://example.com/88x88.jpg' }
39
- it { expect(channel.thumbnail_url :default).to eq 'http://example.com/88x88.jpg' }
40
- it { expect(channel.thumbnail_url :medium).to eq 'http://example.com/240x240.jpg' }
41
- it { expect(channel.thumbnail_url :high).to be_nil }
42
- end
43
-
44
- context 'given a snippet without thumbnails' do
45
- let(:attrs) { {snippet: {}} }
46
- it { expect(channel.thumbnail_url).to be_nil }
47
- end
48
- end
49
-
50
- describe '#published_at' do
51
- context 'given a snippet with a timestamp' do
52
- let(:attrs) { {snippet: {"publishedAt"=>"2014-04-22T19:14:49.000Z"}} }
53
- it { expect(channel.published_at.year).to be 2014 }
54
- end
55
- end
56
-
57
- describe '#comment_count' do
58
- context 'given a video with comments' do
59
- let(:attrs) { {statistics: {"commentCount"=>"33"}} }
60
- it { expect(channel.comment_count).to be 33 }
61
- end
62
- end
63
-
64
- describe '#video_count' do
65
- context 'given a video with videos' do
66
- let(:attrs) { {statistics: {"videoCount"=>"42"}} }
67
- it { expect(channel.video_count).to be 42 }
68
- end
69
- end
70
-
71
- describe '#subscriber_count' do
72
- context 'given a video with subscribers' do
73
- let(:attrs) { {statistics: {"subscriberCount"=>"12"}} }
74
- it { expect(channel.subscriber_count).to be 12 }
75
- end
76
- end
77
-
78
- describe '#subscriber_count_visible?' do
79
- context 'given a video with publicly visible subscribers' do
80
- let(:attrs) { {statistics: {"hiddenSubscriberCount"=>false}} }
81
- it { expect(channel).to be_subscriber_count_visible }
82
- end
83
-
84
- context 'given a video with hidden subscribers' do
85
- let(:attrs) { {statistics: {"hiddenSubscriberCount"=>true}} }
86
- it { expect(channel).not_to be_subscriber_count_visible }
87
- end
88
- end
89
-
90
- describe '#content_owner' do
91
- context 'given a content_owner_detail with a content owner' do
92
- let(:attrs) { {content_owner_details: {"contentOwner"=>"FullScreen"}} }
93
- it { expect(channel.content_owner).to eq 'FullScreen' }
94
- end
95
-
96
- context 'given a content_owner_detail without a content owner' do
97
- let(:attrs) { {content_owner_details: {}} }
98
- it { expect(channel.content_owner).to be_nil }
99
- end
100
- end
101
-
102
- describe '#linked_at' do
103
- context 'given a content_owner_detail with a timeLinked' do
104
- let(:attrs) { {content_owner_details: {"timeLinked"=>"2014-04-22T19:14:49.000Z"}} }
105
- it { expect(channel.linked_at.year).to be 2014 }
106
- end
107
-
108
- context 'given a content_owner_detail with a timeLinked' do
109
- let(:attrs) { {content_owner_details: {}} }
110
- it { expect(channel.linked_at).to be_nil }
111
- end
112
- end
113
-
114
- describe '#snippet' do
115
- context 'given fetching a channel returns a snippet' do
116
- let(:attrs) { {snippet: {"title"=>"Fullscreen"}} }
117
- it { expect(channel.snippet).to be_a Yt::Snippet }
118
- end
119
- end
120
-
121
- describe '#status' do
122
- context 'given fetching a channel returns a status' do
123
- let(:attrs) { {status: {"privacyStatus"=>"public"}} }
124
- it { expect(channel.status).to be_a Yt::Status }
125
- end
126
- end
127
- end
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/claim_event'
3
-
4
- describe Yt::ClaimEvent do
5
- subject(:claim_event) { Yt::ClaimEvent.new data: data }
6
-
7
- describe '#time' do
8
- context 'given fetching a claim_event returns a time' do
9
- let(:data) { {"time"=>"2015-04-08T21:52:13.000Z"} }
10
- it { expect(claim_event.time).to be_a Time }
11
- end
12
- end
13
-
14
- describe '#type' do
15
- context 'given fetching a claim_event returns a type' do
16
- let(:data) { {"type"=>"claim_create"} }
17
- it { expect(claim_event.type).to eq 'claim_create' }
18
- end
19
- end
20
-
21
- describe '#source_type' do
22
- context 'given fetching a claim_event returns a source_type' do
23
- let(:data) { {'source'=>{'type' => 'cms_user'}} }
24
- it { expect(claim_event.source_type).to eq 'cms_user' }
25
- end
26
- end
27
-
28
- describe '#source_content_owner_id' do
29
- context 'given fetching a claim_event returns a source_content_owner_id' do
30
- let(:data) { {'source'=>{'contentOwnerId' => 'C1234'}} }
31
- it { expect(claim_event.source_content_owner_id).to eq 'C1234' }
32
- end
33
- end
34
-
35
- describe '#source_user_email' do
36
- context 'given fetching a claim_event returns a source_user_email' do
37
- let(:data) { {'source'=>{'userEmail' => 'email@fullscreen.net'}} }
38
- it { expect(claim_event.source_user_email).to eq 'email@fullscreen.net' }
39
- end
40
- end
41
-
42
- describe '#dispute_reason' do
43
- context 'given fetching a claim_event returns a dispute_reason' do
44
- let(:data) { {'typeDetails'=>{'disputeReason' => 'fair_use'}} }
45
- it { expect(claim_event.dispute_reason).to eq 'fair_use' }
46
- end
47
- end
48
-
49
- describe '#dispute_notes' do
50
- context 'given fetching a claim_event returns dispute_notes' do
51
- let(:data) { {'typeDetails'=>{'disputeNotes' => 'User entered notes here.'}} }
52
- it { expect(claim_event.dispute_notes).to eq 'User entered notes here.' }
53
- end
54
- end
55
-
56
- describe '#update_status' do
57
- context 'given fetching a claim_event returns an update_status' do
58
- let(:data) { {'typeDetails'=>{'updateStatus' => 'active'}} }
59
- it { expect(claim_event.update_status).to eq 'active' }
60
- end
61
- end
62
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/claim_history'
3
-
4
- describe Yt::ClaimHistory do
5
- subject(:claim_history) { Yt::ClaimHistory.new data: data }
6
-
7
- describe '#id' do
8
- context 'given fetching claim_history with an id' do
9
- let(:data) { {"id"=>"acbd1234"}}
10
- it { expect(claim_history.id).to eq "acbd1234" }
11
- end
12
- end
13
-
14
- describe '#uploader_channel_id' do
15
- context 'given fetching claim_history with an uploader_channel_id' do
16
- let(:data) { {"uploaderChannelId"=>"C1234"}}
17
- it { expect(claim_history.uploader_channel_id).to eq "C1234" }
18
- end
19
- end
20
-
21
- describe '#events' do
22
- context 'given fetching claim_history with associated events' do
23
- let(:data) { {"event"=>[{"time"=>"2015-03-21T21:35:42.000Z"},{"time"=>"2015-03-21T21:35:42.000Z"}]} }
24
- it { expect(claim_history.events.size).to eq 2 }
25
- end
26
- end
27
- end
@@ -1,223 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/claim'
3
-
4
- describe Yt::Claim do
5
- subject(:claim) { Yt::Claim.new data: data }
6
-
7
- describe '#id' do
8
- context 'given fetching a claim returns an id' do
9
- let(:data) { {"id"=>"aBcD1EfGHIk"} }
10
- it { expect(claim.id).to eq 'aBcD1EfGHIk' }
11
- end
12
- end
13
-
14
- describe '#asset_id' do
15
- context 'given fetching a claim returns an assetId' do
16
- let(:data) { {"assetId"=>"A123456789012601"} }
17
- it { expect(claim.asset_id).to eq 'A123456789012601' }
18
- end
19
- end
20
-
21
- describe '#video_id' do
22
- context 'given fetching a claim returns an videoId' do
23
- let(:data) { {"videoId"=>"9bZkp7q19f0"} }
24
- it { expect(claim.video_id).to eq '9bZkp7q19f0' }
25
- end
26
- end
27
-
28
- describe '#status' do
29
- context 'given fetching a claim returns a status' do
30
- let(:data) { {"status"=>"active"} }
31
- it { expect(claim.status).to eq 'active' }
32
- end
33
- end
34
-
35
- describe '#active?' do
36
- context 'given fetching a claim returns an active status' do
37
- let(:data) { {"status"=>"active"} }
38
- it { expect(claim).to be_active }
39
- end
40
-
41
- context 'given fetching a claim does not return an active status' do
42
- let(:data) { {"status"=>"unknown"} }
43
- it { expect(claim).not_to be_active }
44
- end
45
- end
46
-
47
- describe '#appealed?' do
48
- context 'given fetching a claim returns an appealed status' do
49
- let(:data) { {"status"=>"appealed"} }
50
- it { expect(claim).to be_appealed }
51
- end
52
-
53
- context 'given fetching a claim does not return an appealed status' do
54
- let(:data) { {"status"=>"unknown"} }
55
- it { expect(claim).not_to be_appealed }
56
- end
57
- end
58
-
59
- describe '#disputed?' do
60
- context 'given fetching a claim returns an disputed status' do
61
- let(:data) { {"status"=>"disputed"} }
62
- it { expect(claim).to be_disputed }
63
- end
64
-
65
- context 'given fetching a claim does not return an disputed status' do
66
- let(:data) { {"status"=>"unknown"} }
67
- it { expect(claim).not_to be_disputed }
68
- end
69
- end
70
-
71
- describe '#inactive?' do
72
- context 'given fetching a claim returns an inactive status' do
73
- let(:data) { {"status"=>"inactive"} }
74
- it { expect(claim).to be_inactive }
75
- end
76
-
77
- context 'given fetching a claim does not return an inactive status' do
78
- let(:data) { {"status"=>"unknown"} }
79
- it { expect(claim).not_to be_inactive }
80
- end
81
- end
82
-
83
- describe '#pending?' do
84
- context 'given fetching a claim returns an pending status' do
85
- let(:data) { {"status"=>"pending"} }
86
- it { expect(claim).to be_pending }
87
- end
88
-
89
- context 'given fetching a claim does not return an pending status' do
90
- let(:data) { {"status"=>"unknown"} }
91
- it { expect(claim).not_to be_pending }
92
- end
93
- end
94
-
95
- describe '#potential?' do
96
- context 'given fetching a claim returns an potential status' do
97
- let(:data) { {"status"=>"potential"} }
98
- it { expect(claim).to be_potential }
99
- end
100
-
101
- context 'given fetching a claim does not return an potential status' do
102
- let(:data) { {"status"=>"unknown"} }
103
- it { expect(claim).not_to be_potential }
104
- end
105
- end
106
-
107
- describe '#takedown?' do
108
- context 'given fetching a claim returns an takedown status' do
109
- let(:data) { {"status"=>"takedown"} }
110
- it { expect(claim).to be_takedown }
111
- end
112
-
113
- context 'given fetching a claim does not return an takedown status' do
114
- let(:data) { {"status"=>"unknown"} }
115
- it { expect(claim).not_to be_takedown }
116
- end
117
- end
118
-
119
- describe '#has_unknown_status?' do
120
- context 'given fetching a claim returns an unknown status' do
121
- let(:data) { {"status"=>"unknown"} }
122
- it { expect(claim).to have_unknown_status }
123
- end
124
-
125
- context 'given fetching a claim does not return an unknown status' do
126
- let(:data) { {"status"=>"active"} }
127
- it { expect(claim).not_to have_unknown_status }
128
- end
129
- end
130
-
131
- describe '#content_type' do
132
- context 'given fetching a claim returns a content type' do
133
- let(:data) { {"contentType"=>"audio"} }
134
- it { expect(claim.content_type).to eq 'audio' }
135
- end
136
- end
137
-
138
- describe '#audio?' do
139
- context 'given fetching a claim returns an audio content type' do
140
- let(:data) { {"contentType"=>"audio"} }
141
- it { expect(claim).to be_audio }
142
- end
143
-
144
- context 'given fetching a claim does not return an audio content type' do
145
- let(:data) { {"contentType"=>"audiovisual"} }
146
- it { expect(claim).not_to be_audio }
147
- end
148
- end
149
-
150
- describe '#video?' do
151
- context 'given fetching a claim returns an video content type' do
152
- let(:data) { {"contentType"=>"video"} }
153
- it { expect(claim).to be_video }
154
- end
155
-
156
- context 'given fetching a claim does not return an video content type' do
157
- let(:data) { {"contentType"=>"audiovisual"} }
158
- it { expect(claim).not_to be_video }
159
- end
160
- end
161
-
162
- describe '#audiovisual?' do
163
- context 'given fetching a claim returns an audiovisual content type' do
164
- let(:data) { {"contentType"=>"audiovisual"} }
165
- it { expect(claim).to be_audiovisual }
166
- end
167
-
168
- context 'given fetching a claim does not return an audiovisual content type' do
169
- let(:data) { {"contentType"=>"audio"} }
170
- it { expect(claim).not_to be_audiovisual }
171
- end
172
- end
173
-
174
- describe '#created_at' do
175
- context 'given fetching a claim returns a creation timestamp' do
176
- let(:data) { {"timeCreated"=>"2014-04-22T19:14:49.000Z"} }
177
- it { expect(claim.created_at.year).to be 2014 }
178
- end
179
- end
180
-
181
- describe '#block_outside_ownership?' do
182
- context 'given fetching a claim returns blockOutsideOwnership true' do
183
- let(:data) { {"blockOutsideOwnership"=>true} }
184
- it { expect(claim.block_outside_ownership?).to be true }
185
- end
186
-
187
- context 'given fetching a claim returns blockOutsideOwnership false' do
188
- let(:data) { {"blockOutsideOwnership"=>false} }
189
- it { expect(claim.block_outside_ownership?).to be false }
190
- end
191
- end
192
-
193
- describe '#match_reference_id' do
194
- context 'given fetching a claim returns matchInfo' do
195
- let(:data) { {"matchInfo"=>{"referenceId"=>"0r3JDtcRLuQ"}} }
196
- it { expect(claim.match_reference_id).to eq "0r3JDtcRLuQ" }
197
- end
198
- end
199
-
200
- describe '#third_party?' do
201
- context 'given fetching a claim returns thirdPartyClaim true' do
202
- let(:data) { {"thirdPartyClaim"=>true} }
203
- it { expect(claim.third_party?).to be true }
204
- end
205
-
206
- context 'given fetching a claim returns thirdPartyClaim true' do
207
- let(:data) { {"thirdPartyClaim"=>false} }
208
- it { expect(claim.third_party?).to be false }
209
- end
210
- end
211
-
212
- describe '#source' do
213
- context 'given fetching a claim returns a source' do
214
- let(:data) { {"origin"=>{"source"=>"webUpload"}} }
215
- it { expect(claim.source).to eq 'webUpload' }
216
- end
217
-
218
- context 'given fetching a claim does not return a source' do
219
- let(:data) { {"origin"=>{}} }
220
- it { expect(claim.source).to eq nil }
221
- end
222
- end
223
- end
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/comment'
3
-
4
- describe Yt::Comment do
5
- subject(:comment) { Yt::Comment.new attrs }
6
-
7
- describe '#snippet' do
8
- context 'given fetching a comment returns a snippet' do
9
- let(:attrs) { {snippet: {"videoId" => "12345"}} }
10
- it { expect(comment.snippet).to be_a Yt::Snippet }
11
- end
12
- end
13
-
14
- describe 'attributes' do
15
- examples = {
16
- video_id: {with: 'xyz123', without: nil},
17
- parent_id: {with: 'abc123', without: nil},
18
- text_display: {with: 'awesome', without: nil},
19
- author_display_name: {with: 'John', without: nil},
20
- like_count: {with: 10, without: nil},
21
- updated_at: {input: '2016-03-22T12:56:56.3Z', with: Time.parse('2016-03-22T12:56:56.3Z'), without: nil},
22
- }
23
-
24
- examples.each do |attr, cases|
25
- describe "##{attr}" do
26
- context "given a snippet with a #{attr}" do
27
- let(:attrs) {
28
- {snippet: {"#{attr.to_s.camelize(:lower)}" => cases[:input] || cases[:with]}}}
29
- it { expect(comment.send(attr)).to eq cases[:with] }
30
- end
31
-
32
- context "given a snippet without a #{attr}" do
33
- let(:attrs) { {snippet: {}} }
34
- it { expect(comment.send(attr)).to eq cases[:without] }
35
- end
36
- end
37
- end
38
- end
39
- end
40
-
@@ -1,93 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/comment_thread'
3
-
4
- describe Yt::CommentThread do
5
- subject(:comment_thread) { Yt::CommentThread.new attrs }
6
-
7
- describe '#snippet' do
8
- context 'given fetching a comment thread returns a snippet' do
9
- let(:attrs) { {snippet: {"videoId" => "12345"}} }
10
- it { expect(comment_thread.snippet).to be_a Yt::Snippet }
11
- end
12
- end
13
-
14
- describe '#video_id' do
15
- context 'given a snippet with a video id' do
16
- let(:attrs) { {snippet: {"videoId"=>"12345"}} }
17
- it { expect(comment_thread.video_id).to eq '12345' }
18
- end
19
-
20
- context 'given a snippet without a video id' do
21
- let(:attrs) { {snippet: {}} }
22
- it { expect(comment_thread.video_id).to be_nil }
23
- end
24
- end
25
-
26
- describe '#top_level_comment' do
27
- context 'given a snippet with a top level comment' do
28
- let(:attrs) { {snippet: {"topLevelComment"=> {}}} }
29
- it { expect(comment_thread.top_level_comment).to be_a Yt::Comment }
30
- end
31
- end
32
-
33
- describe 'attributes from #top_level_comment delegations' do
34
- context 'with values' do
35
- let(:attrs) { {snippet: {"topLevelComment"=> {"id" => "xyz123", "snippet" => {
36
- "textDisplay" => "funny video!",
37
- "authorDisplayName" => "fullscreen",
38
- "likeCount" => 99,
39
- "updatedAt" => "2016-03-22T12:56:56.3Z"}}}} }
40
-
41
- it { expect(comment_thread.top_level_comment.id).to eq 'xyz123' }
42
- it { expect(comment_thread.text_display).to eq 'funny video!' }
43
- it { expect(comment_thread.author_display_name).to eq 'fullscreen' }
44
- it { expect(comment_thread.like_count).to eq 99 }
45
- it { expect(comment_thread.updated_at).to eq Time.parse('2016-03-22T12:56:56.3Z') }
46
- end
47
-
48
- context 'without values' do
49
- let(:attrs) { {snippet: {"topLevelComment"=> {"snippet" => {}}}} }
50
-
51
- it { expect(comment_thread.text_display).to be_nil }
52
- it { expect(comment_thread.author_display_name).to be_nil }
53
- it { expect(comment_thread.like_count).to be_nil }
54
- it { expect(comment_thread.updated_at).to be_nil }
55
- end
56
- end
57
-
58
- describe '#total_reply_count' do
59
- context 'given a snippet with a total reply count' do
60
- let(:attrs) { {snippet: {"totalReplyCount"=>1}} }
61
- it { expect(comment_thread.total_reply_count).to eq 1 }
62
- end
63
-
64
- context 'given a snippet without a total reply count' do
65
- let(:attrs) { {snippet: {}} }
66
- it { expect(comment_thread.total_reply_count).to be_nil }
67
- end
68
- end
69
-
70
- describe '#can_reply?' do
71
- context 'given a snippet with canReply set' do
72
- let(:attrs) { {snippet: {"canReply"=>true}} }
73
- it { expect(comment_thread.can_reply?).to be true }
74
- end
75
-
76
- context 'given a snippet without canReply set' do
77
- let(:attrs) { {snippet: {}} }
78
- it { expect(comment_thread.can_reply?).to be false }
79
- end
80
- end
81
-
82
- describe '#is_public?' do
83
- context 'given a snippet with isPublic set' do
84
- let(:attrs) { {snippet: {"isPublic"=>true}} }
85
- it { expect(comment_thread).to be_public }
86
- end
87
-
88
- context 'given a snippet without isPublic set' do
89
- let(:attrs) { {snippet: {}} }
90
- it { expect(comment_thread).to_not be_public }
91
- end
92
- end
93
- end
@@ -1,44 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Yt::Configuration do
4
- subject(:config) { Yt::Configuration.new }
5
-
6
- describe '#client_id' do
7
- context 'without an environment variable YT_CLIENT_ID' do
8
- before { ENV['YT_CLIENT_ID'] = nil }
9
- it {expect(config.client_id).to be_nil }
10
- end
11
-
12
- context 'given an environment variable YT_CLIENT_ID' do
13
- let(:client_id) { '1234567890.apps.googleusercontent.com' }
14
- before { ENV['YT_CLIENT_ID'] = client_id}
15
- it {expect(config.client_id).to eq client_id }
16
- end
17
- end
18
-
19
- describe '#client_secret' do
20
- context 'without an environment variable YT_CLIENT_SECRET' do
21
- before { ENV['YT_CLIENT_SECRET'] = nil }
22
- it {expect(config.client_secret).to be_nil }
23
- end
24
-
25
- context 'given an environment variable YT_CLIENT_SECRET' do
26
- let(:client_secret) { '1234567890' }
27
- before { ENV['YT_CLIENT_SECRET'] = client_secret}
28
- it {expect(config.client_secret).to eq client_secret }
29
- end
30
- end
31
-
32
- describe '#api_key' do
33
- context 'without an environment variable YT_API_KEY' do
34
- before { ENV['YT_API_KEY'] = nil }
35
- it {expect(config.api_key).to be_nil }
36
- end
37
-
38
- context 'given an environment variable YT_API_KEY' do
39
- let(:api_key) { '123456789012345678901234567890' }
40
- before { ENV['YT_API_KEY'] = api_key}
41
- it {expect(config.api_key).to eq api_key }
42
- end
43
- end
44
- end
@@ -1,52 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/content_detail'
3
-
4
- describe Yt::ContentDetail do
5
- subject(:content_detail) { Yt::ContentDetail.new data: data }
6
-
7
- describe '#data' do
8
- let(:data) { {"key"=>"value"} }
9
- specify 'returns the data the content detail was initialized with' do
10
- expect(content_detail.data).to eq data
11
- end
12
- end
13
-
14
- describe '#duration' do
15
- context 'given a content_detail with duration in weeks, days, hours, minutes' do
16
- let(:data) { {"duration"=>"P1W2DT6H21M32S"}}
17
- it { expect(content_detail.duration).to eq 800492 }
18
- end
19
-
20
- context 'given a content_detail with duration in days' do
21
- let(:data) { {"duration"=>"P1D"}}
22
- it { expect(content_detail.duration).to eq 86400 }
23
- end
24
-
25
- context 'given a content_detail with duration in hours, minutes, seconds' do
26
- let(:data) { {"duration"=>"PT1H18M52S"} }
27
- it { expect(content_detail.duration).to eq 4732 }
28
- end
29
-
30
- context 'given a content_detail with duration in minutes and seconds' do
31
- let(:data) { {"duration"=>"PT2M51S"} }
32
- it { expect(content_detail.duration).to eq 171 }
33
- end
34
-
35
- context 'given a content_detail with duration in minutes' do
36
- let(:data) { {"duration"=>"PT2M"} }
37
- it { expect(content_detail.duration).to eq 120 }
38
- end
39
-
40
- context 'given a content_detail with duration in seconds' do
41
- let(:data) { {"duration"=>"PT51S"} }
42
- it { expect(content_detail.duration).to eq 51 }
43
- end
44
- end
45
-
46
- describe '#length' do
47
- context 'returns the duration in HH:MM:SS' do
48
- let(:data) { {"duration"=>"PT1H18M52S"} }
49
- it { expect(content_detail.length).to eq '01:18:52' }
50
- end
51
- end
52
- end
@@ -1,6 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/content_owner_detail'
3
-
4
- describe Yt::ContentOwnerDetail do
5
- subject(:content_owner_detail) { Yt::ContentOwnerDetail.new data: data }
6
- end