movies 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/movies.rb +3 -3
- data/movies.gemspec +1 -1
- data/spec/fixtures/vcr_cassettes/bug1.yml +1 -1
- data/spec/fixtures/vcr_cassettes/bug2.yml +1 -1
- data/spec/fixtures/vcr_cassettes/bug3.yml +56 -0
- data/spec/fixtures/vcr_cassettes/n-a-tt1570337.yml +1 -1
- data/spec/fixtures/vcr_cassettes/not_found.yml +1 -1
- data/spec/fixtures/vcr_cassettes/true-grit-1969.yml +1 -1
- data/spec/fixtures/vcr_cassettes/true-grit-2010.yml +1 -1
- data/spec/fixtures/vcr_cassettes/tt0066026.yml +1 -1
- data/spec/fixtures/vcr_cassettes/tt0337978.yml +2 -2
- data/spec/fixtures/vcr_cassettes/tt1285016.yml +1 -1
- data/spec/movies_spec.rb +37 -4
- metadata +4 -2
data/lib/movies.rb
CHANGED
@@ -52,14 +52,14 @@ class Movies
|
|
52
52
|
end
|
53
53
|
|
54
54
|
@year = @year.to_i
|
55
|
-
@genres = @genre.split(",")
|
56
|
-
@writers = @writer.split(",")
|
55
|
+
@genres = @genre.split(", ")
|
56
|
+
@writers = @writer.split(", ")
|
57
57
|
@actors = @actors.split(", ")
|
58
58
|
@rating = @rating.to_f
|
59
59
|
@votes = @votes.to_i
|
60
60
|
|
61
61
|
if @runtime =~ /(\d+).+?(\d+)/
|
62
|
-
@runtime = $1.to_i * 60 + $
|
62
|
+
@runtime = $1.to_i * 60 + $2.to_i
|
63
63
|
elsif @runtime =~ /(\d+) hrs/
|
64
64
|
@runtime = $1.to_i * 60
|
65
65
|
else
|
data/movies.gemspec
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://www.imdbapi.com:80/?i=tt0058371
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
accept:
|
9
|
+
- "*/*; q=0.5, application/xml"
|
10
|
+
accept-encoding:
|
11
|
+
- gzip, deflate
|
12
|
+
timeout:
|
13
|
+
- "3"
|
14
|
+
response: !ruby/struct:VCR::Response
|
15
|
+
status: !ruby/struct:VCR::ResponseStatus
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
cache-control:
|
20
|
+
- no-cache
|
21
|
+
pragma:
|
22
|
+
- no-cache
|
23
|
+
content-type:
|
24
|
+
- text/html; charset=utf-8
|
25
|
+
content-encoding:
|
26
|
+
- gzip
|
27
|
+
expires:
|
28
|
+
- "-1"
|
29
|
+
vary:
|
30
|
+
- Accept-Encoding
|
31
|
+
server:
|
32
|
+
- Microsoft-IIS/7.0
|
33
|
+
x-aspnet-version:
|
34
|
+
- 4.0.30319
|
35
|
+
x-powered-by:
|
36
|
+
- ASP.NET
|
37
|
+
date:
|
38
|
+
- Sat, 30 Apr 2011 23:20:16 GMT
|
39
|
+
content-length:
|
40
|
+
- "573"
|
41
|
+
body: !binary |
|
42
|
+
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3m
|
43
|
+
kuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZk
|
44
|
+
AWz2zkrayZ4hgKrIHz9+fB8/In7xR2+Ktsw/evTRm3meflFVy+3Xq2K5zOvm
|
45
|
+
o9FHv0+e1fTV7sNP9+mvV1mbz+jPz/F7XuZZw38epN9Zl6m2+Txf1oD2LFsU
|
46
|
+
5fUo/eK6afOafnlVLbLlNKcmT4s6n7YVAH8nW+RN+iIvyqZa0lffrQtqTV98
|
47
|
+
UUznWV6mT6+XOQHJ6uv0dZtfZXVLrY7xdkOtvp1dl/l1+kVRls0oPS2L9LtZ
|
48
|
+
WWbT+Sh9WZUZAb6oC/o9J6DpF9NTGtU1vf+yrFp6+/ep1suL9HR5URbNPL0o
|
49
|
+
6jJ9Ubx9e51my1k6pzey9bJNs7ouLvM0a9O2S6BRmqXzqiU0q2V6UlMvo7St
|
50
|
+
6MMybxpqni3TfNnO102RNW0xTa/yclot8vF4DCQqEIbQmLft6tHdu0U2XuSz
|
51
|
+
ItsuFrPJmNrdLRbZRd7c/eLuFz95/8kXby72v/jpsx/Q//dePKO/y/tPsuWT
|
52
|
+
5e/99ln7U2+mV18+ne5/+ebi3Rc/8Xv+nuPf/yd3x7//69/73t7O+KdXF9TZ
|
53
|
+
KxpJscC87KbzOr1/kC6KJSaYprRYXtDnn44f0J8/SaMBYQ8e3KO/zp7Sr227
|
54
|
+
s3P/4N6DXfrgVd6sqmUDOG/qdf7RL/l/ALTFvcI+AgAA
|
55
|
+
|
56
|
+
http_version: "1.1"
|
@@ -35,7 +35,7 @@
|
|
35
35
|
x-powered-by:
|
36
36
|
- ASP.NET
|
37
37
|
date:
|
38
|
-
- Sat, 30 Apr 2011
|
38
|
+
- Sat, 30 Apr 2011 23:20:17 GMT
|
39
39
|
content-length:
|
40
40
|
- "643"
|
41
41
|
body: !binary |
|
@@ -92,7 +92,7 @@
|
|
92
92
|
x-powered-by:
|
93
93
|
- ASP.NET
|
94
94
|
date:
|
95
|
-
- Sat, 30 Apr 2011
|
95
|
+
- Sat, 30 Apr 2011 23:20:18 GMT
|
96
96
|
content-length:
|
97
97
|
- "583"
|
98
98
|
body: !binary |
|
data/spec/movies_spec.rb
CHANGED
@@ -87,25 +87,41 @@ describe Movies do
|
|
87
87
|
movie.id.should eq("tt1285016")
|
88
88
|
movie.director.should eq("David Fincher")
|
89
89
|
movie.href.should eq("http://www.imdb.com/title/tt1285016/")
|
90
|
+
|
91
|
+
movie.genres.each do |genre|
|
92
|
+
genre.should eq(genre.strip)
|
93
|
+
end
|
94
|
+
|
95
|
+
movie.actors.each do |actor|
|
96
|
+
actor.should eq(actor.strip)
|
97
|
+
end
|
98
|
+
|
99
|
+
movie.writers.each do |writer|
|
100
|
+
writer.should eq(writer.strip)
|
101
|
+
end
|
90
102
|
end
|
91
103
|
end
|
92
104
|
|
93
105
|
context "tt0066026" do
|
94
106
|
use_vcr_cassette "tt0066026"
|
95
|
-
|
107
|
+
it "should be possible to pass params" do
|
96
108
|
Movies.new("http://www.imdbapi.com/?i=tt0066026", {
|
97
109
|
y: "1970"
|
98
110
|
}).prepare
|
99
|
-
|
111
|
+
end
|
112
|
+
|
113
|
+
after(:each) do
|
100
114
|
a_request(:get, "http://www.imdbapi.com/?i=tt0066026&y=1970").should have_been_made.once
|
101
115
|
end
|
102
116
|
end
|
103
117
|
|
104
118
|
context "not_found" do
|
105
119
|
use_vcr_cassette "not_found"
|
106
|
-
|
120
|
+
it "should be set to not found" do
|
107
121
|
Movies.new("http://www.imdbapi.com/?i=ttrandom").prepare.should_not be_found
|
108
|
-
|
122
|
+
end
|
123
|
+
|
124
|
+
after(:each) do
|
109
125
|
a_request(:get, "http://www.imdbapi.com/?i=ttrandom").should have_been_made.once
|
110
126
|
end
|
111
127
|
end
|
@@ -116,6 +132,9 @@ describe Movies do
|
|
116
132
|
lambda {
|
117
133
|
Movies.new("http://www.imdbapi.com/?t=Consinsual&y=2010").prepare.released.should be_nil
|
118
134
|
}.should_not raise_error
|
135
|
+
end
|
136
|
+
|
137
|
+
after(:each) do
|
119
138
|
a_request(:get, "http://www.imdbapi.com/?t=Consinsual&y=2010").should have_been_made.once
|
120
139
|
end
|
121
140
|
end
|
@@ -126,10 +145,24 @@ describe Movies do
|
|
126
145
|
lambda {
|
127
146
|
Movies.new("http://www.imdbapi.com/?i=tt0988120").prepare.released.should be_nil
|
128
147
|
}.should_not raise_error
|
148
|
+
end
|
149
|
+
|
150
|
+
after(:each) do
|
129
151
|
a_request(:get, "http://www.imdbapi.com/?i=tt0988120").should have_been_made.once
|
130
152
|
end
|
131
153
|
end
|
132
154
|
|
155
|
+
context "bug3" do
|
156
|
+
use_vcr_cassette "bug3"
|
157
|
+
it "should contain the correct length" do
|
158
|
+
Movies.new("http://www.imdbapi.com/?i=tt0058371").prepare.runtime.should eq(118)
|
159
|
+
end
|
160
|
+
|
161
|
+
after(:each) do
|
162
|
+
a_request(:get, "http://www.imdbapi.com/?i=tt0058371").should have_been_made.once
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
133
166
|
context "N/A" do
|
134
167
|
use_vcr_cassette "n-a-tt1570337"
|
135
168
|
it "Fields that contains N/A should be nil or zero" do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: movies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.6
|
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-
|
13
|
+
date: 2011-05-01 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- spec/exclude_spec.rb
|
90
90
|
- spec/fixtures/vcr_cassettes/bug1.yml
|
91
91
|
- spec/fixtures/vcr_cassettes/bug2.yml
|
92
|
+
- spec/fixtures/vcr_cassettes/bug3.yml
|
92
93
|
- spec/fixtures/vcr_cassettes/n-a-tt1570337.yml
|
93
94
|
- spec/fixtures/vcr_cassettes/not_found.yml
|
94
95
|
- spec/fixtures/vcr_cassettes/true-grit-1969.yml
|
@@ -130,6 +131,7 @@ test_files:
|
|
130
131
|
- spec/exclude_spec.rb
|
131
132
|
- spec/fixtures/vcr_cassettes/bug1.yml
|
132
133
|
- spec/fixtures/vcr_cassettes/bug2.yml
|
134
|
+
- spec/fixtures/vcr_cassettes/bug3.yml
|
133
135
|
- spec/fixtures/vcr_cassettes/n-a-tt1570337.yml
|
134
136
|
- spec/fixtures/vcr_cassettes/not_found.yml
|
135
137
|
- spec/fixtures/vcr_cassettes/true-grit-1969.yml
|