royw-tmdb 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -22,6 +22,7 @@ require 'spec/rake/spectask'
22
22
  Spec::Rake::SpecTask.new(:spec) do |spec|
23
23
  spec.libs << 'lib' << 'spec'
24
24
  spec.spec_files = FileList['spec/**/*_spec.rb']
25
+ spec.spec_opts = ["--color", "--format nested"]
25
26
  end
26
27
 
27
28
  Spec::Rake::SpecTask.new(:rcov) do |spec|
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 6
3
- :major: 0
4
2
  :minor: 1
3
+ :patch: 7
4
+ :major: 0
@@ -28,96 +28,102 @@ describe "TmdbImage" do
28
28
  @image.should_not == nil
29
29
  end
30
30
 
31
- it "should find image via profile" do
32
- profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :logger => @logger)
33
- profile.image.imdb_id.should == 'tt0465234'
34
- end
31
+ describe "Image finds" do
32
+ it "should find image via profile" do
33
+ profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :logger => @logger)
34
+ profile.image.imdb_id.should == 'tt0465234'
35
+ end
35
36
 
36
- it "should find image via movie" do
37
- profile = TmdbMovie.new('0465234', TMDB_API_KEY, @logger)
38
- profile.image.imdb_id.should == 'tt0465234'
37
+ it "should find image via movie" do
38
+ profile = TmdbMovie.new('0465234', TMDB_API_KEY, @logger)
39
+ profile.image.imdb_id.should == 'tt0465234'
40
+ end
39
41
  end
40
42
 
41
- it "should find original size fanart" do
42
- src_url = nil
43
- src_url = @image.fanart_original unless @image.nil?
44
- src_url.should_not be_nil
45
- end
43
+ describe "Image contents" do
44
+ it "should find original size fanart" do
45
+ src_url = nil
46
+ src_url = @image.fanart_original unless @image.nil?
47
+ src_url.should_not be_nil
48
+ end
46
49
 
47
- it "should find mid size fanart" do
48
- src_url = nil
49
- src_url = @image.fanart_mid unless @image.nil?
50
- src_url.should_not be_nil
51
- end
50
+ it "should find mid size fanart" do
51
+ src_url = nil
52
+ src_url = @image.fanart_mid unless @image.nil?
53
+ src_url.should_not be_nil
54
+ end
52
55
 
53
- it "should find thumb size fanart" do
54
- src_url = nil
55
- src_url = @image.fanart_thumb unless @image.nil?
56
- src_url.should_not be_nil
57
- end
56
+ it "should find thumb size fanart" do
57
+ src_url = nil
58
+ src_url = @image.fanart_thumb unless @image.nil?
59
+ src_url.should_not be_nil
60
+ end
58
61
 
59
- it "should find original size poster" do
60
- src_url = nil
61
- src_url = @image.poster_original unless @image.nil?
62
- src_url.should_not be_nil
63
- end
62
+ it "should find original size poster" do
63
+ src_url = nil
64
+ src_url = @image.poster_original unless @image.nil?
65
+ src_url.should_not be_nil
66
+ end
64
67
 
65
- it "should find mid size poster" do
66
- src_url = nil
67
- src_url = @image.poster_mid unless @image.nil?
68
- src_url.should_not be_nil
69
- end
68
+ it "should find mid size poster" do
69
+ src_url = nil
70
+ src_url = @image.poster_mid unless @image.nil?
71
+ src_url.should_not be_nil
72
+ end
70
73
 
71
- it "should find thumb size poster" do
72
- src_url = nil
73
- src_url = @image.poster_thumb unless @image.nil?
74
- src_url.should_not be_nil
75
- end
74
+ it "should find thumb size poster" do
75
+ src_url = nil
76
+ src_url = @image.poster_thumb unless @image.nil?
77
+ src_url.should_not be_nil
78
+ end
76
79
 
77
- it "should find cover size poster" do
78
- src_url = nil
79
- src_url = @image.poster_cover unless @image.nil?
80
- src_url.should_not be_nil
81
- end
80
+ it "should find cover size poster" do
81
+ src_url = nil
82
+ src_url = @image.poster_cover unless @image.nil?
83
+ src_url.should_not be_nil
84
+ end
82
85
 
83
- it "should find all fanarts" do
84
- buf = []
85
- @image.fanart_sizes.each do |size|
86
- buf << "fanart(#{size}) returned nil" if @image.fanart(size).nil?
86
+ it "should find all fanarts" do
87
+ buf = []
88
+ @image.fanart_sizes.each do |size|
89
+ buf << "fanart(#{size}) returned nil" if @image.fanart(size).nil?
90
+ end
91
+ puts buf.join("\n") unless buf.empty?
92
+ buf.empty?.should be_true
87
93
  end
