-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathchannel_spec.rb
More file actions
151 lines (128 loc) · 5.01 KB
/
channel_spec.rb
File metadata and controls
151 lines (128 loc) · 5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
require 'spec_helper'
require 'yt/models/channel'
describe Yt::Channel do
subject(:channel) { Yt::Channel.new attrs }
describe '#etag' do
context 'given the API response includes an etag' do
let(:attrs) { {id: 'any-id', etag: '12345'} }
it { expect(channel.etag).to eq '12345' }
end
end
describe '#title' do
context 'given a snippet with a title' do
let(:attrs) { {snippet: {"title"=>"Fullscreen"}} }
it { expect(channel.title).to eq 'Fullscreen' }
end
context 'given a snippet without a title' do
let(:attrs) { {snippet: {}} }
it { expect(channel.title).to eq '' }
end
end
describe '#description' do
context 'given a snippet with a description' do
let(:attrs) { {snippet: {"description"=>"A cool channel."}} }
it { expect(channel.description).to eq 'A cool channel.' }
end
context 'given a snippet without a description' do
let(:attrs) { {snippet: {}} }
it { expect(channel.description).to eq '' }
end
end
describe '#made_for_kids?' do
context 'given fetching a status returns madeForKids true' do
let(:attrs) { {status: {"madeForKids"=>true}} }
it { expect(channel).to be_made_for_kids }
end
context 'given fetching a status returns madeForKids false' do
let(:attrs) { {status: {"madeForKids"=>false}} }
it { expect(channel).not_to be_made_for_kids }
end
end
describe '#self_declared_made_for_kids?' do
context 'given fetching a status returns selfDeclaredMadeForKids true' do
let(:attrs) { {status: {"selfDeclaredMadeForKids"=>true}} }
it { expect(channel).to be_self_declared_made_for_kids }
end
context 'given fetching a status returns selfDeclaredMadeForKids false' do
let(:attrs) { {status: {"selfDeclaredMadeForKids"=>false}} }
it { expect(channel).not_to be_self_declared_made_for_kids }
end
end
describe '#thumbnail_url' do
context 'given a snippet with thumbnails' do
let(:attrs) { {snippet: {"thumbnails"=>{
"default"=>{"url"=> "http://example.com/88x88.jpg"},
"medium"=>{"url"=> "http://example.com/240x240.jpg"},
}}} }
it { expect(channel.thumbnail_url).to eq 'http://example.com/88x88.jpg' }
it { expect(channel.thumbnail_url 'default').to eq 'http://example.com/88x88.jpg' }
it { expect(channel.thumbnail_url :default).to eq 'http://example.com/88x88.jpg' }
it { expect(channel.thumbnail_url :medium).to eq 'http://example.com/240x240.jpg' }
it { expect(channel.thumbnail_url :high).to be_nil }
end
context 'given a snippet without thumbnails' do
let(:attrs) { {snippet: {}} }
it { expect(channel.thumbnail_url).to be_nil }
end
end
describe '#published_at' do
context 'given a snippet with a timestamp' do
let(:attrs) { {snippet: {"publishedAt"=>"2014-04-22T19:14:49.000Z"}} }
it { expect(channel.published_at.year).to be 2014 }
end
end
describe '#video_count' do
context 'given a video with videos' do
let(:attrs) { {statistics: {"videoCount"=>"42"}} }
it { expect(channel.video_count).to be 42 }
end
end
describe '#subscriber_count' do
context 'given a video with subscribers' do
let(:attrs) { {statistics: {"subscriberCount"=>"12"}} }
it { expect(channel.subscriber_count).to be 12 }
end
end
describe '#subscriber_count_visible?' do
context 'given a video with publicly visible subscribers' do
let(:attrs) { {statistics: {"hiddenSubscriberCount"=>false}} }
it { expect(channel).to be_subscriber_count_visible }
end
context 'given a video with hidden subscribers' do
let(:attrs) { {statistics: {"hiddenSubscriberCount"=>true}} }
it { expect(channel).not_to be_subscriber_count_visible }
end
end
describe '#content_owner' do
context 'given a content_owner_detail with a content owner' do
let(:attrs) { {content_owner_details: {"contentOwner"=>"FullScreen"}} }
it { expect(channel.content_owner).to eq 'FullScreen' }
end
context 'given a content_owner_detail without a content owner' do
let(:attrs) { {content_owner_details: {}} }
it { expect(channel.content_owner).to be_nil }
end
end
describe '#linked_at' do
context 'given a content_owner_detail with a timeLinked' do
let(:attrs) { {content_owner_details: {"timeLinked"=>"2014-04-22T19:14:49.000Z"}} }
it { expect(channel.linked_at.year).to be 2014 }
end
context 'given a content_owner_detail with a timeLinked' do
let(:attrs) { {content_owner_details: {}} }
it { expect(channel.linked_at).to be_nil }
end
end
describe '#snippet' do
context 'given fetching a channel returns a snippet' do
let(:attrs) { {snippet: {"title"=>"Fullscreen"}} }
it { expect(channel.snippet).to be_a Yt::Snippet }
end
end
describe '#status' do
context 'given fetching a channel returns a status' do
let(:attrs) { {status: {"privacyStatus"=>"public"}} }
it { expect(channel.status).to be_a Yt::Status }
end
end
end