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,249 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/reference'
3
-
4
- describe Yt::Reference do
5
- subject(:reference) { Yt::Reference.new data: data }
6
-
7
- describe '#id' do
8
- context 'given fetching a reference returns an id' do
9
- let(:data) { {"id"=>"aBcD1EfGHIk"} }
10
- it { expect(reference.id).to eq 'aBcD1EfGHIk' }
11
- end
12
- end
13
-
14
- describe '#asset_id' do
15
- context 'given fetching a reference returns an assetId' do
16
- let(:data) { {"assetId"=>"A123456789012601"} }
17
- it { expect(reference.asset_id).to eq 'A123456789012601' }
18
- end
19
- end
20
-
21
- describe '#status' do
22
- context 'given fetching a reference returns a status' do
23
- let(:data) { {"status"=>"active"} }
24
- it { expect(reference.status).to eq 'active' }
25
- end
26
- end
27
-
28
- describe '#activating?' do
29
- context 'given fetching a reference returns an activating status' do
30
- let(:data) { {"status"=>"activating"} }
31
- it { expect(reference).to be_activating }
32
- end
33
-
34
- context 'given fetching a reference does not return an activating status' do
35
- let(:data) { {"status"=>"unknown"} }
36
- it { expect(reference).not_to be_activating }
37
- end
38
- end
39
-
40
- describe '#active?' do
41
- context 'given fetching a reference returns an active status' do
42
- let(:data) { {"status"=>"active"} }
43
- it { expect(reference).to be_active }
44
- end
45
-
46
- context 'given fetching a reference does not return an active status' do
47
- let(:data) { {"status"=>"unknown"} }
48
- it { expect(reference).not_to be_active }
49
- end
50
- end
51
-
52
- describe '#checking?' do
53
- context 'given fetching a reference returns an checking status' do
54
- let(:data) { {"status"=>"checking"} }
55
- it { expect(reference).to be_checking }
56
- end
57
-
58
- context 'given fetching a reference does not return an checking status' do
59
- let(:data) { {"status"=>"unknown"} }
60
- it { expect(reference).not_to be_checking }
61
- end
62
- end
63
-
64
- describe '#computing_fingerprint?' do
65
- context 'given fetching a reference returns an computing_fingerprint status' do
66
- let(:data) { {"status"=>"computing_fingerprint"} }
67
- it { expect(reference).to be_computing_fingerprint }
68
- end
69
-
70
- context 'given fetching a reference does not return an computing_fingerprint status' do
71
- let(:data) { {"status"=>"unknown"} }
72
- it { expect(reference).not_to be_computing_fingerprint }
73
- end
74
- end
75
-
76
- describe '#deleted?' do
77
- context 'given fetching a reference returns an deleted status' do
78
- let(:data) { {"status"=>"deleted"} }
79
- it { expect(reference).to be_deleted }
80
- end
81
-
82
- context 'given fetching a reference does not return an deleted status' do
83
- let(:data) { {"status"=>"unknown"} }
84
- it { expect(reference).not_to be_deleted }
85
- end
86
- end
87
-
88
- describe '#duplicate_on_hold?' do
89
- context 'given fetching a reference returns an duplicate_on_hold status' do
90
- let(:data) { {"status"=>"duplicate_on_hold"} }
91
- it { expect(reference).to be_duplicate_on_hold }
92
- end
93
-
94
- context 'given fetching a reference does not return an duplicate_on_hold status' do
95
- let(:data) { {"status"=>"unknown"} }
96
- it { expect(reference).not_to be_duplicate_on_hold }
97
- end
98
- end
99
-
100
- describe '#inactive?' do
101
- context 'given fetching a reference returns an inactive status' do
102
- let(:data) { {"status"=>"inactive"} }
103
- it { expect(reference).to be_inactive }
104
- end
105
-
106
- context 'given fetching a reference does not return an inactive status' do
107
- let(:data) { {"status"=>"unknown"} }
108
- it { expect(reference).not_to be_inactive }
109
- end
110
- end
111
-
112
- describe '#live_streaming_processing?' do
113
- context 'given fetching a reference returns an live_streaming_processing status' do
114
- let(:data) { {"status"=>"live_streaming_processing"} }
115
- it { expect(reference).to be_live_streaming_processing }
116
- end
117
-
118
- context 'given fetching a reference does not return an live_streaming_processing status' do
119
- let(:data) { {"status"=>"unknown"} }
120
- it { expect(reference).not_to be_live_streaming_processing }
121
- end
122
- end
123
-
124
- describe '#urgent_reference_processing?' do
125
- context 'given fetching a reference returns an urgent_reference_processing status' do
126
- let(:data) { {"status"=>"urgent_reference_processing"} }
127
- it { expect(reference).to be_urgent_reference_processing }
128
- end
129
-
130
- context 'given fetching a reference does not return an urgent_reference_processing status' do
131
- let(:data) { {"status"=>"unknown"} }
132
- it { expect(reference).not_to be_urgent_reference_processing }
133
- end
134
- end
135
-
136
- describe '#status_reason' do
137
- context 'given fetching a reference returns a statusReason' do
138
- let(:data) { {"statusReason"=>"explanation"} }
139
- it { expect(reference.status_reason).to eq 'explanation' }
140
- end
141
- end
142
-
143
- describe '#duplicate_leader' do
144
- context 'given fetching a reference returns a duplicateLeader' do
145
- let(:data) { {"duplicateLeader"=>"123456"} }
146
- it { expect(reference.duplicate_leader).to eq '123456' }
147
- end
148
- end
149
-
150
- describe '#length' do
151
- context 'given fetching a reference returns a length' do
152
- let(:data) { {"length"=>354.66} }
153
- it { expect(reference.length).to eq 354.66 }
154
- end
155
- end
156
-
157
- describe '#video_id' do
158
- context 'given fetching a reference returns an videoId' do
159
- let(:data) { {"videoId"=>"9bZkp7q19f0"} }
160
- it { expect(reference.video_id).to eq '9bZkp7q19f0' }
161
- end
162
- end
163
-
164
- describe '#claim_id' do
165
- context 'given fetching a reference returns an claimId' do
166
- let(:data) { {"claimId"=>"aBcD1EfGHIk"} }
167
- it { expect(reference.claim_id).to eq 'aBcD1EfGHIk' }
168
- end
169
- end
170
-
171
- describe '#urgent?' do
172
- context 'given fetching a reference returns an urgent status true' do
173
- let(:data) { {"urgent"=>true} }
174
- it { expect(reference).to be_urgent }
175
- end
176
-
177
- context 'given fetching a reference returns an urgent status false' do
178
- let(:data) { {"urgent"=>false} }
179
- it { expect(reference).not_to be_urgent }
180
- end
181
- end
182
-
183
- describe '#content_type' do
184
- context 'given fetching a reference returns a content type' do
185
- let(:data) { {"contentType"=>"audio"} }
186
- it { expect(reference.content_type).to eq 'audio' }
187
- end
188
- end
189
-
190
- describe '#audio?' do
191
- context 'given fetching a reference returns an audio content type' do
192
- let(:data) { {"contentType"=>"audio"} }
193
- it { expect(reference).to be_audio }
194
- end
195
-
196
- context 'given fetching a reference does not return an audio content type' do
197
- let(:data) { {"contentType"=>"audiovisual"} }
198
- it { expect(reference).not_to be_audio }
199
- end
200
- end
201
-
202
- describe '#video?' do
203
- context 'given fetching a reference returns an video content type' do
204
- let(:data) { {"contentType"=>"video"} }
205
- it { expect(reference).to be_video }
206
- end
207
-
208
- context 'given fetching a reference does not return an video content type' do
209
- let(:data) { {"contentType"=>"audiovisual"} }
210
- it { expect(reference).not_to be_video }
211
- end
212
- end
213
-
214
- describe '#audiovisual?' do
215
- context 'given fetching a reference returns an audiovisual content type' do
216
- let(:data) { {"contentType"=>"audiovisual"} }
217
- it { expect(reference).to be_audiovisual }
218
- end
219
-
220
- context 'given fetching a reference does not return an audiovisual content type' do
221
- let(:data) { {"contentType"=>"audio"} }
222
- it { expect(reference).not_to be_audiovisual }
223
- end
224
- end
225
-
226
- describe '#audioswap_enabled?' do
227
- context 'given fetching a reference returns audioswapEnabled true' do
228
- let(:data) { {"audioswapEnabled"=>true} }
229
- it { expect(reference).to be_audioswap_enabled }
230
- end
231
-
232
- context 'given fetching a reference returns audioswapEnabled false' do
233
- let(:data) { {"audioswap_enabled"=>false} }
234
- it { expect(reference).not_to be_audioswap_enabled }
235
- end
236
- end
237
-
238
- describe '#ignore_fp_match?' do
239
- context 'given fetching a reference returns ignoreFpMatch true' do
240
- let(:data) { {"ignoreFpMatch"=>true} }
241
- it { expect(reference.ignore_fp_match?).to be true }
242
- end
243
-
244
- context 'given fetching a reference returns ignoreFpMatch false' do
245
- let(:data) { {"ignoreFpMatch"=>false} }
246
- it { expect(reference.ignore_fp_match?).to be false }
247
- end
248
- end
249
- end
@@ -1,204 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/request'
3
-
4
-
5
- describe Yt::Request do
6
- subject(:request) { Yt::Request.new host: 'example.com' }
7
- let(:response) { response_class.new nil, nil, nil }
8
- let(:response_body) { }
9
-
10
- describe '#run' do
11
- context 'given a request that returns' do
12
- before { allow(response).to receive(:body).and_return response_body }
13
- before { expect(Net::HTTP).to receive(:start).once.and_return response }
14
-
15
- context 'a success code 2XX' do
16
- let(:response_class) { Net::HTTPOK }
17
-
18
- it { expect{request.run}.not_to fail }
19
- end
20
-
21
- context 'an error code 5XX' do
22
- let(:response_class) { Net::HTTPServerError }
23
- let(:retry_response) { retry_response_class.new nil, nil, nil }
24
- before { allow(retry_response).to receive(:body) }
25
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
26
-
27
- context 'every time' do
28
- let(:retry_response_class) { Net::HTTPServerError }
29
-
30
- it { expect{request.run}.to fail }
31
- end
32
-
33
- context 'but returns a success code 2XX the second time' do
34
- let(:retry_response_class) { Net::HTTPOK }
35
-
36
- it { expect{request.run}.not_to fail }
37
- end
38
- end
39
-
40
- context 'an error code 403 with a "quota exceeded message"' do
41
- let(:response_class) { Net::HTTPForbidden }
42
- let(:retry_response) { retry_response_class.new nil, nil, nil }
43
- let(:response_body) { "{\n \"error\": {\n \"errors\": [\n {\n \"domain\": \"youtube.quota\",\n \"reason\": \"quotaExceeded\",\n \"message\": \"The request cannot be completed because you have exceeded your \\u003ca href=\\\"/youtube/v3/getting-started#quota\\\"\\u003equota\\u003c/a\\u003e.\"\n }\n ],\n \"code\": 403,\n \"message\": \"The request cannot be completed because you have exceeded your \\u003ca href=\\\"/youtube/v3/getting-started#quota\\\"\\u003equota\\u003c/a\\u003e.\"\n }\n}\n" }
44
- before { allow(retry_response).to receive(:body) }
45
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
46
-
47
- context 'every time' do
48
- let(:retry_response_class) { Net::HTTPForbidden }
49
-
50
- it { expect{request.run}.to fail }
51
- end
52
-
53
- context 'but returns a success code 2XX the second time' do
54
- let(:retry_response_class) { Net::HTTPOK }
55
-
56
- it { expect{request.run}.not_to fail }
57
- end
58
- end
59
-
60
- context 'an error code 401' do
61
- let(:response_class) { Net::HTTPUnauthorized }
62
-
63
- it { expect{request.run}.to fail }
64
- end
65
-
66
- context 'any other non-2XX error code' do
67
- let(:response_class) { Net::HTTPNotFound }
68
-
69
- it { expect{request.run}.to fail }
70
- end
71
- end
72
-
73
- # TODO: clean up the following tests, removing repetitions
74
- context 'given a request that raises' do
75
- before { expect(Net::HTTP).to receive(:start).once.and_raise http_error }
76
-
77
- # NOTE: This test is just a reflection of YouTube irrational behavior of
78
- # being unavailable once in a while, and therefore causing Net::HTTP to
79
- # fail, although retrying after some seconds works.
80
- context 'an OpenSSL::SSL::SSLError' do
81
- let(:http_error) { OpenSSL::SSL::SSLError.new }
82
-
83
- context 'every time' do
84
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
85
-
86
- it { expect{request.run}.to fail }
87
- end
88
-
89
- context 'but works the second time' do
90
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
91
- before { allow(retry_response).to receive(:body) }
92
- let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
93
-
94
- it { expect{request.run}.not_to fail }
95
- end
96
- end
97
-
98
- # NOTE: This test is just a reflection of YouTube irrational behavior of
99
- # being unavailable once in a while, and therefore causing Net::HTTP to
100
- # fail, although retrying after some seconds works.
101
- context 'an Errno::ETIMEDOUT' do
102
- let(:http_error) { Errno::ETIMEDOUT.new }
103
-
104
- context 'every time' do
105
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
106
-
107
- it { expect{request.run}.to fail }
108
- end
109
-
110
- context 'but works the second time' do
111
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
112
- before { allow(retry_response).to receive(:body) }
113
- let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
114
-
115
- it { expect{request.run}.not_to fail }
116
- end
117
- end
118
-
119
- # NOTE: This test is just a reflection of YouTube irrational behavior of
120
- # being unavailable once in a while, and therefore causing Net::HTTP to
121
- # fail, although retrying after some seconds works.
122
- context 'an Errno::ENETUNREACH' do
123
- let(:http_error) { Errno::ENETUNREACH.new }
124
-
125
- context 'every time' do
126
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
127
-
128
- it { expect{request.run}.to fail }
129
- end
130
-
131
- context 'but works the second time' do
132
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
133
- before { allow(retry_response).to receive(:body) }
134
- let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
135
-
136
- it { expect{request.run}.not_to fail }
137
- end
138
- end
139
-
140
- # NOTE: This test is just a reflection of YouTube irrational behavior of
141
- # being unavailable once in a while, and therefore causing Net::HTTP to
142
- # fail, although retrying after some seconds works.
143
- context 'an Errno::EHOSTUNREACH' do
144
- let(:http_error) { Errno::EHOSTUNREACH.new }
145
-
146
- context 'every time' do
147
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
148
-
149
- it { expect{request.run}.to fail }
150
- end
151
-
152
- context 'but works the second time' do
153
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
154
- before { allow(retry_response).to receive(:body) }
155
- let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
156
-
157
- it { expect{request.run}.not_to fail }
158
- end
159
- end
160
-
161
- # NOTE: This test is just a reflection of YouTube irrational behavior of
162
- # being unavailable once in a while, and therefore causing Net::HTTP to
163
- # fail, although retrying after some seconds works.
164
- context 'an OpenSSL::SSL::SSLErrorWaitReadable', ruby21: true do
165
- let(:http_error) { OpenSSL::SSL::SSLErrorWaitReadable.new }
166
-
167
- context 'every time' do
168
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
169
-
170
- it { expect{request.run}.to fail }
171
- end
172
-
173
- context 'but works the second time' do
174
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
175
- before { allow(retry_response).to receive(:body) }
176
- let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
177
-
178
- it { expect{request.run}.not_to fail }
179
- end
180
- end
181
-
182
- # NOTE: This test is just a reflection of YouTube irrational behavior of
183
- # being unavailable once in a while, and therefore causing Net::HTTP to
184
- # fail, although retrying after some seconds works.
185
- context 'a SocketError', ruby21: true do
186
- let(:http_error) { SocketError.new }
187
-
188
- context 'every time' do
189
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
190
-
191
- it { expect{request.run}.to fail }
192
- end
193
-
194
- context 'but works the second time' do
195
- before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
196
- before { allow(retry_response).to receive(:body) }
197
- let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
198
-
199
- it { expect{request.run}.not_to fail }
200
- end
201
- end
202
- end
203
- end
204
- end
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/resource'
3
-
4
- describe Yt::Resource do
5
- subject(:resource) { Yt::Resource.new attrs }
6
-
7
- describe '#public?' do
8
- context 'given fetching a status returns privacyStatus "public"' do
9
- let(:attrs) { {status: {"privacyStatus"=>"public"}} }
10
- it { expect(resource).to be_public }
11
- end
12
-
13
- context 'given fetching a status does not return privacyStatus "public"' do
14
- let(:attrs) { {status: {}} }
15
- it { expect(resource).not_to be_public }
16
- end
17
- end
18
-
19
- describe '#private?' do
20
- context 'given fetching a status returns privacyStatus "private"' do
21
- let(:attrs) { {status: {"privacyStatus"=>"private"}} }
22
- it { expect(resource).to be_private }
23
- end
24
-
25
- context 'given fetching a status does not return privacyStatus "private"' do
26
- let(:attrs) { {status: {}} }
27
- it { expect(resource).not_to be_private }
28
- end
29
- end
30
-
31
- describe '#unlisted?' do
32
- context 'given fetching a status returns privacyStatus "unlisted"' do
33
- let(:attrs) { {status: {"privacyStatus"=>"unlisted"}} }
34
- it { expect(resource).to be_unlisted }
35
- end
36
-
37
- context 'given fetching a status does not return privacyStatus "unlisted"' do
38
- let(:attrs) { {status: {}} }
39
- it { expect(resource).not_to be_unlisted }
40
- end
41
- end
42
- end
@@ -1,71 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/right_owner'
3
-
4
- describe Yt::RightOwner do
5
- subject(:right_owner) { Yt::RightOwner.new data: data }
6
- let(:data) { {} }
7
-
8
- describe '#ratio' do
9
- context 'given fetching an owner returns a ratio' do
10
- let(:data) { {"ratio"=>"20.0"} }
11
- it { expect(right_owner.ratio).to eq 20 }
12
- end
13
- end
14
-
15
- describe '#owner' do
16
- context 'given fetching an owner returns an owner name' do
17
- let(:data) { {"owner"=>"FullScreen"} }
18
- it { expect(right_owner.owner).to eq 'FullScreen' }
19
- end
20
- end
21
-
22
- describe '#owner' do
23
- context 'given fetching an owner returns a publisher name' do
24
- let(:data) { {"publisher"=>"Third Party"} }
25
- it { expect(right_owner.publisher).to eq 'Third Party' }
26
- end
27
-
28
- context 'given fetching an owner does not return a publisher name' do
29
- it { expect(right_owner.publisher).to be_nil }
30
- end
31
- end
32
-
33
- describe '#included_territories' do
34
- context 'given fetching an owner returns included territories' do
35
- let(:data) { {"type"=>"include", "territories"=>["US", "CA"]} }
36
- it { expect(right_owner.included_territories).to eq %w(US CA) }
37
- end
38
-
39
- context 'given fetching an owner does not return included territories' do
40
- it { expect(right_owner.included_territories).to be_nil }
41
- end
42
- end
43
-
44
- describe '#excluded_territories' do
45
- context 'given fetching an owner returns excluded territories' do
46
- let(:data) { {"type"=>"exclude", "territories"=>["US", "CA"]} }
47
- it { expect(right_owner.excluded_territories).to eq %w(US CA) }
48
- end
49
-
50
- context 'given fetching an owner does not return excluded territories' do
51
- it { expect(right_owner.excluded_territories).to be_nil }
52
- end
53
- end
54
-
55
- describe '#everywhere?' do
56
- context 'given fetching an owner returns zero excluded territories' do
57
- let(:data) { {"type"=>"exclude", "territories"=>[]} }
58
- it { expect(right_owner).to be_everywhere }
59
- end
60
-
61
- context 'given fetching an owner returns no excluded territories' do
62
- let(:data) { {"type"=>"exclude"} }
63
- it { expect(right_owner).to be_everywhere }
64
- end
65
-
66
- context 'given fetching an owner returns included territories' do
67
- let(:data) { {"type"=>"include", "territories"=>[]} }
68
- it { expect(right_owner).not_to be_everywhere }
69
- end
70
- end
71
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/snippet'
3
-
4
- describe Yt::Snippet do
5
- subject(:snippet) { Yt::Snippet.new data: data }
6
-
7
- describe '#data' do
8
- let(:data) { {"key"=>"value"} }
9
- specify 'returns the data the snippet was initialized with' do
10
- expect(snippet.data).to eq data
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/statistics_set'
3
-
4
- describe Yt::StatisticsSet do
5
- subject(:statistics_set) { Yt::StatisticsSet.new data: data }
6
-
7
- describe '#data' do
8
- let(:data) { {"key"=>"value"} }
9
- specify 'returns the data the statistics set was initialized with' do
10
- expect(statistics_set.data).to eq data
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/status'
3
-
4
- describe Yt::Status do
5
- subject(:status) { Yt::Status.new data: data }
6
-
7
- describe '#data' do
8
- let(:data) { {"key"=>"value"} }
9
- specify 'returns the data the status was initialized with' do
10
- expect(status.data).to eq data
11
- end
12
- end
13
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/subscription'
3
-
4
- describe Yt::Subscription do
5
- subject(:subscription) { Yt::Subscription.new id: id }
6
-
7
- describe '#exists?' do
8
- context 'given a subscription with an id' do
9
- let(:id) { 'CBl6OoF0BpiV' }
10
- it { expect(subscription).to exist }
11
- end
12
-
13
- context 'given a subscription without an id' do
14
- let(:id) { nil }
15
- it { expect(subscription).not_to exist }
16
- end
17
- end
18
-
19
- describe '#delete' do
20
- let(:id) { 'CBl6OoF0BpiV' }
21
- before { expect(subscription).to behave }
22
-
23
- context 'given an existing subscription' do
24
- let(:behave) { receive(:do_delete).and_yield }
25
-
26
- it { expect(subscription.delete).to be true }
27
- it { expect{subscription.delete}.to change{subscription.exists?} }
28
- end
29
- end
30
- end