88
- puts buf.join("\n") unless buf.empty?
89
- buf.empty?.should be_true
90
- end
91
94
 
92
- it "should find all posters" do
93
- buf = []
94
- @image.poster_sizes.each do |size|
95
- buf << "poster(#{size}) returned nil" if @image.poster(size).nil?
95
+ it "should find all posters" do
96
+ buf = []
97
+ @image.poster_sizes.each do |size|
98
+ buf << "poster(#{size}) returned nil" if @image.poster(size).nil?
99
+ end
100
+ puts buf.join("\n") unless buf.empty?
101
+ buf.empty?.should be_true
96
102
  end
97
- puts buf.join("\n") unless buf.empty?
98
- buf.empty?.should be_true
99
- end
100
103
 
101
- # the same routine is used by all the getters to fetch the image so only
102
- # need to test one case
103
- it "should fetch fanart" do
104
- filespec = get_temp_filename
105
- src_url = @image.fanart_original(filespec)
106
- filespec += File.extname(src_url)
107
- (File.exist?(filespec).should be_true) && (File.size(filespec).should > 0)
104
+ # the same routine is used by all the getters to fetch the image so only
105
+ # need to test one case
106
+ it "should fetch fanart" do
107
+ filespec = get_temp_filename
108
+ src_url = @image.fanart_original(filespec)
109
+ filespec += File.extname(src_url)
110
+ (File.exist?(filespec).should be_true) && (File.size(filespec).should > 0)
111
+ end
108
112
  end
109
113
 
110
- # these are a couple of white box tests to show a bug where
111
- # src_url was nil but copy_image was trying to copy from it anyway.
114
+ describe "bug tests" do
115
+ # these are a couple of white box tests to show a bug where
116
+ # src_url was nil but copy_image was trying to copy from it anyway.
112
117
 
113
- it "should not attempt to copy if src_url is blank" do
114
- dest_filespec = get_temp_filename
115
- @image.send('copy_image', nil, dest_filespec).should be_nil
116
- end
118
+ it "should not attempt to copy if src_url is blank" do
119
+ dest_filespec = get_temp_filename
120
+ @image.send('copy_image', nil, dest_filespec).should be_nil
121
+ end
117
122
 
118
- it "should not attempt to copy if dest_filespec is blank" do
119
- src_url = @image.send('image_url', 'tt0465234', 'fanarts', 'original')
120
- @image.send('copy_image', src_url, nil).should be_nil
123
+ it "should not attempt to copy if dest_filespec is blank" do
124
+ src_url = @image.send('image_url', 'tt0465234', 'fanarts', 'original')
125
+ @image.send('copy_image', src_url, nil).should be_nil
126
+ end
121
127
  end
122
128
 
123
129
  def get_temp_filename
@@ -20,58 +20,63 @@ describe "TmdbMovie" do
20
20
  Dir.glob(File.join(TMPDIR,'tmdb_movie_spec*')).each { |filename| File.delete(filename) }
21
21
  end
22
22
 
23
- it "should find by imdb_id" do
24
- @profile.should_not == nil
23
+ describe "Find movie" do
24
+ it "should find by imdb_id" do
25
+ @profile.should_not == nil
26
+ end
25
27
  end
26
28
 
27
- it "should find tmdb id" do
28
- @profile.idents.first.should == '6637'
29
- end
29
+ describe "Movie contents" do
30
+ it "should find tmdb id" do
31
+ @profile.idents.first.should == '6637'
32
+ end
30
33
 
31
- it "should find fanarts" do
32
- @profile.fanarts.size.should == 3
33
- end
34
+ it "should find fanarts" do
35
+ @profile.fanarts.size.should == 3
36
+ end
34
37
 
35
- it "should find posters" do
36
- @profile.posters.size.should == 4
37
- end
38
+ it "should find posters" do
39
+ @profile.posters.size.should == 4
40
+ end
38
41
 
39
- it "should find the tmdb url" do
40
- @profile.urls.first.should == 'http://www.themoviedb.org/movie/6637'
41
- end
42
+ it "should find the tmdb url" do
43
+ @profile.urls.first.should == 'http://www.themoviedb.org/movie/6637'
44
+ end
42
45
 
43
- it "should find the imdb_id" do
44
- @profile.imdb_ids.first.should == 'tt0465234'
45
- end
46
+ it "should find the imdb_id" do
47
+ @profile.imdb_ids.first.should == 'tt0465234'
48
+ end
46
49
 
47
- it "should find the title" do
48
- @profile.titles.first.should == 'National Treasure: Book of Secrets'
49
- end
50
+ it "should find the title" do
51
+ @profile.titles.first.should == 'National Treasure: Book of Secrets'
52
+ end
50
53
 
