themoviedb-jzg 0.0.27

Sign up to get free protection for your applications and to get access to all the features.
data/spec/tv_spec.rb ADDED
@@ -0,0 +1,458 @@
1
+ require 'rspec'
2
+ require 'spec_helper'
3
+ require 'vcr'
4
+
5
+ describe Tmdb::TV do
6
+
7
+ @fields = [
8
+ :backdrop_path,
9
+ :created_by,
10
+ :episode_run_time,
11
+ :first_air_date,
12
+ :genres,
13
+ :homepage,
14
+ :id,
15
+ :in_production,
16
+ :languages,
17
+ :last_air_date,
18
+ :name,
19
+ :networks,
20
+ :number_of_episodes,
21
+ :number_of_seasons,
22
+ :original_name,
23
+ :origin_country,
24
+ :overview,
25
+ :popularity,
26
+ :poster_path,
27
+ :seasons,
28
+ :status,
29
+ :vote_average,
30
+ :vote_count,
31
+ :credits,
32
+ :external_ids
33
+ ]
34
+
35
+ @fields.each do |field|
36
+ it { should respond_to field }
37
+ end
38
+
39
+ describe "For Chuck it should return images" do
40
+ before(:each) do
41
+ VCR.use_cassette 'tv/test_chuck' do
42
+ @tv = Tmdb::TV.images(1404)
43
+ end
44
+ end
45
+
46
+ it "should return backdrops for chuck" do
47
+ @tv.backdrops.length.should >= 1
48
+ end
49
+
50
+ it "should return posters for chuck" do
51
+ @tv.posters.length.should >= 1
52
+ end
53
+ end
54
+
55
+ describe "For a TV detail" do
56
+
57
+ before(:each) do
58
+ VCR.use_cassette 'tv/detail' do
59
+ @tv = Tmdb::TV.detail(1396)
60
+ end
61
+ end
62
+
63
+ it "should return a id" do
64
+ @tv.id.should == 1396
65
+ end
66
+
67
+ it "should return a backdrop" do
68
+ @tv.backdrop_path.should == "/8STVFl9kvWtFAydXUFHIUvT47AA.jpg"
69
+ end
70
+
71
+ it "should return a created date" do
72
+ @tv.created_by.first.name.should == "Vince Gilligan"
73
+ end
74
+
75
+ it "should return a run time" do
76
+ @tv.episode_run_time.should == [45, 47]
77
+ end
78
+
79
+ it "should return genres" do
80
+ @tv.genres.should_not == []
81
+ end
82
+
83
+ it "should return a first air date" do
84
+ @tv.first_air_date.should == "2008-01-20"
85
+ end
86
+
87
+ it "should return a homepage" do
88
+ @tv.homepage.should == "http://www.amctv.com/shows/breaking-bad"
89
+ end
90
+
91
+ it "should return a production state" do
92
+ @tv.in_production.should be_false
93
+ end
94
+
95
+ it "should return languages" do
96
+ @tv.languages.should == ["en", "de", "ro", "es", "fa"]
97
+ end
98
+
99
+ it "should return a last air date" do
100
+ @tv.last_air_date.should == "2013-09-29"
101
+ end
102
+
103
+ it "should return a name" do
104
+ @tv.name.should == "Breaking Bad"
105
+ end
106
+
107
+ it "should return a network" do
108
+ @tv.networks.first.id.should == 174
109
+ @tv.networks.first.name == "AMC"
110
+ end
111
+
112
+ it "should return the number of episodes" do
113
+ @tv.number_of_episodes.should == 62
114
+ end
115
+
116
+ it "should return the number of seasons" do
117
+ @tv.number_of_seasons.should == 5
118
+ end
119
+
120
+ it "should return the original name" do
121
+ @tv.original_name.should == "Breaking Bad"
122
+ end
123
+
124
+ it "should return the origin country" do
125
+ @tv.origin_country.should == ["US"]
126
+ end
127
+
128
+ it "should return a overview" do
129
+ @tv.overview.should == "Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. Set and produced in Albuquerque, New Mexico, Breaking Bad is the story of Walter White, a struggling high school chemistry teacher who is diagnosed with inoperable lung cancer at the beginning of the series. He turns to a life of crime, producing and selling methamphetamine, in order to secure his family's financial future before he dies, teaming with his former student, Jesse Pinkman. Heavily serialized, the series is known for positioning its characters in seemingly inextricable corners and has been labeled a contemporary western by its creator."
130
+ end
131
+
132
+ it "should return a popularity rating" do
133
+ @tv.popularity.should == 6.60821276854239
134
+ end
135
+
136
+ it "should return a poster" do
137
+ @tv.poster_path.should == "/iRDNn9EHKuBhGa77UBteazvsZa1.jpg"
138
+ end
139
+
140
+ it "should return seasons" do
141
+ @tv.seasons.should_not == []
142
+ end
143
+
144
+ it "should return a status" do
145
+ @tv.status.should == "Ended"
146
+ end
147
+
148
+ it "should return a vote average" do
149
+ @tv.vote_average.should == 8.86764705882353
150
+ end
151
+
152
+ it "should return a vote count" do
153
+ @tv.vote_count.should == 34
154
+ end
155
+
156
+ end
157
+
158
+ describe "For a TV detail with appended response" do
159
+ let(:append_fields) { %w{ credits external_ids }.join(',') }
160
+
161
+ before(:each) do
162
+ VCR.use_cassette 'tv/detail_with_appeded_response' do
163
+ @tv = Tmdb::TV.detail(1396, append_to_response: append_fields)
164
+ end
165
+ end
166
+
167
+ it 'should return credits' do
168
+ @tv.credits.cast.size.should == 7
169
+ @tv.credits.cast.first.id.should == 17419
170
+ @tv.credits.crew.size.should == 4
171
+ @tv.credits.crew.first.id.should == 5162
172
+ end
173
+
174
+ it 'should return external_ids' do
175
+ @tv.external_ids.imdb_id.should == 'tt0903747'
176
+ end
177
+ end
178
+
179
+ describe "For popular TV shows" do
180
+
181
+ before(:each) do
182
+ VCR.use_cassette 'tv/popular' do
183
+ @tv = Tmdb::TV.popular
184
+ end
185
+ end
186
+
187
+ it "should return an array" do
188
+ @tv.class.should == Array
189
+ end
190
+
191
+ it "each show should return an id" do
192
+ @tv.first.id.should == 57243
193
+ end
194
+
195
+ it "each show should return an name" do
196
+ @tv.first.name.should == "Doctor Who"
197
+ end
198
+
199
+ it "each show should return an original name" do
200
+ @tv.first.original_name.should == "Doctor Who"
201
+ end
202
+
203
+ it "each show should return an popularity" do
204
+ @tv.first.popularity.should == 16.5167252220739
205
+ end
206
+
207
+ it "each show should return an poster_path" do
208
+ @tv.first.poster_path.should == "/4a94ptIdYz0JwSzo0dCNuPCcfM8.jpg"
209
+ end
210
+
211
+ it "each show should return an vote_average" do
212
+ @tv.first.vote_average.should == 7.875
213
+ end
214
+
215
+ it "each show should return an vote_count" do
216
+ @tv.first.vote_count.should == 4
217
+ end
218
+
219
+ it "each show should return an backdrop" do
220
+ @tv.first.backdrop_path.should == nil
221
+ end
222
+
223
+ it "each show should return an first air date" do
224
+ @tv.first.first_air_date.should == "2005-03-26"
225
+ end
226
+
227
+ end
228
+
229
+ describe "For top rated TV shows" do
230
+
231
+ before(:each) do
232
+ VCR.use_cassette 'tv/top_rated' do
233
+ @tv = Tmdb::TV.top_rated
234
+ end
235
+ end
236
+
237
+ it "should return an array" do
238
+ @tv.class.should == Array
239
+ end
240
+
241
+ it "each show should return an id" do
242
+ @tv.first.id.should == 1104
243
+ end
244
+
245
+ it "each show should return an name" do
246
+ @tv.first.name.should == "Mad Men"
247
+ end
248
+
249
+ it "each show should return an original name" do
250
+ @tv.first.original_name.should == "Mad Men"
251
+ end
252
+
253
+ it "each show should return an popularity" do
254
+ @tv.first.popularity.should == 2.15615937122719
255
+ end
256
+
257
+ it "each show should return an poster_path" do
258
+ @tv.first.poster_path.should == "/xA2nHrx2oHGPnL4ehBwPxD0ABvb.jpg"
259
+ end
260
+
261
+ it "each show should return an vote_average" do
262
+ @tv.first.vote_average.should == 9.66666666666667
263
+ end
264
+
265
+ it "each show should return an vote_count" do
266
+ @tv.first.vote_count.should == 3
267
+ end
268
+
269
+ it "each show should return an backdrop" do
270
+ @tv.first.backdrop_path.should == "/yGW0NX3I8GXPlWPdoWWyaH0AsCk.jpg"
271
+ end
272
+
273
+ it "each show should return an first air date" do
274
+ @tv.first.first_air_date.should == "2007-07-19"
275
+ end
276
+
277
+ end
278
+
279
+ describe "For a TV shows images" do
280
+
281
+ describe "For backdrops" do
282
+
283
+ before(:each) do
284
+ VCR.use_cassette 'tv/images' do
285
+ @backdrop = Tmdb::TV.images(1396).backdrops.first
286
+ end
287
+ end
288
+
289
+ it "should return a aspect ratio" do
290
+ @backdrop.aspect_ratio.should == 1.78
291
+ end
292
+
293
+ it "should return a file path" do
294
+ @backdrop.file_path.should == "/dRaV8HGx7Z9xmw77qSs8prp5OuI.jpg"
295
+ end
296
+
297
+ it "should return a height" do
298
+ @backdrop.height.should == 720
299
+ end
300
+
301
+ it "should return a iso code" do
302
+ @backdrop.iso_639_1.should == nil
303
+ end
304
+
305
+ it "should return a vote average" do
306
+ @backdrop.vote_average.should == 0.0
307
+ end
308
+
309
+ it "should return a vote count" do
310
+ @backdrop.vote_count.should == 0.0
311
+ end
312
+
313
+ it "should return a width" do
314
+ @backdrop.width.should == 1280
315
+ end
316
+
317
+ end
318
+
319
+ describe "For posters" do
320
+
321
+ before(:each) do
322
+ VCR.use_cassette 'tv/images' do
323
+ @poster = Tmdb::TV.images(1396).posters.first
324
+ end
325
+ end
326
+
327
+ it "should return a aspect ratio" do
328
+ @poster.aspect_ratio.should == 1.0
329
+ end
330
+
331
+ it "should return a file path" do
332
+ @poster.file_path.should == "/lVbofIPlw3kYa8FQgHT7GtWMI2Q.jpg"
333
+ end
334
+
335
+ it "should return a height" do
336
+ @poster.height.should == 1000
337
+ end
338
+
339
+ it "should return a iso code" do
340
+ @poster.iso_639_1.should == "nl"
341
+ end
342
+
343
+ it "should return a vote average" do
344
+ @poster.vote_average.should == 5.3125
345
+ end
346
+
347
+ it "should return a vote count" do
348
+ @poster.vote_count.should == 1
349
+ end
350
+
351
+ it "should return a width" do
352
+ @poster.width.should == 1000
353
+ end
354
+
355
+ end
356
+
357
+ end
358
+
359
+ describe "For a TV shows cast" do
360
+
361
+ before(:each) do
362
+ VCR.use_cassette 'tv/cast' do
363
+ @cast = Tmdb::TV.cast(1396).first
364
+ end
365
+ end
366
+
367
+ it "should return a id" do
368
+ @cast.id.should == 17419
369
+ end
370
+
371
+ it "should return a name" do
372
+ @cast.name.should == "Bryan Cranston"
373
+ end
374
+
375
+ it "should return a order" do
376
+ @cast.order.should == 0
377
+ end
378
+
379
+ it "should return a profile image" do
380
+ @cast.profile_path.should == "/qXWgFCk4OJqmLRUBEj7cbp8dnkx.jpg"
381
+ end
382
+
383
+ it "should return a character name" do
384
+ @cast.character.should == "Walter White"
385
+ end
386
+
387
+ it "should return a credit id" do
388
+ @cast.credit_id.should == "52542282760ee313280017f9"
389
+ end
390
+
391
+ end
392
+
393
+ describe "For a TV shows crew" do
394
+
395
+ before(:each) do
396
+ VCR.use_cassette 'tv/crew' do
397
+ @crew = Tmdb::TV.crew(1396).first
398
+ end
399
+ end
400
+
401
+ it "should return a id" do
402
+ @crew.id.should == 29779
403
+ end
404
+
405
+ it "should return a department" do
406
+ @crew.department.should == "Production"
407
+ end
408
+
409
+ it "should return a job" do
410
+ @crew.job.should == "Executive Producer"
411
+ end
412
+
413
+ it "should return a name" do
414
+ @crew.name.should == "Michelle MacLaren"
415
+ end
416
+
417
+ it "should return a profile image" do
418
+ @crew.profile_path.should == nil
419
+ end
420
+
421
+ end
422
+
423
+ describe "For a TV shows external ids" do
424
+
425
+ before(:each) do
426
+ VCR.use_cassette 'tv/external_ids' do
427
+ @external = Tmdb::TV.external_ids(1396)
428
+ end
429
+ end
430
+
431
+ it "should return a id" do
432
+ @external.id.should == 1396
433
+ end
434
+
435
+ it "should return a imdb id" do
436
+ @external.imdb_id.should == "tt0903747"
437
+ end
438
+
439
+ it "should return a tvdb id" do
440
+ @external.tvdb_id.should == 81189
441
+ end
442
+
443
+ it "should return a tvrage id" do
444
+ @external.tvrage_id.should == 18164
445
+ end
446
+
447
+ it "should return a freebase id" do
448
+ @external.freebase_id.should == "/en/breaking_bad"
449
+ end
450
+
451
+ it "should return a freebase mid" do
452
+ @external.freebase_mid.should == "/m/03d34x8"
453
+ end
454
+
455
+
456
+ end
457
+
458
+ end