thetvdb_party 0.0.12.pre → 0.0.13.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -2
- data/lib/thetvdb_party/actor.rb +15 -5
- data/lib/thetvdb_party/banner.rb +98 -21
- data/lib/thetvdb_party/baseepisoderecord.rb +88 -17
- data/lib/thetvdb_party/baseseriesrecord.rb +46 -10
- data/lib/thetvdb_party/client.rb +4 -2
- data/lib/thetvdb_party/searchseriesrecord.rb +24 -13
- data/lib/thetvdb_party/version.rb +1 -1
- data/spec/thetvdb_party/actor_spec.rb +15 -15
- data/spec/thetvdb_party/banner_spec.rb +54 -48
- data/spec/thetvdb_party/baseepisoderecord_spec.rb +404 -6
- data/spec/thetvdb_party/baseseriesrecord_spec.rb +366 -12
- data/spec/thetvdb_party/client_spec.rb +27 -0
- data/spec/thetvdb_party/searchseriesrecord_spec.rb +138 -0
- data/spec/thetvdb_party_spec.rb +16 -7
- data/thetvdb_party.gemspec +1 -0
- metadata +20 -2
data/lib/thetvdb_party/client.rb
CHANGED
@@ -22,8 +22,10 @@ module TheTvDbParty
|
|
22
22
|
@language = nil
|
23
23
|
|
24
24
|
# Creates a new TheTvDb client with the given API key
|
25
|
-
#
|
26
|
-
|
25
|
+
# Parameters::
|
26
|
+
# +apikey+:: Optional. The API key to use when accessing the ThTvDb programmers API
|
27
|
+
# Remarks:: if +apikey+ is +nil+, only the #get_series and #search methods will work, as they do not require an API key.
|
28
|
+
def initialize(apikey = nil)
|
27
29
|
@apikey = apikey
|
28
30
|
end
|
29
31
|
|
@@ -54,19 +54,30 @@ module TheTvDbParty
|
|
54
54
|
|
55
55
|
private
|
56
56
|
def read_hash_values
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
57
|
+
begin
|
58
|
+
@id = @hashValues["id"] ? Integer(@hashValues["id"]) : -1
|
59
|
+
rescue ArgumentError
|
60
|
+
@id = -1
|
61
|
+
end
|
62
|
+
begin
|
63
|
+
@seriesid = @hashValues["seriesid"] ? Integer(@hashValues["seriesid"]) : -1
|
64
|
+
rescue ArgumentError
|
65
|
+
@seriesid = -1
|
66
|
+
end
|
67
|
+
@language = @hashValues["language"]
|
68
|
+
@seriesname = @hashValues["SeriesName"]
|
69
|
+
@aliasnames = @hashValues["AliasNames"] ? @hashValues["AliasNames"].split('|').reject { |a| a.nil? || a.empty? } : []
|
70
|
+
@bannerpath_relative = @hashValues["banner"]
|
71
|
+
@overview = @hashValues["Overview"]
|
72
|
+
begin
|
73
|
+
@firstaired = @hashValues["FirstAired"] ? Date.parse(@hashValues["FirstAired"]) : nil
|
74
|
+
rescue ArgumentError
|
75
|
+
@firstaired = nil
|
76
|
+
end
|
77
|
+
@imdb_id = @hashValues["IMDB_ID"]
|
78
|
+
@zap2it_id = @hashValues["zap2it_id"]
|
79
|
+
@network = @hashValues["Network"]
|
80
|
+
@bannerpath_full = bannerpath_relative ? URI::join(BASE_URL, "banners/", bannerpath_relative) : nil
|
70
81
|
|
71
82
|
nil
|
72
83
|
end
|
@@ -26,16 +26,16 @@ describe 'TheTvDbParty::Actor' do
|
|
26
26
|
|
27
27
|
it 'should have a relative/full image path' do
|
28
28
|
record = TheTvDbParty::Actor.new(nil, { "Image" => "actors/27747.jpg" })
|
29
|
-
expect(record.
|
30
|
-
expect(record.
|
31
|
-
expect(record.
|
32
|
-
expect(record.
|
29
|
+
expect(record.image_path_relative).to be_an_instance_of(String)
|
30
|
+
expect(record.image_path_full).to be_a(URI::Generic)
|
31
|
+
expect(record.image_path_relative).to eq("actors/27747.jpg")
|
32
|
+
expect(record.image_path_full).to eq(URI::join(TheTvDbParty::BASE_URL, 'banners/', 'actors/27747.jpg'))
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should have a nil relative/full image path, if not specified' do
|
36
36
|
record = TheTvDbParty::Actor.new(nil, {})
|
37
|
-
expect(record.
|
38
|
-
expect(record.
|
37
|
+
expect(record.image_path_relative).to be_nil
|
38
|
+
expect(record.image_path_full).to be_nil
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should have a name field' do
|
@@ -51,23 +51,23 @@ describe 'TheTvDbParty::Actor' do
|
|
51
51
|
|
52
52
|
it 'should have a sorting order between 0-3' do
|
53
53
|
record = TheTvDbParty::Actor.new(nil, { "SortOrder" => "2" })
|
54
|
-
expect(record.
|
55
|
-
expect(record.
|
56
|
-
expect(record.
|
54
|
+
expect(record.sort_order).to be_an_instance_of(Fixnum)
|
55
|
+
expect(record.sort_order).to be_between(0, 3).inclusive
|
56
|
+
expect(record.sort_order).to eq(2)
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'should have a 0 sorting order, if invalid specified' do
|
60
60
|
record = TheTvDbParty::Actor.new(nil, { "SortOrder" => "INVALID_SORT_ORDER" })
|
61
|
-
expect(record.
|
62
|
-
expect(record.
|
63
|
-
expect(record.
|
61
|
+
expect(record.sort_order).to be_an_instance_of(Fixnum)
|
62
|
+
expect(record.sort_order).to be_between(0, 3).inclusive
|
63
|
+
expect(record.sort_order).to eq(0)
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'should have a 0 sorting order, if invalid specified' do
|
67
67
|
record = TheTvDbParty::Actor.new(nil, { })
|
68
|
-
expect(record.
|
69
|
-
expect(record.
|
70
|
-
expect(record.
|
68
|
+
expect(record.sort_order).to be_an_instance_of(Fixnum)
|
69
|
+
expect(record.sort_order).to be_between(0, 3).inclusive
|
70
|
+
expect(record.sort_order).to eq(0)
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should not instantiate when created without hash values' do
|
@@ -26,62 +26,62 @@ describe 'TheTvDbParty::Banner' do
|
|
26
26
|
|
27
27
|
it 'should have a relative/full banner path' do
|
28
28
|
record = TheTvDbParty::Banner.new(nil, { "BannerPath" => "text/80348.jpg" })
|
29
|
-
expect(record.
|
30
|
-
expect(record.
|
31
|
-
expect(record.
|
32
|
-
expect(record.
|
29
|
+
expect(record.banner_path_relative).to be_an_instance_of(String)
|
30
|
+
expect(record.banner_path_full).to be_a(URI::Generic)
|
31
|
+
expect(record.banner_path_relative).to eq("text/80348.jpg")
|
32
|
+
expect(record.banner_path_full).to eq(URI::join(TheTvDbParty::BASE_URL, 'banners/', "text/80348.jpg"))
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should have a nil relative/full banner path, if not specified' do
|
36
36
|
record = TheTvDbParty::Banner.new(nil, {})
|
37
|
-
expect(record.
|
38
|
-
expect(record.
|
37
|
+
expect(record.banner_path_relative).to be_nil
|
38
|
+
expect(record.banner_path_full).to be_nil
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should have a relative/full thumbnail path' do
|
42
42
|
record = TheTvDbParty::Banner.new(nil, { "ThumbnailPath" => "_cache/fanart/original/80348-49.jpg" })
|
43
|
-
expect(record.
|
44
|
-
expect(record.
|
45
|
-
expect(record.
|
46
|
-
expect(record.
|
43
|
+
expect(record.thumbnail_path_relative).to be_an_instance_of(String)
|
44
|
+
expect(record.thumbnail_path_full).to be_a(URI::Generic)
|
45
|
+
expect(record.thumbnail_path_relative).to eq("_cache/fanart/original/80348-49.jpg")
|
46
|
+
expect(record.thumbnail_path_full).to eq(URI::join(TheTvDbParty::BASE_URL, 'banners/', "_cache/fanart/original/80348-49.jpg"))
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should have a nil relative/full thumbnail path, if not specified' do
|
50
50
|
record = TheTvDbParty::Banner.new(nil, {})
|
51
|
-
expect(record.
|
52
|
-
expect(record.
|
51
|
+
expect(record.thumbnail_path_relative).to be_nil
|
52
|
+
expect(record.thumbnail_path_full).to be_nil
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'should have a relative/full vignette path' do
|
56
56
|
record = TheTvDbParty::Banner.new(nil, { "VignettePath" => "fanart/vignette/80348-49.jpg" })
|
57
|
-
expect(record.
|
58
|
-
expect(record.
|
59
|
-
expect(record.
|
60
|
-
expect(record.
|
57
|
+
expect(record.vignette_path_relative).to be_an_instance_of(String)
|
58
|
+
expect(record.vignette_path_full).to be_a(URI::Generic)
|
59
|
+
expect(record.vignette_path_relative).to eq("fanart/vignette/80348-49.jpg")
|
60
|
+
expect(record.vignette_path_full).to eq(URI::join(TheTvDbParty::BASE_URL, 'banners/', "fanart/vignette/80348-49.jpg"))
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'should have a nil relative/full vignette path, if not specified' do
|
64
64
|
record = TheTvDbParty::Banner.new(nil, {})
|
65
|
-
expect(record.
|
66
|
-
expect(record.
|
65
|
+
expect(record.vignette_path_relative).to be_nil
|
66
|
+
expect(record.vignette_path_full).to be_nil
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should have a banner type' do
|
70
70
|
[ "poster", "fanart", "series", "season" ].each do |expected_valid_bannertype|
|
71
71
|
record = TheTvDbParty::Banner.new(nil, { "BannerType" => expected_valid_bannertype })
|
72
|
-
expect(record.
|
73
|
-
expect(record.
|
72
|
+
expect(record.banner_type).to be_an_instance_of(String)
|
73
|
+
expect(record.banner_type).to eq(expected_valid_bannertype)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'should have a nil banner type, if specified is invalid' do
|
78
78
|
record = TheTvDbParty::Banner.new(nil, { "BannerType" => "INVALID_BANNERTYPE_STRING" })
|
79
|
-
expect(record.
|
79
|
+
expect(record.banner_type).to be_nil
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'should have a nil banner type, if not specified' do
|
83
83
|
record = TheTvDbParty::Banner.new(nil, {})
|
84
|
-
expect(record.
|
84
|
+
expect(record.banner_type).to be_nil
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'should have a secondary banner type' do
|
@@ -93,25 +93,25 @@ describe 'TheTvDbParty::Banner' do
|
|
93
93
|
}.each do |expected_valid_bannertype, expected_valid_bannerytype2s|
|
94
94
|
expected_valid_bannerytype2s.each do |expected_valid_bannerytype2|
|
95
95
|
record = TheTvDbParty::Banner.new(nil, { "BannerType" => expected_valid_bannertype, "BannerType2" => expected_valid_bannerytype2 })
|
96
|
-
expect(record.
|
97
|
-
expect(record.
|
96
|
+
expect(record.banner_type_2).to be_an_instance_of(String)
|
97
|
+
expect(record.banner_type_2).to eq(expected_valid_bannerytype2)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'should have a nil secondary banner type, if the primary banner type is valid, but the specified secondary banner type is invalid' do
|
103
103
|
record = TheTvDbParty::Banner.new(nil, { "BannerType" => "poster", "BannerType2" => "abcdef" })
|
104
|
-
expect(record.
|
104
|
+
expect(record.banner_type_2).to be_nil
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'should have a nil secondary banner type, if the primary banner type is valid, but the specified secondary banner type is invalid for that primary banner type' do
|
108
108
|
record = TheTvDbParty::Banner.new(nil, { "BannerType" => "poster", "BannerType2" => "seasonwide" })
|
109
|
-
expect(record.
|
109
|
+
expect(record.banner_type_2).to be_nil
|
110
110
|
end
|
111
111
|
|
112
112
|
it 'should have a nil secondary banner type, if the primary banner type is nil' do
|
113
113
|
record = TheTvDbParty::Banner.new(nil, { "BannerType2" => "seasonwide" })
|
114
|
-
expect(record.
|
114
|
+
expect(record.banner_type_2).to be_nil
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'should have a language associated with it' do
|
@@ -144,6 +144,12 @@ describe 'TheTvDbParty::Banner' do
|
|
144
144
|
expect(record.rating).to be 6.6667
|
145
145
|
end
|
146
146
|
|
147
|
+
it 'should have a zero rating, if invalid specified' do
|
148
|
+
record = TheTvDbParty::Banner.new(nil, { "Rating" => "INVALID_RATING" })
|
149
|
+
expect(record.rating).to be_an_instance_of(Float)
|
150
|
+
expect(record.rating).to be 0.0
|
151
|
+
end
|
152
|
+
|
147
153
|
it 'should have a zero rating, if it is not specified' do
|
148
154
|
record = TheTvDbParty::Banner.new(nil, { })
|
149
155
|
expect(record.rating).to be_an_instance_of(Float)
|
@@ -152,41 +158,41 @@ describe 'TheTvDbParty::Banner' do
|
|
152
158
|
|
153
159
|
it 'should have a rating count' do
|
154
160
|
record = TheTvDbParty::Banner.new(nil, { "RatingCount" => "6" })
|
155
|
-
expect(record.
|
156
|
-
expect(record.
|
157
|
-
expect(record.
|
161
|
+
expect(record.rating_count).to be_an_instance_of(Fixnum)
|
162
|
+
expect(record.rating_count).to be >= 0
|
163
|
+
expect(record.rating_count).to eq(6)
|
158
164
|
end
|
159
165
|
|
160
166
|
it 'should have a zero rating count, if it is not specified' do
|
161
167
|
record = TheTvDbParty::Banner.new(nil, { })
|
162
|
-
expect(record.
|
163
|
-
expect(record.
|
168
|
+
expect(record.rating_count).to be_an_instance_of(Fixnum)
|
169
|
+
expect(record.rating_count).to be 0
|
164
170
|
end
|
165
171
|
|
166
172
|
it 'should have a true series name flag' do
|
167
173
|
record = TheTvDbParty::Banner.new(nil, { "BannerType" => "fanart", "SeriesName" => "true" })
|
168
|
-
expect(record.
|
169
|
-
expect(record.
|
174
|
+
expect(record.series_name).to be_an_instance_of(TrueClass).or be_an_instance_of(FalseClass)
|
175
|
+
expect(record.series_name).to be true
|
170
176
|
end
|
171
177
|
|
172
178
|
it 'should have a false series name flag, if banner type is not fanart' do
|
173
179
|
[ "poster", "series", "season" ].each do |expected_valid_bannertype|
|
174
180
|
record = TheTvDbParty::Banner.new(nil, { "BannerType" => expected_valid_bannertype, "SeriesName" => "true" })
|
175
|
-
expect(record.
|
176
|
-
expect(record.
|
181
|
+
expect(record.series_name).to be_an_instance_of(TrueClass).or be_an_instance_of(FalseClass)
|
182
|
+
expect(record.series_name).to be false
|
177
183
|
end
|
178
184
|
end
|
179
185
|
|
180
186
|
it 'should have a false series name flag, if it is not specified' do
|
181
|
-
record = TheTvDbParty::Banner.new(nil, { "BannerType" => "fanart"
|
182
|
-
expect(record.
|
183
|
-
expect(record.
|
187
|
+
record = TheTvDbParty::Banner.new(nil, { "BannerType" => "fanart" })
|
188
|
+
expect(record.series_name).to be_an_instance_of(TrueClass).or be_an_instance_of(FalseClass)
|
189
|
+
expect(record.series_name).to be false
|
184
190
|
end
|
185
191
|
|
186
192
|
it 'should have a zero rating count, if it is not specified' do
|
187
193
|
record = TheTvDbParty::Banner.new(nil, { })
|
188
|
-
expect(record.
|
189
|
-
expect(record.
|
194
|
+
expect(record.rating_count).to be_an_instance_of(Fixnum)
|
195
|
+
expect(record.rating_count).to be 0
|
190
196
|
end
|
191
197
|
|
192
198
|
it 'should have the color fields' do
|
@@ -195,36 +201,36 @@ describe 'TheTvDbParty::Banner' do
|
|
195
201
|
expect(record.light_accent_color).to match_array([81, 81, 81])
|
196
202
|
expect(record.dark_accent_color).to be_an_instance_of(Array)
|
197
203
|
expect(record.dark_accent_color).to match_array([15, 15, 15])
|
198
|
-
expect(record.
|
199
|
-
expect(record.
|
204
|
+
expect(record.neutral_midtone_color).to be_an_instance_of(Array)
|
205
|
+
expect(record.neutral_midtone_color).to match_array([201, 226, 246])
|
200
206
|
end
|
201
207
|
|
202
208
|
it 'should have nil color fields, if banner type is not fanart' do
|
203
209
|
record = TheTvDbParty::Banner.new(nil, { "Colors" => "|81,81,81|15,15,15|201,226,246|" })
|
204
210
|
expect(record.light_accent_color).to be_nil
|
205
211
|
expect(record.dark_accent_color).to be_nil
|
206
|
-
expect(record.
|
212
|
+
expect(record.neutral_midtone_color).to be_nil
|
207
213
|
end
|
208
214
|
|
209
215
|
it 'should have nil color fields, if invalid colors are specified' do
|
210
216
|
record = TheTvDbParty::Banner.new(nil, { "Colors" => "INVALID_COLORS" })
|
211
217
|
expect(record.light_accent_color).to be_nil
|
212
218
|
expect(record.dark_accent_color).to be_nil
|
213
|
-
expect(record.
|
219
|
+
expect(record.neutral_midtone_color).to be_nil
|
214
220
|
end
|
215
221
|
|
216
222
|
it 'should have nil color fields, if no colors are specified' do
|
217
223
|
record = TheTvDbParty::Banner.new(nil, { })
|
218
224
|
expect(record.light_accent_color).to be_nil
|
219
225
|
expect(record.dark_accent_color).to be_nil
|
220
|
-
expect(record.
|
226
|
+
expect(record.neutral_midtone_color).to be_nil
|
221
227
|
end
|
222
228
|
|
223
229
|
it 'should have nil color fields, if colors are specified, but at least one of the colors does not have exactly three elements' do
|
224
|
-
record = TheTvDbParty::Banner.new(nil, { "Colors" => "|81,81,81,4|15,15,15|201,226,246|" })
|
230
|
+
record = TheTvDbParty::Banner.new(nil, { "BannerType" => "fanart", "Colors" => "|81,81,81,4|15,15,15|201,226,246|" })
|
225
231
|
expect(record.light_accent_color).to be_nil
|
226
232
|
expect(record.dark_accent_color).to be_nil
|
227
|
-
expect(record.
|
233
|
+
expect(record.neutral_midtone_color).to be_nil
|
228
234
|
end
|
229
235
|
|
230
236
|
it 'should not instantiate when created without hash values' do
|
@@ -109,20 +109,20 @@ describe 'TheTvDbParty::BaseEpisodeRecord' do
|
|
109
109
|
|
110
110
|
it 'should have a DVD season number' do
|
111
111
|
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "DVD_season" => "1" })
|
112
|
-
expect(record.
|
113
|
-
expect(record.
|
112
|
+
expect(record.dvd_season).to be_an_instance_of(Fixnum)
|
113
|
+
expect(record.dvd_season).to eq(1)
|
114
114
|
end
|
115
115
|
|
116
116
|
it 'should have a negative DVD season number, if invalid specified' do
|
117
117
|
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "DVD_season" => "INVALID_DVD_SEASON" })
|
118
|
-
expect(record.
|
119
|
-
expect(record.
|
118
|
+
expect(record.dvd_season).to be_an_instance_of(Fixnum)
|
119
|
+
expect(record.dvd_season).to be < 0
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'should have a negative DVD season number, if not specified' do
|
123
123
|
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
124
|
-
expect(record.
|
125
|
-
expect(record.
|
124
|
+
expect(record.dvd_season).to be_an_instance_of(Fixnum)
|
125
|
+
expect(record.dvd_season).to be < 0
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'should have a single element array for the director, if only one name is specified' do
|
@@ -145,6 +145,404 @@ describe 'TheTvDbParty::BaseEpisodeRecord' do
|
|
145
145
|
expect(record.director).to be_empty
|
146
146
|
end
|
147
147
|
|
148
|
+
it 'should have a episode image flag' do
|
149
|
+
(1..6).to_a.each do |expected_valid_epimgflag|
|
150
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "EpImgFlag" => expected_valid_epimgflag.to_s })
|
151
|
+
expect(record.epimgflag).to be_an_instance_of(Fixnum)
|
152
|
+
expect(record.epimgflag).to eq(expected_valid_epimgflag)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should have a zero episode image flag, if invalid specified' do
|
157
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "EpImgFlag" => "INVALID_EPIMGFLAG" })
|
158
|
+
expect(record.epimgflag).to be_an_instance_of(Fixnum)
|
159
|
+
expect(record.epimgflag).to eq(0)
|
160
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "EpImgFlag" => "9" })
|
161
|
+
expect(record.epimgflag).to be_an_instance_of(Fixnum)
|
162
|
+
expect(record.epimgflag).to eq(0)
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'should have a zero episode image flag, if not specified' do
|
166
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
167
|
+
expect(record.epimgflag).to be_an_instance_of(Fixnum)
|
168
|
+
expect(record.epimgflag).to eq(0)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should have an episode name' do
|
172
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "EpisodeName" => "White Orchids" })
|
173
|
+
expect(record.episodename).to be_an_instance_of(String)
|
174
|
+
expect(record.episodename).to eq("White Orchids")
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'should have a nil episode name, if not specified' do
|
178
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
179
|
+
expect(record.episodename).to be_nil
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should have an episode number' do
|
183
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "EpisodeNumber" => "1" })
|
184
|
+
expect(record.episodenumber).to be_an_instance_of(Fixnum)
|
185
|
+
expect(record.episodenumber).to eq(1)
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should have a negative episode number, if invalid specified' do
|
189
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "EpisodeNumber" => "INVALID_EPISODENUMBER" })
|
190
|
+
expect(record.episodenumber).to be_an_instance_of(Fixnum)
|
191
|
+
expect(record.episodenumber).to be < 0
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'should have a negative episode number, if not specified' do
|
195
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
196
|
+
expect(record.episodenumber).to be_an_instance_of(Fixnum)
|
197
|
+
expect(record.episodenumber).to be < 0
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'should have a first aired date' do
|
201
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "FirstAired" => "2009-11-15" })
|
202
|
+
expect(record.firstaired).to be_an_instance_of(Date)
|
203
|
+
expect(record.firstaired).to eq(Date.new(2009, 11, 15))
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'should have a nil first aired date, if invalid specified' do
|
207
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "FirstAired" => "INVALID_FIRSTAIRED" })
|
208
|
+
expect(record.firstaired).to be_nil
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'should have a nil first aired date, if not specified' do
|
212
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
213
|
+
expect(record.firstaired).to be_nil
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'should have a single element array for the guest stars, if only one name is specified' do
|
217
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "GuestStars" => "Lindsay Duncan" })
|
218
|
+
expect(record.gueststars).to match_array(["Lindsay Duncan"])
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'should have a multi element array for the guest stars, if a pipe-delimited list is specified' do
|
222
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "GuestStars" => "Lindsay Duncan|Peter O'Brien|Sharon Duncan Brewster" })
|
223
|
+
expect(record.gueststars).to match_array(["Lindsay Duncan", "Peter O'Brien", "Sharon Duncan Brewster"])
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'should have a multi element array for the guest stars, if a pipe-surrounded list is specified' do
|
227
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "GuestStars" => "|Lindsay Duncan|Peter O'Brien|Sharon Duncan Brewster|" })
|
228
|
+
expect(record.gueststars).to match_array(["Lindsay Duncan", "Peter O'Brien", "Sharon Duncan Brewster"])
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should have an empty array for guest stars, if none is specified' do
|
232
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
233
|
+
expect(record.gueststars).to be_empty
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'should have an IMDB id' do
|
237
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"IMDB_ID" => "abcd1234"})
|
238
|
+
expect(record.imdb_id).to be_an_instance_of(String)
|
239
|
+
expect(record.imdb_id).to eq("abcd1234")
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'should have a nil IMDB id, if none specified' do
|
243
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
244
|
+
expect(record.imdb_id).to be_nil
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'should have a language associated with the record' do
|
248
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"Language" => "en"})
|
249
|
+
expect(record.language).to be_a(String)
|
250
|
+
expect(record.language).to eq("en")
|
251
|
+
end
|
252
|
+
|
253
|
+
it 'should have a nil language associated with the record, if not specified' do
|
254
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {})
|
255
|
+
expect(record.language).to be_nil
|
256
|
+
end
|
257
|
+
|
258
|
+
it 'should have an overview' do
|
259
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"Overview" => "Location: Bowie Base One, Mars Date: 21st November 2059 Enemies: The Flood The Doctor..."})
|
260
|
+
expect(record.overview).to be_a(String)
|
261
|
+
expect(record.overview).to eq("Location: Bowie Base One, Mars Date: 21st November 2059 Enemies: The Flood The Doctor...")
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'should have a nil overview, if not specified' do
|
265
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
266
|
+
expect(record.overview).to be_nil
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'should have an production code' do
|
270
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"ProductionCode" => "abcd1234"})
|
271
|
+
expect(record.productioncode).to be_an_instance_of(String)
|
272
|
+
expect(record.productioncode).to eq("abcd1234")
|
273
|
+
end
|
274
|
+
|
275
|
+
it 'should have a nil production code, if none specified' do
|
276
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
277
|
+
expect(record.productioncode).to be_nil
|
278
|
+
end
|
279
|
+
|
280
|
+
it 'should have a rating' do
|
281
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "Rating" => "6.6667" })
|
282
|
+
expect(record.rating).to be_an_instance_of(Float)
|
283
|
+
expect(record.rating).to be >= 0.0
|
284
|
+
expect(record.rating).to be 6.6667
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'should have a zero rating, if invalid specified' do
|
288
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "Rating" => "INVALID_RATING" })
|
289
|
+
expect(record.rating).to be_an_instance_of(Float)
|
290
|
+
expect(record.rating).to be 0.0
|
291
|
+
end
|
292
|
+
|
293
|
+
it 'should have a zero rating, if it is not specified' do
|
294
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
295
|
+
expect(record.rating).to be_an_instance_of(Float)
|
296
|
+
expect(record.rating).to be 0.0
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'should have a rating count' do
|
300
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "RatingCount" => "6" })
|
301
|
+
expect(record.ratingcount).to be_an_instance_of(Fixnum)
|
302
|
+
expect(record.ratingcount).to be >= 0
|
303
|
+
expect(record.ratingcount).to eq(6)
|
304
|
+
end
|
305
|
+
|
306
|
+
it 'should have a zero rating count, if invalid specified' do
|
307
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "RatingCount" => "INVALID_RATINGCOUNT" })
|
308
|
+
expect(record.ratingcount).to be_an_instance_of(Fixnum)
|
309
|
+
expect(record.ratingcount).to be 0
|
310
|
+
end
|
311
|
+
|
312
|
+
it 'should have a zero rating count, if it is not specified' do
|
313
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
314
|
+
expect(record.ratingcount).to be_an_instance_of(Fixnum)
|
315
|
+
expect(record.ratingcount).to be 0
|
316
|
+
end
|
317
|
+
|
318
|
+
it 'should have an season number' do
|
319
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "SeasonNumber" => "1" })
|
320
|
+
expect(record.seasonnumber).to be_an_instance_of(Fixnum)
|
321
|
+
expect(record.seasonnumber).to eq(1)
|
322
|
+
end
|
323
|
+
|
324
|
+
it 'should have a negative season number, if invalid specified' do
|
325
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "SeasonNumber" => "INVALID_SEASONNUMBER" })
|
326
|
+
expect(record.seasonnumber).to be_an_instance_of(Fixnum)
|
327
|
+
expect(record.seasonnumber).to be < 0
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'should have a negative season number, if not specified' do
|
331
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
332
|
+
expect(record.seasonnumber).to be_an_instance_of(Fixnum)
|
333
|
+
expect(record.seasonnumber).to be < 0
|
334
|
+
end
|
335
|
+
|
336
|
+
it 'should have a single element array for the writer, if only one name is specified' do
|
337
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "Writer" => "Russell T Davies" })
|
338
|
+
expect(record.writer).to match_array(["Russell T Davies"])
|
339
|
+
end
|
340
|
+
|
341
|
+
it 'should have a multi element array for the writer, if a pipe-delimited list is specified' do
|
342
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "Writer" => "Russell T Davies|Phil Ford" })
|
343
|
+
expect(record.writer).to match_array(["Russell T Davies", "Phil Ford"])
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'should have a multi element array for the writer, if a pipe-surrounded list is specified' do
|
347
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "Writer" => "|Russell T Davies|Phil Ford|" })
|
348
|
+
expect(record.writer).to match_array(["Russell T Davies", "Phil Ford"])
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'should have an empty array for writer, if none is specified' do
|
352
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
353
|
+
expect(record.writer).to be_empty
|
354
|
+
end
|
355
|
+
|
356
|
+
it 'should have an absolute number' do
|
357
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"absolute_number" => "151"})
|
358
|
+
expect(record.absolute_number).to be_a(Fixnum)
|
359
|
+
expect(record.absolute_number).to eq(151)
|
360
|
+
end
|
361
|
+
|
362
|
+
it 'should have a negative absolute number, if invalid specified' do
|
363
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"absolute_number" => "INVALID_ABSOLUTENUMBER"})
|
364
|
+
expect(record.absolute_number).to be_a(Fixnum)
|
365
|
+
expect(record.absolute_number).to be < 0
|
366
|
+
end
|
367
|
+
|
368
|
+
it 'should have a negative absolute number, if not specified' do
|
369
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
370
|
+
expect(record.absolute_number).to be_a(Fixnum)
|
371
|
+
expect(record.absolute_number).to be < 0
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'should have an airs after season number' do
|
375
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"airsafter_season" => "2"})
|
376
|
+
expect(record.airsafter_season).to be_a(Fixnum)
|
377
|
+
expect(record.airsafter_season).to eq(2)
|
378
|
+
end
|
379
|
+
|
380
|
+
it 'should have a negative airs after season number, if invalid specified' do
|
381
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"airsafter_season" => "INVALID_AIRSAFTER_SEASON"})
|
382
|
+
expect(record.airsafter_season).to be_a(Fixnum)
|
383
|
+
expect(record.airsafter_season).to be < 0
|
384
|
+
end
|
385
|
+
|
386
|
+
it 'should have a negative airs after season number, if not specified' do
|
387
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
388
|
+
expect(record.airsafter_season).to be_a(Fixnum)
|
389
|
+
expect(record.airsafter_season).to be < 0
|
390
|
+
end
|
391
|
+
|
392
|
+
it 'should have an airs before episode number' do
|
393
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"airsbefore_episode" => "2"})
|
394
|
+
expect(record.airsbefore_episode).to be_a(Fixnum)
|
395
|
+
expect(record.airsbefore_episode).to eq(2)
|
396
|
+
end
|
397
|
+
|
398
|
+
it 'should have a negative airs before episode number, if invalid specified' do
|
399
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"airsbefore_episode" => "INVALID_AIRSBEFORE_EPISODE"})
|
400
|
+
expect(record.airsbefore_episode).to be_a(Fixnum)
|
401
|
+
expect(record.airsbefore_episode).to be < 0
|
402
|
+
end
|
403
|
+
|
404
|
+
it 'should have a negative airs before episode number, if not specified' do
|
405
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
406
|
+
expect(record.airsbefore_episode).to be_a(Fixnum)
|
407
|
+
expect(record.airsbefore_episode).to be < 0
|
408
|
+
end
|
409
|
+
|
410
|
+
it 'should have an airs before season number' do
|
411
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"airsbefore_season" => "2"})
|
412
|
+
expect(record.airsbefore_season).to be_a(Fixnum)
|
413
|
+
expect(record.airsbefore_season).to eq(2)
|
414
|
+
end
|
415
|
+
|
416
|
+
it 'should have a negative airs before season number, if invalid specified' do
|
417
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"airsbefore_season" => "INVALID_AIRSBEFORE_SEASON"})
|
418
|
+
expect(record.airsbefore_season).to be_a(Fixnum)
|
419
|
+
expect(record.airsbefore_season).to be < 0
|
420
|
+
end
|
421
|
+
|
422
|
+
it 'should have a negative airs before season number, if not specified' do
|
423
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
424
|
+
expect(record.airsbefore_season).to be_a(Fixnum)
|
425
|
+
expect(record.airsbefore_season).to be < 0
|
426
|
+
end
|
427
|
+
|
428
|
+
it 'should have a relative/full episode image path' do
|
429
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"filename" => "episodes/82459/5038185.jpg"})
|
430
|
+
expect(record.imagepath_relative).to be_a(String)
|
431
|
+
expect(record.imagepath_full).to be_a(URI::Generic)
|
432
|
+
expect(record.imagepath_relative).to eq("episodes/82459/5038185.jpg")
|
433
|
+
expect(record.imagepath_full).to eq(URI::join(TheTvDbParty::BASE_URL, 'banners/', "episodes/82459/5038185.jpg"))
|
434
|
+
end
|
435
|
+
|
436
|
+
it 'should have a nil relative/full episode image path, if not specified' do
|
437
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
438
|
+
expect(record.imagepath_relative).to be_nil
|
439
|
+
expect(record.imagepath_full).to be_nil
|
440
|
+
end
|
441
|
+
|
442
|
+
it 'should have a last updated timestamp' do
|
443
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "lastupdated" => "1424691313" })
|
444
|
+
expect(record.lastupdated).to be_a(DateTime)
|
445
|
+
expect(record.lastupdated).to eq(Time.at(1424691313).to_datetime)
|
446
|
+
end
|
447
|
+
|
448
|
+
it 'should have a nil last updated timestamp, if invalid specified' do
|
449
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "lastupdated" => "INVALID_LASTUPDATED" })
|
450
|
+
expect(record.lastupdated).to be_nil
|
451
|
+
end
|
452
|
+
|
453
|
+
it 'should have a nil last updated timestamp, if not specified' do
|
454
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
455
|
+
expect(record.lastupdated).to be_nil
|
456
|
+
end
|
457
|
+
|
458
|
+
it 'should have a season number' do
|
459
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"seasonid" => "2"})
|
460
|
+
expect(record.seasonid).to be_a(Fixnum)
|
461
|
+
expect(record.seasonid).to eq(2)
|
462
|
+
end
|
463
|
+
|
464
|
+
it 'should have a negative season number, if invalid specified' do
|
465
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"seasonid" => "INVALID_SEASONID"})
|
466
|
+
expect(record.seasonid).to be_a(Fixnum)
|
467
|
+
expect(record.seasonid).to be < 0
|
468
|
+
end
|
469
|
+
|
470
|
+
it 'should have a negative airs before season number, if not specified' do
|
471
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
472
|
+
expect(record.seasonid).to be_a(Fixnum)
|
473
|
+
expect(record.seasonid).to be < 0
|
474
|
+
end
|
475
|
+
|
476
|
+
it 'should have a series id' do
|
477
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"seriesid" => "82459"})
|
478
|
+
expect(record.seriesid).to be_a(Fixnum)
|
479
|
+
expect(record.seriesid).to eq(82459)
|
480
|
+
end
|
481
|
+
|
482
|
+
it 'should have a negative series id, if invalid specified' do
|
483
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, {"seriesid" => "INVALID_SERIESID"})
|
484
|
+
expect(record.seriesid).to be_a(Fixnum)
|
485
|
+
expect(record.seriesid).to be < 0
|
486
|
+
end
|
487
|
+
|
488
|
+
it 'should have a negative series id, if not specified' do
|
489
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
490
|
+
expect(record.seriesid).to be_a(Fixnum)
|
491
|
+
expect(record.seriesid).to be < 0
|
492
|
+
end
|
493
|
+
|
494
|
+
it 'should have a thumbnail added date' do
|
495
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "thumb_added" => "2015-02-11 09:28:28" })
|
496
|
+
expect(record.thumb_added).to be_a(DateTime)
|
497
|
+
# expect(record.thumb_added).to eq(DateTime.new(2015, 02, 11, 9, 28, 28))
|
498
|
+
end
|
499
|
+
|
500
|
+
it 'should have a nil thumbnail added date, if invalid specified' do
|
501
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "thumb_added" => "INVALID_THUMB_ADDED" })
|
502
|
+
expect(record.thumb_added).to be_nil
|
503
|
+
end
|
504
|
+
|
505
|
+
it 'should have a nil thumbnail added date, if not specified' do
|
506
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
507
|
+
expect(record.thumb_added).to be_nil
|
508
|
+
end
|
509
|
+
|
510
|
+
it 'should have thumbnail height field' do
|
511
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "thumb_height" => "225" })
|
512
|
+
expect(record.thumb_height).to be_a(Fixnum)
|
513
|
+
expect(record.thumb_height).to eq(225)
|
514
|
+
end
|
515
|
+
|
516
|
+
it 'should have a zero thumbnail height, if invalid specified' do
|
517
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "thumb_width" => "INVALID_THUMB_HEIGHT" })
|
518
|
+
expect(record.thumb_height).to be_a(Fixnum)
|
519
|
+
expect(record.thumb_height).to eq(0)
|
520
|
+
end
|
521
|
+
|
522
|
+
it 'should have a zero thumbnail height, if not specified' do
|
523
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
524
|
+
expect(record.thumb_height).to be_a(Fixnum)
|
525
|
+
expect(record.thumb_height).to eq(0)
|
526
|
+
end
|
527
|
+
|
528
|
+
it 'should have thumbnail width field' do
|
529
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "thumb_width" => "400" })
|
530
|
+
expect(record.thumb_width).to be_a(Fixnum)
|
531
|
+
expect(record.thumb_width).to eq(400)
|
532
|
+
end
|
533
|
+
|
534
|
+
it 'should have a zero thumbnail width, if invalid specified' do
|
535
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { "thumb_width" => "INVALID_THUMB_WIDTH" })
|
536
|
+
expect(record.thumb_width).to be_a(Fixnum)
|
537
|
+
expect(record.thumb_width).to eq(0)
|
538
|
+
end
|
539
|
+
|
540
|
+
it 'should have a zero thumbnail width, if not specified' do
|
541
|
+
record = TheTvDbParty::BaseEpisodeRecord.new(nil, { })
|
542
|
+
expect(record.thumb_width).to be_a(Fixnum)
|
543
|
+
expect(record.thumb_width).to eq(0)
|
544
|
+
end
|
545
|
+
|
148
546
|
it 'should not instantiate when created without hash values' do
|
149
547
|
expect { TheTvDbParty::BaseEpisodeRecord.new(nil, nil) }.to raise_error
|
150
548
|
end
|