51
- it "should find the short_overview" do
52
- @profile.short_overviews.first.should =~ /Benjamin Franklin Gates/
53
- end
54
+ it "should find the short_overview" do
55
+ @profile.short_overviews.first.should =~ /Benjamin Franklin Gates/
56
+ end
54
57
 
55
- it "should find the type" do
56
- @profile.types.first.should == 'movie'
57
- end
58
+ it "should find the type" do
59
+ @profile.types.first.should == 'movie'
60
+ end
58
61
 
59
- it "should find the alternative_titles" do
60
- @profile.alternative_titles.first.should == 'National Treasure 2'
61
- end
62
+ it "should find the alternative_titles" do
63
+ @profile.alternative_titles.first.should == 'National Treasure 2'
64
+ end
62
65
 
63
- it "should find the release" do
64
- @profile.releases.first.should == '2007-12-13'
65
- end
66
+ it "should find the release" do
67
+ @profile.releases.first.should == '2007-12-13'
68
+ end
66
69
 
67
- it "should find the score" do
68
- @profile.scores.first.should == '1.0'
70
+ it "should find the score" do
71
+ @profile.scores.first.should == '1.0'
72
+ end
69
73
  end
70
74
 
71
- it "should handle The Sand Pebble" do
72
- profile = TmdbMovie.new('tt0060934', TMDB_API_KEY, @logger)
73
- profile.idents.should be_nil
75
+ describe "bug tests" do
76
+ it "should handle The Sand Pebble" do
77
+ profile = TmdbMovie.new('tt0060934', TMDB_API_KEY, @logger)
78
+ profile.idents.should be_nil
79
+ end
74
80
  end
75
-
76
81
  end
77
82
 
@@ -21,115 +21,110 @@ describe "TmdbProfile" do
21
21
  Dir.glob(File.join(TMPDIR,'tmdb_profile_spec*')).each { |filename| File.delete(filename) }
22
22
  end
23
23
 
24
- it "should find by imdb_id" do
25
- @profile.should_not == nil
24
+ describe "Finder" do
25
+ it "should find by imdb_id" do
26
+ @profile.should_not == nil
27
+ end
26
28
  end
27
29
 
28
- it "should save the profile to a file" do
29
- filespec = get_temp_filename
30
- profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => filespec)
31
- (File.exist?(filespec).should be_true) && (File.size(filespec).should > 0)
32
- end
30
+ describe "Contents" do
31
+ it "should find tmdb id" do
32
+ @profile.movie['idents'].first.should == '6637'
33
+ end
33
34
 
34
- it "should be able to convert to xml" do
35
- xml = @profile.to_xml
36
- (xml.should_not be_nil) && (xml.length.should > 0)
37
- end
35
+ it "should find fanarts" do
36
+ @profile.movie['fanarts'].size.should == 3
37
+ end
38
38
 
39
- it "should be able to convert to xml and then from xml" do
40
- hash = nil
41
- begin
42
- xml = @profile.to_xml
43
- hash = XmlSimple.xml_in(xml)
44
- rescue
45
- hash = nil
39
+ it "should find posters" do
40
+ @profile.movie['posters'].size.should == 4
46
41
  end
47
- hash.should_not be_nil
48
- end
49
42
 
50
- it "should find tmdb id" do
51
- @profile.movie['idents'].first.should == '6637'
52
- end
43
+ it "should find the tmdb url" do
44
+ @profile.movie['urls'].first.should == 'http://www.themoviedb.org/movie/6637'
45
+ end
53
46
 
54
- it "should find fanarts" do
55
- @profile.movie['fanarts'].size.should == 3
56
- end
47
+ it "should find the imdb_id" do
48
+ @profile.movie['imdb_ids'].first.should == 'tt0465234'
49
+ end
57
50
 
58
- it "should find posters" do
59
- @profile.movie['posters'].size.should == 4
60
- end
51
+ it "should find the title" do
52
+ @profile.movie['titles'].first.should == 'National Treasure: Book of Secrets'
53
+ end
61
54
 
62
- it "should find the tmdb url" do
63
- @profile.movie['urls'].first.should == 'http://www.themoviedb.org/movie/6637'
64
- end
55
+ it "should find the short_overview" do
56
+ @profile.movie['short_overviews'].first.should =~ /Benjamin Franklin Gates/
57
+ end
65
58
 
66
- it "should find the imdb_id" do
67
- @profile.movie['imdb_ids'].first.should == 'tt0465234'
68
- end
59
+ it "should find the type" do
60
+ @profile.movie['types'].first.should == 'movie'
61
+ end
69
62
 
70
- it "should find the title" do
71
- @profile.movie['titles'].first.should == 'National Treasure: Book of Secrets'
72
- end
63
+ it "should find the alternative_titles" do
64
+ @profile.movie['alternative_titles'].first.should == 'National Treasure 2'
65
+ end
73
66
 
