imdb_lists 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,6 +42,7 @@ Get easy access to any public [IMDb](http://www.imdb.com/) [vote history list](h
42
42
  - **url** (String) Full URL to the IMDb list itself.
43
43
  - **movies** (Array[Container::Movie]) A list of movies containing `Container::Movie` instances.
44
44
  - **title** (String) Title of the watchlist.
45
+ - **valid?** (Boolean) Is the data that is being returned valid?
45
46
 
46
47
  ### The Container::Movie class
47
48
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "imdb_lists"
6
- s.version = "1.0.3"
6
+ s.version = "1.0.4"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Linus Oleander"]
9
9
  s.email = ["linus@oleander.nu"]
@@ -22,9 +22,15 @@ module ImdbLists
22
22
 
23
23
  def title
24
24
  @_title ||= content.at_css("h1").content
25
- @_title == "Newest Lists" ? nil : @_title
25
+ ["Newest Lists", "Page not found"].include?(@_title) ? nil : @_title
26
+ rescue NoMethodError
27
+ nil # Default name if not found
26
28
  end
27
-
29
+
30
+ def valid?
31
+ ! [title, user].any?(&:nil?)
32
+ end
33
+
28
34
  private
29
35
  def prepare!
30
36
  movies = []; content.css(".title a").each do |movie|
@@ -29,6 +29,10 @@ describe ImdbLists::Watchlist do
29
29
  @ivh.title.should eq("My favorite movies of alltime! some of them are so bad, but so f....g brilliant")
30
30
  end
31
31
 
32
+ it "should be valid" do
33
+ @ivh.should be_valid
34
+ end
35
+
32
36
  after(:each) do
33
37
  a_request(:get, @full_url).should have_been_made
34
38
  end
@@ -76,11 +80,41 @@ describe ImdbLists::Watchlist do
76
80
  @ivh.user.should be_nil
77
81
  end
78
82
 
83
+ it "should not have a title" do
84
+ @ivh.title.should be_nil
85
+ end
86
+
79
87
  it "should have an id" do
80
88
  @ivh.id.should eq("2BZy80bxY2U")
81
89
  end
82
90
  end
83
91
 
92
+ context "empty page" do
93
+ before(:each) do
94
+ stub_request(:get, @full_url).to_return(:body => "<html></html>", :status => 200)
95
+ end
96
+
97
+ it "should return an empty list" do
98
+ @ivh.should have(0).movies
99
+ end
100
+
101
+ it "should not have a user" do
102
+ @ivh.user.should be_nil
103
+ end
104
+
105
+ it "should not have a title" do
106
+ @ivh.title.should be_nil
107
+ end
108
+
109
+ it "should have an id" do
110
+ @ivh.id.should eq("2BZy80bxY2U")
111
+ end
112
+
113
+ it "should not be valid" do
114
+ @ivh.should_not be_valid
115
+ end
116
+ end
117
+
84
118
  context "the find_by_id method" do
85
119
  it "should be possible to pass an id" do
86
120
  ImdbLists::Watchlist.should_receive(:new).with("2BZy80bxY2U")
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: imdb_lists
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.3
5
+ version: 1.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Linus Oleander
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-17 00:00:00 +02:00
13
+ date: 2011-06-03 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -94,7 +94,7 @@ files:
94
94
  - Gemfile
95
95
  - README.markdown
96
96
  - Rakefile
97
- - imdb_vote_history.gemspec
97
+ - imdb_lists.gemspec
98
98
  - lib/imdb_lists.rb
99
99
  - lib/imdb_lists/base.rb
100
100
  - lib/imdb_lists/container.rb