royw-imdb 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/imdb/imdb_profile.rb +3 -3
- data/spec/imdb_profile_spec.rb +45 -0
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/imdb/imdb_profile.rb
CHANGED
@@ -161,9 +161,9 @@ class ImdbProfile
|
|
161
161
|
# 5) released years plus/minus a year
|
162
162
|
# 6) no years
|
163
163
|
def self.lookup(titles, media_years, production_years, released_years)
|
164
|
-
media_years = media_years.collect{|y| y > 0 ? y : nil}.uniq.compact unless media_years.blank?
|
165
|
-
production_years = production_years.collect{|y| y > 0 ? y : nil}.uniq.compact unless production_years.blank?
|
166
|
-
released_years = released_years.collect{|y| y > 0 ? y : nil}.uniq.compact unless released_years.blank?
|
164
|
+
media_years = media_years.compact.collect{|y| y.to_i > 0 ? y : nil}.uniq.compact unless media_years.blank?
|
165
|
+
production_years = production_years.compact.collect{|y| y.to_i > 0 ? y : nil}.uniq.compact unless production_years.blank?
|
166
|
+
released_years = released_years.compact.collect{|y| y.to_i > 0 ? y : nil}.uniq.compact unless released_years.blank?
|
167
167
|
idents = []
|
168
168
|
year_sets = []
|
169
169
|
year_sets << media_years unless media_years.blank?
|
data/spec/imdb_profile_spec.rb
CHANGED
@@ -173,6 +173,51 @@ describe "ImdbProfile" do
|
|
173
173
|
profile.should be_nil
|
174
174
|
end
|
175
175
|
|
176
|
+
it "should handle media year == nil" do
|
177
|
+
profile = ImdbProfile.first(:titles => ['National Treasure: Book of Secrets'], :media_years => [nil])
|
178
|
+
profile.should_not == nil
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should handle media year == 0" do
|
182
|
+
profile = ImdbProfile.first(:titles => ['National Treasure: Book of Secrets'], :media_years => [0])
|
183
|
+
profile.should_not == nil
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should handle media year == '0'" do
|
187
|
+
profile = ImdbProfile.first(:titles => ['National Treasure: Book of Secrets'], :media_years => ['0'])
|
188
|
+
profile.should_not == nil
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should handle production year == nil" do
|
192
|
+
profile = ImdbProfile.first(:titles => ['National Treasure: Book of Secrets'], :production_years => [nil])
|
193
|
+
profile.should_not == nil
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should handle media production == 0" do
|
197
|
+
profile = ImdbProfile.first(:titles => ['National Treasure: Book of Secrets'], :production_years => [0])
|
198
|
+
profile.should_not == nil
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should handle production year == '0'" do
|
202
|
+
profile = ImdbProfile.first(:titles => ['National Treasure: Book of Secrets'], :production_years => ['0'])
|
203
|
+
profile.should_not == nil
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should handle released year == nil" do
|
207
|
+
profile = ImdbProfile.first(:titles => ['National Treasure: Book of Secrets'], :released_years => [nil])
|
208
|
+
profile.should_not == nil
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should handle released year == 0" do
|
212
|
+
profile = ImdbProfile.first(:titles => ['National Treasure: Book of Secrets'], :released_years => [0])
|
213
|
+
profile.should_not == nil
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should handle released year == '0'" do
|
217
|
+
profile = ImdbProfile.first(:titles => ['National Treasure: Book of Secrets'], :released_years => ['0'])
|
218
|
+
profile.should_not == nil
|
219
|
+
end
|
220
|
+
|
176
221
|
def get_temp_filename
|
177
222
|
outfile = Tempfile.new('imdb_profile_spec', TMPDIR)
|
178
223
|
filespec = outfile.path
|