74
- it "should find the short_overview" do
75
- @profile.movie['short_overviews'].first.should =~ /Benjamin Franklin Gates/
76
- end
67
+ it "should find the release" do
68
+ @profile.movie['releases'].first.should == '2007-12-13'
69
+ end
77
70
 
78
- it "should find the type" do
79
- @profile.movie['types'].first.should == 'movie'
71
+ it "should find the score" do
72
+ @profile.movie['scores'].first.should == '1.0'
73
+ end
80
74
  end
81
75
 
82
- it "should find the alternative_titles" do
83
- @profile.movie['alternative_titles'].first.should == 'National Treasure 2'
84
- end
76
+ describe "XML" do
77
+ it "should be able to convert to xml" do
78
+ xml = @profile.to_xml
79
+ (xml.should_not be_nil) && (xml.length.should > 0)
80
+ end
85
81
 
86
- it "should find the release" do
87
- @profile.movie['releases'].first.should == '2007-12-13'
82
+ it "should be able to convert to xml and then from xml" do
83
+ hash = nil
84
+ begin
85
+ xml = @profile.to_xml
86
+ hash = XmlSimple.xml_in(xml)
87
+ rescue
88
+ hash = nil
89
+ end
90
+ hash.should_not be_nil
91
+ end
88
92
  end
89
93
 
90
- it "should find the score" do
91
- @profile.movie['scores'].first.should == '1.0'
92
- end
94
+ describe "File" do
95
+ it "should save the profile to a file" do
96
+ filespec = get_temp_filename
97
+ profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => filespec)
98
+ (File.exist?(filespec).should be_true) && (File.size(filespec).should > 0)
99
+ end
93
100
 
94
- # let's make sure the generated xml from to_xml() is valid
101
+ # now let's test caching the profile to/from a file
95
102
 
96
- it "should be able to convert to xml and then from xml" do
97
- hash = nil
98
- begin
99
- profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY)
100
- xml = profile.to_xml
101
- hash = XmlSimple.xml_in(xml)
102
- rescue
103
- hash = nil
103
+ it "should not create a file if a :filespec option is passed that is nil" do
104
+ profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => nil)
105
+ Dir.glob(File.join(TMPDIR, "imdb_profile_spec*")).empty?.should be_true
104
106
  end
105
- hash.should_not be_nil
106
- end
107
-
108
- # now let's test caching the profile to/from a file
109
107
 
110
- it "should not create a file if a :filespec option is passed that is nil" do
111
- profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => nil)
112
- Dir.glob(File.join(TMPDIR, "imdb_profile_spec*")).empty?.should be_true
113
- end
108
+ it "should create a file if a :filespec option is passed" do
109
+ filespec = get_temp_filename
110
+ profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => filespec)
111
+ (File.exist?(filespec) && (File.size(filespec) > 0)).should be_true
112
+ end
114
113
 
115
- it "should create a file if a :filespec option is passed" do
116
- filespec = get_temp_filename
117
- profile = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => filespec)
118
- (File.exist?(filespec) && (File.size(filespec) > 0)).should be_true
119
- end
114
+ it "should load from a file if a :filespec option is passed and the file exists" do
115
+ filespec = get_temp_filename
116
+ profile1 = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => filespec)
117
+ profile2 = TmdbProfile.first(:api_key => TMDB_API_KEY, :filespec => filespec)
118
+ profile1.imdb_id.should == profile2.imdb_id
119
+ end
120
120
 
121
- it "should load from a file if a :filespec option is passed and the file exists" do
122
- filespec = get_temp_filename
123
- profile1 = TmdbProfile.first(:imdb_id => 'tt0465234', :api_key => TMDB_API_KEY, :filespec => filespec)
124
- profile2 = TmdbProfile.first(:api_key => TMDB_API_KEY, :filespec => filespec)
125
- profile1.imdb_id.should == profile2.imdb_id
121
+ it "should not load from a file if a :filespec option is passed and the file does not exists" do
122
+ filespec = get_temp_filename
123
+ profile = TmdbProfile.first(:api_key => TMDB_API_KEY, :filespec => filespec)
124
+ profile.should be_nil
125
+ end
126
126
  end
127
127
 
128
- it "should not load from a file if a :filespec option is passed and the file does not exists" do
129
- filespec = get_temp_filename
130
- profile = TmdbProfile.first(:api_key => TMDB_API_KEY, :filespec => filespec)
131
- profile.should be_nil
132
- end
133
128
 
134
129
  def get_temp_filename
135
130
  outfile = Tempfile.new('tmdb_profile_spec', TMPDIR)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: royw-tmdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Wright
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-21 00:00:00 -07:00
12
+ date: 2009-04-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency