imdb_lists 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/.rspec +5 -0
- data/Gemfile +4 -0
- data/README.markdown +76 -0
- data/Rakefile +2 -0
- data/imdb_vote_history.gemspec +25 -0
- data/lib/imdb_lists.rb +36 -0
- data/lib/imdb_lists/container.rb +49 -0
- data/lib/imdb_lists/history.rb +58 -0
- data/lib/imdb_lists/watchlist.rb +54 -0
- data/spec/container_spec.rb +38 -0
- data/spec/fixtures/32558051.html +8401 -0
- data/spec/fixtures/empty_watchlist.html +761 -0
- data/spec/fixtures/non_public.html +992 -0
- data/spec/fixtures/non_public_watchlist.html +668 -0
- data/spec/fixtures/pagination.html +1057 -0
- data/spec/fixtures/pagination_end.html +956 -0
- data/spec/fixtures/watchlist.html +3365 -0
- data/spec/history_spec.rb +124 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/watchlist_spec.rb +98 -0
- metadata +141 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ImdbLists::History do
|
4
|
+
before(:all) do
|
5
|
+
@url = "http://www.imdb.com/mymovies/list?l=32558051"
|
6
|
+
@id = "32558051"
|
7
|
+
@count = 937
|
8
|
+
|
9
|
+
@valid_urls = [
|
10
|
+
"http://imdb.com/mymovies/list?l=1234",
|
11
|
+
"imdb.com/mymovies/list?l=1234",
|
12
|
+
"www.imdb.com/mymovies/list?l=1234"
|
13
|
+
]
|
14
|
+
|
15
|
+
@invalid_urls = [
|
16
|
+
"http://www.imdb.com/mymovieslist?l=32558051",
|
17
|
+
"mymovieslist?l=32558051",
|
18
|
+
"http://www.imdb.com/mymovieslist?l=32558abc051"
|
19
|
+
]
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:each) do
|
23
|
+
WebMock.reset!
|
24
|
+
end
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
@ivh = ImdbLists::History.new(@id)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "200 success" do
|
31
|
+
before(:each) do
|
32
|
+
stub_request(:get, "#{@url}&a=1").to_return(:body => File.new("spec/fixtures/32558051.html"), :status => 200)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return a list of movies" do
|
36
|
+
@ivh.should have(@count).movies
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be able to cache" do
|
40
|
+
object = Container::Movie.new(:imdb_link => "http://www.imdb.com/title/tt0460649/")
|
41
|
+
Container::Movie.should_receive(:new).exactly(@count).times.and_return(object)
|
42
|
+
10.times { @ivh.movies }
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have a user method" do
|
46
|
+
@ivh.user.should eq("eddyproca")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should have a id method" do
|
50
|
+
@ivh.id.should eq(32558051)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should contain a list of movies" do
|
54
|
+
@ivh.movies.all? { |m| m.should be_instance_of(Container::Movie) }
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should have an url method" do
|
58
|
+
@ivh.url.should eq(@url)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "404 error" do
|
63
|
+
before(:each) do
|
64
|
+
stub_request(:get, "#{@url}&a=1").to_return(:body => "", :status => 404)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return an empty list if something goes wrong" do
|
68
|
+
@ivh.movies.should be_empty
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should not return a user" do
|
72
|
+
@ivh.user.should be_nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "a non public list" do
|
77
|
+
before(:each) do
|
78
|
+
stub_request(:get, "#{@url}&a=1").to_return(:body => File.new("spec/fixtures/non_public.html"), :status => 200)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should return an empty list" do
|
82
|
+
@ivh.should have(0).movies
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not have a user" do
|
86
|
+
@ivh.user.should be_nil
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should have an id" do
|
90
|
+
@ivh.id.should eq(32558051)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "the find_by_id method" do
|
95
|
+
it "should be possible to pass an id" do
|
96
|
+
["32558051", 32558051].each do |id|
|
97
|
+
ImdbLists::History.should_receive(:new).with(id)
|
98
|
+
lambda { ImdbLists::find_by_id(id) }.should_not raise_error(ArgumentError)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should not be possible to pass nil or n <= 9" do
|
103
|
+
["0", nil, "1", "9"].each do |id|
|
104
|
+
lambda { ImdbLists::find_by_id(id) }.should raise_error(ArgumentError)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "the find_by_url method" do
|
110
|
+
it "should raise an error if the url is invalid" do
|
111
|
+
ImdbLists::History.should_not_receive(:new)
|
112
|
+
@invalid_urls.each do |url|
|
113
|
+
lambda { ImdbLists::find_by_url(url) }.should raise_error(ArgumentError)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should not raise an error if the url is valid" do
|
118
|
+
ImdbLists::History.should_receive(:new).with("1234").exactly(@valid_urls.length).times
|
119
|
+
@valid_urls.each do |url|
|
120
|
+
lambda { ImdbLists::find_by_url(url) }.should_not raise_error(ArgumentError)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "rspec"
|
2
|
+
require "webmock/rspec"
|
3
|
+
require "imdb_lists"
|
4
|
+
require "imdb_lists/container"
|
5
|
+
require "imdb_lists/history"
|
6
|
+
require "imdb_lists/watchlist"
|
7
|
+
|
8
|
+
WebMock.disable_net_connect!
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.mock_with :rspec
|
12
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ImdbLists::Watchlist do
|
4
|
+
before(:all) do
|
5
|
+
@url = "http://www.imdb.com/list/2BZy80bxY2U"
|
6
|
+
@id = "2BZy80bxY2U"
|
7
|
+
@count = 79
|
8
|
+
@full_url = "http://www.imdb.com/list/2BZy80bxY2U/?view=compact&sort=listorian:asc"
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
@ivh = ImdbLists::Watchlist.new(@id)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "200 success - internet" do
|
16
|
+
before(:each) do
|
17
|
+
stub_request(:get, @full_url).to_return(:body => File.read("spec/fixtures/watchlist.html"), :status => 200)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return a list of movies" do
|
21
|
+
@ivh.should have(@count).movies
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have a user method" do
|
25
|
+
@ivh.user.should eq("savagestreets")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have a title" do
|
29
|
+
@ivh.title.should eq("My favorite movies of alltime! some of them are so bad, but so f....g brilliant")
|
30
|
+
end
|
31
|
+
|
32
|
+
after(:each) do
|
33
|
+
a_request(:get, @full_url).should have_been_made
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "offline" do
|
39
|
+
it "should have a id method" do
|
40
|
+
@ivh.id.should eq("2BZy80bxY2U")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have an url method" do
|
44
|
+
@ivh.url.should eq(@url)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "empty list" do
|
49
|
+
before(:each) do
|
50
|
+
stub_request(:get, @full_url).to_return(:body => File.new("spec/fixtures/empty_watchlist.html"), :status => 200)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should return an empty list" do
|
54
|
+
@ivh.should have(0).movies
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should not have a user" do
|
58
|
+
@ivh.user.should eq("Oleeander")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should have an id" do
|
62
|
+
@ivh.id.should eq("2BZy80bxY2U")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "non public" do
|
67
|
+
before(:each) do
|
68
|
+
stub_request(:get, @full_url).to_return(:body => File.new("spec/fixtures/non_public_watchlist.html"), :status => 200)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return an empty list" do
|
72
|
+
@ivh.should have(0).movies
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should not have a user" do
|
76
|
+
@ivh.user.should be_nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should have an id" do
|
80
|
+
@ivh.id.should eq("2BZy80bxY2U")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "the find_by_id method" do
|
85
|
+
it "should be possible to pass an id" do
|
86
|
+
ImdbLists::Watchlist.should_receive(:new).with("2BZy80bxY2U")
|
87
|
+
lambda { ImdbLists::find_by_id("2BZy80bxY2U") }.should_not raise_error(ArgumentError)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "the find_by_url method" do
|
92
|
+
it "should not raise an error if the url is valid" do
|
93
|
+
ImdbLists::Watchlist.should_receive(:new).exactly(2).times.with("2BZy80bxY2U")
|
94
|
+
lambda { ImdbLists::find_by_url(@full_url) }.should_not raise_error(ArgumentError)
|
95
|
+
lambda { ImdbLists::find_by_url(@url) }.should_not raise_error(ArgumentError)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: imdb_lists
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Linus Oleander
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-15 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rest-client
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: movie_searcher
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rspec
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: webmock
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id005
|
71
|
+
description: Get easy access to any public IMDb list, such as; Watchlists and Vote history lists. Extract information from each movie like; title, release date, rating, actors
|
72
|
+
email:
|
73
|
+
- linus@oleander.nu
|
74
|
+
executables: []
|
75
|
+
|
76
|
+
extensions: []
|
77
|
+
|
78
|
+
extra_rdoc_files: []
|
79
|
+
|
80
|
+
files:
|
81
|
+
- .gitignore
|
82
|
+
- .rspec
|
83
|
+
- Gemfile
|
84
|
+
- README.markdown
|
85
|
+
- Rakefile
|
86
|
+
- imdb_vote_history.gemspec
|
87
|
+
- lib/imdb_lists.rb
|
88
|
+
- lib/imdb_lists/container.rb
|
89
|
+
- lib/imdb_lists/history.rb
|
90
|
+
- lib/imdb_lists/watchlist.rb
|
91
|
+
- spec/container_spec.rb
|
92
|
+
- spec/fixtures/32558051.html
|
93
|
+
- spec/fixtures/empty_watchlist.html
|
94
|
+
- spec/fixtures/non_public.html
|
95
|
+
- spec/fixtures/non_public_watchlist.html
|
96
|
+
- spec/fixtures/pagination.html
|
97
|
+
- spec/fixtures/pagination_end.html
|
98
|
+
- spec/fixtures/watchlist.html
|
99
|
+
- spec/history_spec.rb
|
100
|
+
- spec/spec_helper.rb
|
101
|
+
- spec/watchlist_spec.rb
|
102
|
+
has_rdoc: true
|
103
|
+
homepage: https://github.com/oleander/imdb_lists
|
104
|
+
licenses: []
|
105
|
+
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: "0"
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: "0"
|
123
|
+
requirements: []
|
124
|
+
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 1.6.2
|
127
|
+
signing_key:
|
128
|
+
specification_version: 3
|
129
|
+
summary: Get easy access to any public IMDb list
|
130
|
+
test_files:
|
131
|
+
- spec/container_spec.rb
|
132
|
+
- spec/fixtures/32558051.html
|
133
|
+
- spec/fixtures/empty_watchlist.html
|
134
|
+
- spec/fixtures/non_public.html
|
135
|
+
- spec/fixtures/non_public_watchlist.html
|
136
|
+
- spec/fixtures/pagination.html
|
137
|
+
- spec/fixtures/pagination_end.html
|
138
|
+
- spec/fixtures/watchlist.html
|
139
|
+
- spec/history_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
- spec/watchlist_spec.rb
|