imdb_vote_history 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,116 @@
1
+ describe ImdbVoteHistory do
2
+ before(:all) do
3
+ @url = "http://www.imdb.com/mymovies/list?l=32558051"
4
+ @id = "32558051"
5
+ @count = 937
6
+
7
+ @valid_urls = [
8
+ "http://imdb.com/mymovies/list?l=1234",
9
+ "imdb.com/mymovies/list?l=1234",
10
+ "www.imdb.com/mymovies/list?l=1234"
11
+ ]
12
+
13
+ @invalid_urls = [
14
+ "http://www.imdb.com/mymovieslist?l=32558051",
15
+ "mymovieslist?l=32558051",
16
+ "http://www.imdb.com/mymovieslist?l=32558abc051"
17
+ ]
18
+ end
19
+
20
+ after(:each) do
21
+ WebMock.reset!
22
+ end
23
+
24
+ before(:each) do
25
+ @ivh = ImdbVoteHistory.new(@id)
26
+ end
27
+
28
+ context "200 success" do
29
+ before(:each) do
30
+ stub_request(:get, "#{@url}&a=1").to_return(:body => File.new("spec/fixtures/32558051.html"), :status => 200)
31
+ end
32
+
33
+ it "should return a list of movies" do
34
+ @ivh.should have(@count).movies
35
+ end
36
+
37
+ it "should be able to cache" do
38
+ object = Container::Movie.new(:imdb_link => "http://www.imdb.com/title/tt0460649/")
39
+ Container::Movie.should_receive(:new).exactly(@count).times.and_return(object)
40
+ 10.times { @ivh.movies }
41
+ end
42
+
43
+ it "should have a user method" do
44
+ @ivh.user.should eq("eddyproca")
45
+ end
46
+
47
+ it "should have a id method" do
48
+ @ivh.id.should eq(32558051)
49
+ end
50
+
51
+ it "should contain a list of movies" do
52
+ @ivh.movies.all? { |m| m.should be_instance_of(Container::Movie) }
53
+ end
54
+
55
+ it "should have an url method" do
56
+ @ivh.url.should eq(@url)
57
+ end
58
+ end
59
+
60
+ context "404 error" do
61
+ before(:each) do
62
+ stub_request(:get, "#{@url}&a=1").to_return(:body => "", :status => 404)
63
+ end
64
+
65
+ it "should return an empty list if something goes wrong" do
66
+ @ivh.movies.should be_empty
67
+ end
68
+
69
+ it "should not return a user" do
70
+ @ivh.user.should be_nil
71
+ end
72
+ end
73
+
74
+ context "a non public list" do
75
+ before(:each) do
76
+ stub_request(:get, "#{@url}&a=1").to_return(:body => File.new("spec/fixtures/non_public.html"), :status => 200)
77
+ end
78
+
79
+ it "should return an empty list" do
80
+ @ivh.should have(0).movies
81
+ end
82
+
83
+ it "should not have a user" do
84
+ @ivh.user.should be_nil
85
+ end
86
+
87
+ it "should have an id" do
88
+ @ivh.id.should eq(32558051)
89
+ end
90
+ end
91
+
92
+ context "the find_by_id method" do
93
+ it "should be possible to pass an id" do
94
+ ["32558051", 32558051].each do |id|
95
+ ImdbVoteHistory.should_receive(:new).with(id)
96
+ lambda { ImdbVoteHistory.find_by_id(id) }.should_not raise_error(ArgumentError)
97
+ end
98
+ end
99
+ end
100
+
101
+ context "the find_by_url method" do
102
+ it "should raise an error if the url is invalid" do
103
+ ImdbVoteHistory.should_not_receive(:new)
104
+ @invalid_urls.each do |url|
105
+ lambda { ImdbVoteHistory.find_by_url(url) }.should raise_error(ArgumentError)
106
+ end
107
+ end
108
+
109
+ it "should not raise an error if the url is valid" do
110
+ ImdbVoteHistory.should_receive(:new).with("1234").exactly(@valid_urls.length).times
111
+ @valid_urls.each do |url|
112
+ lambda { ImdbVoteHistory.find_by_url(url) }.should_not raise_error(ArgumentError)
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "webmock/rspec"
3
+ require "imdb_vote_history"
4
+ require "imdb_vote_history/container"
5
+
6
+ RSpec.configure do |config|
7
+ config.mock_with :rspec
8
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: imdb_vote_history
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Linus Oleander
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-03 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rest-client
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: nokogiri
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: movie_searcher
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: rspec
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :development
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: webmock
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ type: :development
90
+ version_requirements: *id005
91
+ description: Get easy access to any public IMDb vote history list. Extract information from each movie like; title, release date, rating, actors
92
+ email:
93
+ - linus@oleande.nu
94
+ executables: []
95
+
96
+ extensions: []
97
+
98
+ extra_rdoc_files: []
99
+
100
+ files:
101
+ - .gitignore
102
+ - .rspec
103
+ - Gemfile
104
+ - README.markdown
105
+ - Rakefile
106
+ - imdb_vote_history.gemspec
107
+ - lib/imdb_vote_history.rb
108
+ - lib/imdb_vote_history/container.rb
109
+ - spec/container_spec.rb
110
+ - spec/fixtures/32558051.html
111
+ - spec/fixtures/non_public.html
112
+ - spec/fixtures/pagination.html
113
+ - spec/fixtures/pagination_end.html
114
+ - spec/imdb_vote_history_spec.rb
115
+ - spec/spec_helper.rb
116
+ has_rdoc: true
117
+ homepage: https://github.com/oleander/imdb_vote_history
118
+ licenses: []
119
+
120
+ post_install_message:
121
+ rdoc_options: []
122
+
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ hash: 3
131
+ segments:
132
+ - 0
133
+ version: "0"
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ hash: 3
140
+ segments:
141
+ - 0
142
+ version: "0"
143
+ requirements: []
144
+
145
+ rubyforge_project: imdb_vote_history
146
+ rubygems_version: 1.5.0
147
+ signing_key:
148
+ specification_version: 3
149
+ summary: Get easy access to any public IMDb vote history list using Ruby
150
+ test_files:
151
+ - spec/container_spec.rb
152
+ - spec/fixtures/32558051.html
153
+ - spec/fixtures/non_public.html
154
+ - spec/fixtures/pagination.html
155
+ - spec/fixtures/pagination_end.html
156
+ - spec/imdb_vote_history_spec.rb
157
+ - spec/spec_helper.rb