movies 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rspec +5 -0
- data/Gemfile +4 -0
- data/README.md +102 -0
- data/Rakefile +2 -0
- data/lib/movies.rb +124 -0
- data/lib/movies/exclude.yml +22 -0
- data/movies.gemspec +29 -0
- data/spec/fixtures/vcr_cassettes/bug1.yml +54 -0
- data/spec/fixtures/vcr_cassettes/not_found.yml +93 -0
- data/spec/fixtures/vcr_cassettes/true-grit-1969.yml +215 -0
- data/spec/fixtures/vcr_cassettes/true-grit-2010.yml +109 -0
- data/spec/fixtures/vcr_cassettes/tt0066026.yml +157 -0
- data/spec/fixtures/vcr_cassettes/tt0337978.yml +113 -0
- data/spec/fixtures/vcr_cassettes/tt1285016.yml +203 -0
- data/spec/movies_spec.rb +145 -0
- data/spec/spec_helper.rb +19 -0
- metadata +135 -0
@@ -0,0 +1,113 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://www.imdbapi.com:80/?i=tt0337978&tomatoes=true
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
accept:
|
9
|
+
- "*/*; q=0.5, application/xml"
|
10
|
+
accept-encoding:
|
11
|
+
- gzip, deflate
|
12
|
+
timeout:
|
13
|
+
- "10"
|
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 03:37:31 GMT
|
39
|
+
content-length:
|
40
|
+
- "643"
|
41
|
+
body: !binary |
|
42
|
+
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3m
|
43
|
+
kuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZk
|
44
|
+
AWz2zkrayZ4hgKrIHz9+fB8/In7xR2+Ktsw/evTR8+IyT5/VeZ5Wdfq0yNNv
|
45
|
+
Z/Xso9FHv0+e1fT13s7OA/rrVdbmM/rz5efbu/fwd17mWcMf7T1Iv7Neptrw
|
46
|
+
83xZA+zxtC2q5Sg9qYtFPkrfzOuiLPOaWjwt6nzaVgD+PF+m3y2afJEt6Yvv
|
47
|
+
1kVLLR599EVWv02fVItJNn07Sv2/qBUBruqGWj2p19OcXi/LohkRCk1bLNPn
|
48
|
+
1fKCeisWVTu/Tr8sr1fzbNkCyMUFje0nCMDLsmrp9e9U82X6xfSkzJZ52mZv
|
49
|
+
8yatlmm2TM+WhMUyb7cnGGBKf9RVXTQt0eciWxY/yDCw9GpepUWTNtdNS+i3
|
50
|
+
xTQry+u0ma9bQuMinVVXy7Sd5+lXSxrULH3dEgGbMbqv6A2Mct62q0d37xbZ
|
51
|
+
eJHPimy7WMwm42m1uFsssou8ufvF3S9+8v6TF09/4t0XT093v3xzsf+C/v6i
|
52
|
+
vP8kWz5Z/t5vn7U/9WZ69cWbL37w5Zuf+MEXV7/n7zn+/X9yd/z7v/697+3t
|
53
|
+
jH96dUGdvVovW6I/9baXzusmPUgXxbLBF4Ty8oI+fzC+T3/+ZEXY0V+79+4f
|
54
|
+
7O3QB2dP6a+23bl378HDBwf0QVvRKKsvcsH9YM9+dAZs6aNpXrfFeUEsYb6x
|
55
|
+
fXw6dhBe5ZdFfsV9PXSfEv81c3z2qQP8qmrbfEkf3vuUPnuVN6tq2aCnN/U6
|
56
|
+
/+iX/D8kLc6swgIAAA==
|
57
|
+
|
58
|
+
http_version: "1.1"
|
59
|
+
- !ruby/struct:VCR::HTTPInteraction
|
60
|
+
request: !ruby/struct:VCR::Request
|
61
|
+
method: :get
|
62
|
+
uri: http://www.imdbapi.com:80/?i=tt0337978
|
63
|
+
body:
|
64
|
+
headers:
|
65
|
+
accept:
|
66
|
+
- "*/*; q=0.5, application/xml"
|
67
|
+
accept-encoding:
|
68
|
+
- gzip, deflate
|
69
|
+
timeout:
|
70
|
+
- "10"
|
71
|
+
response: !ruby/struct:VCR::Response
|
72
|
+
status: !ruby/struct:VCR::ResponseStatus
|
73
|
+
code: 200
|
74
|
+
message: OK
|
75
|
+
headers:
|
76
|
+
cache-control:
|
77
|
+
- no-cache
|
78
|
+
pragma:
|
79
|
+
- no-cache
|
80
|
+
content-type:
|
81
|
+
- text/html; charset=utf-8
|
82
|
+
content-encoding:
|
83
|
+
- gzip
|
84
|
+
expires:
|
85
|
+
- "-1"
|
86
|
+
vary:
|
87
|
+
- Accept-Encoding
|
88
|
+
server:
|
89
|
+
- Microsoft-IIS/7.0
|
90
|
+
x-aspnet-version:
|
91
|
+
- 4.0.30319
|
92
|
+
x-powered-by:
|
93
|
+
- ASP.NET
|
94
|
+
date:
|
95
|
+
- Sat, 30 Apr 2011 03:37:32 GMT
|
96
|
+
content-length:
|
97
|
+
- "583"
|
98
|
+
body: !binary |
|
99
|
+
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3m
|
100
|
+
kuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZk
|
101
|
+
AWz2zkrayZ4hgKrIHz9+fB8/In7xR2+Ktsw/evTR8+IyT5/VeZ5Wdfq0yNNv
|
102
|
+
Z/Xso9FHv0+e1fT13s7OA/rrVdbmM/rz5efbu/fwd17mWcMf7T1Iv7Neptrw
|
103
|
+
83xZA+zxtC2q5Sg9qYtFPkrfzOuiLPOaWjwt6nzaVgD+PF+m3y2afJEt6Yvv
|
104
|
+
1kVLLR599EVWv02fVItJNn07Sv2/qBUBruqGWj2p19OcXi/LohkRCk1bLNPn
|
105
|
+
1fKCeisWVTu/Tr8sr1fzbNkCyMUFje0nCMDLsmrp9e9U82X6xfSkzJZ52mZv
|
106
|
+
8yatlmm2TM+WhMUyb7cnGGBKf9RVXTQt0eciWxY/yDCw9GpepUWTNtdNS+i3
|
107
|
+
xTQry+u0ma9bQuMinVVXy7Sd5+lXSxrULH3dEgGbMbqv6A2Mct62q0d37xbZ
|
108
|
+
eJHPimy7WMwm42m1uFsssou8ufvF3S9+8v6TF09/4t0XT093v3xzsf+C/v6i
|
109
|
+
vP8kWz5Z/t5vn7U/9WZ69cWbL37w5Zuf+MEXV7/n7zn+/X9yd/z7v/697+3t
|
110
|
+
jH96dUGdvVovW6I/9baXzusmPUgXxbLBF4Ty8oI+fzC+T3/+ZEXY0V+79+4f
|
111
|
+
7O3QB2dP6a+23bl378HDBwf0wau8WVXLBqDe1Ov8o1/y/wDvqZN0QgIAAA==
|
112
|
+
|
113
|
+
http_version: "1.1"
|
@@ -0,0 +1,203 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://www.imdbapi.com:80/?i=1
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
accept:
|
9
|
+
- "*/*; q=0.5, application/xml"
|
10
|
+
accept-encoding:
|
11
|
+
- gzip, deflate
|
12
|
+
timeout:
|
13
|
+
- "10"
|
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 00:15:40 GMT
|
39
|
+
content-length:
|
40
|
+
- "144"
|
41
|
+
body: !binary |
|
42
|
+
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3m
|
43
|
+
kuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZk
|
44
|
+
AWz2zkrayZ4hgKrIHz9+fB8/In7xR6/yZlUtm/yjRx+9zOomT0/ruqo/+iX/
|
45
|
+
D1RQWLAaAAAA
|
46
|
+
|
47
|
+
http_version: "1.1"
|
48
|
+
- !ruby/struct:VCR::HTTPInteraction
|
49
|
+
request: !ruby/struct:VCR::Request
|
50
|
+
method: :get
|
51
|
+
uri: http://www.imdbapi.com:80/?i=tt1285016%5B%5D
|
52
|
+
body:
|
53
|
+
headers:
|
54
|
+
accept:
|
55
|
+
- "*/*; q=0.5, application/xml"
|
56
|
+
accept-encoding:
|
57
|
+
- gzip, deflate
|
58
|
+
timeout:
|
59
|
+
- "10"
|
60
|
+
response: !ruby/struct:VCR::Response
|
61
|
+
status: !ruby/struct:VCR::ResponseStatus
|
62
|
+
code: 200
|
63
|
+
message: OK
|
64
|
+
headers:
|
65
|
+
cache-control:
|
66
|
+
- no-cache
|
67
|
+
pragma:
|
68
|
+
- no-cache
|
69
|
+
content-type:
|
70
|
+
- text/html; charset=utf-8
|
71
|
+
content-encoding:
|
72
|
+
- gzip
|
73
|
+
expires:
|
74
|
+
- "-1"
|
75
|
+
vary:
|
76
|
+
- Accept-Encoding
|
77
|
+
server:
|
78
|
+
- Microsoft-IIS/7.0
|
79
|
+
x-aspnet-version:
|
80
|
+
- 4.0.30319
|
81
|
+
x-powered-by:
|
82
|
+
- ASP.NET
|
83
|
+
date:
|
84
|
+
- Sat, 30 Apr 2011 00:22:55 GMT
|
85
|
+
content-length:
|
86
|
+
- "144"
|
87
|
+
body: !binary |
|
88
|
+
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3m
|
89
|
+
kuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZk
|
90
|
+
AWz2zkrayZ4hgKrIHz9+fB8/In7xR6/yZlUtm/yjRx+9zOomT0/ruqo/+iX/
|
91
|
+
D1RQWLAaAAAA
|
92
|
+
|
93
|
+
http_version: "1.1"
|
94
|
+
- !ruby/struct:VCR::HTTPInteraction
|
95
|
+
request: !ruby/struct:VCR::Request
|
96
|
+
method: :get
|
97
|
+
uri: http://www.imdbapi.com:80/?i=tt0066026
|
98
|
+
body:
|
99
|
+
headers:
|
100
|
+
accept:
|
101
|
+
- "*/*; q=0.5, application/xml"
|
102
|
+
accept-encoding:
|
103
|
+
- gzip, deflate
|
104
|
+
timeout:
|
105
|
+
- "10"
|
106
|
+
response: !ruby/struct:VCR::Response
|
107
|
+
status: !ruby/struct:VCR::ResponseStatus
|
108
|
+
code: 200
|
109
|
+
message: OK
|
110
|
+
headers:
|
111
|
+
cache-control:
|
112
|
+
- no-cache
|
113
|
+
pragma:
|
114
|
+
- no-cache
|
115
|
+
content-type:
|
116
|
+
- text/html; charset=utf-8
|
117
|
+
content-encoding:
|
118
|
+
- gzip
|
119
|
+
expires:
|
120
|
+
- "-1"
|
121
|
+
vary:
|
122
|
+
- Accept-Encoding
|
123
|
+
server:
|
124
|
+
- Microsoft-IIS/7.0
|
125
|
+
x-aspnet-version:
|
126
|
+
- 4.0.30319
|
127
|
+
x-powered-by:
|
128
|
+
- ASP.NET
|
129
|
+
date:
|
130
|
+
- Sat, 30 Apr 2011 00:26:08 GMT
|
131
|
+
content-length:
|
132
|
+
- "571"
|
133
|
+
body: !binary |
|
134
|
+
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3m
|
135
|
+
kuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZk
|
136
|
+
AWz2zkrayZ4hgKrIHz9+fB8/In7xR2+Ktsw/evTRF8evv/3R6KPfJ89q+mv3
|
137
|
+
4YMd+utV1uYz+vPl5/gjL/Os4b+/yOpUm3yeL2u8f1It8tn1KP1uVo/Sp3W2
|
138
|
+
yOjLp0WdT9sKEF9Vk7xu0+OyXWRL+uq7ddHm/EUxnWf1LP12Vb3N6d1XxfIi
|
139
|
+
fU6fLPM6/U49prbHgNFQ26fVMitn6et1O8/rMlvORulpWRZV26afV+uS/nxT
|
140
|
+
LdLXBIegt6P0dVaW1+nvlZdlXku3L8uqJUBv5nnatNn5eVqdp1n6e1V1ni2B
|
141
|
+
e3pe5NTDvGpWRZuV6brJ0/l6UdUp9ZbOi58ulm+btK3St3m+SgmNok6bbFm0
|
142
|
+
12mxxN/peTbNARW/z6u6plfpr6uMR/KyamTU87ZdPbp7t8jGRLYi2y4Ws8l4
|
143
|
+
Wi3uFovsIm/ufnH3i5+8/+SLnz5998XT0/sv3vzED17g7/L+k2z5ZPl7v33W
|
144
|
+
/tSb6dUXTy92vnjz+1x/8RO/5+85/v1/cnf8+7/+ve/t7Yx/enVBnb1aL9ti
|
145
|
+
gcnZTed1en8vXRTLBl9kLRGZPn8wfkB//mTV5qDu3sOHe7v099lT+qNtd3Y+
|
146
|
+
/XRn71P64FXerKplA0hv6nX+0S/5fwDW8LMaNwIAAA==
|
147
|
+
|
148
|
+
http_version: "1.1"
|
149
|
+
- !ruby/struct:VCR::HTTPInteraction
|
150
|
+
request: !ruby/struct:VCR::Request
|
151
|
+
method: :get
|
152
|
+
uri: http://www.imdbapi.com:80/?i=tt1285016
|
153
|
+
body:
|
154
|
+
headers:
|
155
|
+
accept:
|
156
|
+
- "*/*; q=0.5, application/xml"
|
157
|
+
accept-encoding:
|
158
|
+
- gzip, deflate
|
159
|
+
timeout:
|
160
|
+
- "10"
|
161
|
+
response: !ruby/struct:VCR::Response
|
162
|
+
status: !ruby/struct:VCR::ResponseStatus
|
163
|
+
code: 200
|
164
|
+
message: OK
|
165
|
+
headers:
|
166
|
+
cache-control:
|
167
|
+
- no-cache
|
168
|
+
pragma:
|
169
|
+
- no-cache
|
170
|
+
content-type:
|
171
|
+
- text/html; charset=utf-8
|
172
|
+
content-encoding:
|
173
|
+
- gzip
|
174
|
+
expires:
|
175
|
+
- "-1"
|
176
|
+
vary:
|
177
|
+
- Accept-Encoding
|
178
|
+
server:
|
179
|
+
- Microsoft-IIS/7.0
|
180
|
+
x-aspnet-version:
|
181
|
+
- 4.0.30319
|
182
|
+
x-powered-by:
|
183
|
+
- ASP.NET
|
184
|
+
date:
|
185
|
+
- Sat, 30 Apr 2011 03:37:29 GMT
|
186
|
+
content-length:
|
187
|
+
- "550"
|
188
|
+
body: !binary |
|
189
|
+
H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3m
|
190
|
+
kuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZk
|
191
|
+
AWz2zkrayZ4hgKrIHz9+fB8/In7xR2+Ktsw/evTRm3mevq6mRVamL/L2qqrf
|
192
|
+
fjT66PfJs5q+29vZ3aG/XmVtPqM/X36+vXsPf+dlnjX80W765bRNtd3n+bIG
|
193
|
+
yCdFdVFnq/n1KH1aZ4tslH67aNqqvqY2T4s6n9Lv1OxpdlnM0mfFcjrPa/rq
|
194
|
+
u3XR0i+PPjrO6mpJSNVvi+UofZIv0y/yH9TFdE6NjvFyQ42+kzdNnp4WTb6c
|
195
|
+
5PXFKD1ezur8Kv08q8+LvJyN0u+sm7ZYpm+KBTUos7f5KH1VVcv8Ov0iqzOC
|
196
|
+
9bKsWoJ0nE7n1GExLfO0Ok9bIsh5tV7OiuUF/n6WTfNJVb0d8TcNk2p7KaRC
|
197
|
+
k+/mk7QhzMeAWDUyhHnbrh7dvVtk40U+K7LtYjGbjKfV4m6xyC7y5u4Xd7/4
|
198
|
+
yftPvnjzxd6XT9/uvHh6fPXFM/q7vP8kWz5Z/t5vn7U/9WZ69eLNF7tfPJ3u
|
199
|
+
fXH1e/6e49//J3fHv//r3/ve3s74p1cX1Nmr9bItFiD4XjonmtAnGQ34gj44
|
200
|
+
GO/Snz9ZtTlItbvz8OBTTNzZU/qrbXf3Du7v7H5KH7zKm1W1bADjTb3OP/ol
|
201
|
+
/w9JJy5xGAIAAA==
|
202
|
+
|
203
|
+
http_version: "1.1"
|
data/spec/movies_spec.rb
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Movies do
|
4
|
+
|
5
|
+
context "#find_by_id" do
|
6
|
+
it "should raise an error if wrong params is being passed" do
|
7
|
+
["aa123", "tt123", "123", nil, ""].each do |id|
|
8
|
+
lambda {
|
9
|
+
Movies.find_by_id(id)
|
10
|
+
}.should raise_error(ArgumentError, "The id is not valid.")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "#find_by_title" do
|
16
|
+
it "should raise an error if wrong params is being passed" do
|
17
|
+
[nil, ""].each do |title|
|
18
|
+
lambda {
|
19
|
+
Movies.find_by_title(title)
|
20
|
+
}.should raise_error(ArgumentError, "Title can not be blank.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "#find_by_release_name" do
|
26
|
+
it "should raise an error if wrong params is being passed" do
|
27
|
+
[nil, ""].each do |title|
|
28
|
+
lambda {
|
29
|
+
Movies.find_by_release_name(title)
|
30
|
+
}.should raise_error(ArgumentError, "Title can not be blank.")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "true-grit-1969" do
|
35
|
+
use_vcr_cassette "true-grit-1969"
|
36
|
+
|
37
|
+
it "should be possible to search for a release name containg a year" do
|
38
|
+
Movies.find_by_release_name("True.Grit.DVDRip.1969.XviD-AMIABLE").year.should eq(1969)
|
39
|
+
end
|
40
|
+
|
41
|
+
after(:each) do
|
42
|
+
a_request(:get, "http://www.imdbapi.com/?t=True%20Grit&y=1969").should have_been_made.once
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "true-grit-2010" do
|
47
|
+
use_vcr_cassette "true-grit-2010"
|
48
|
+
|
49
|
+
it "should be possible to search for a release name containg a year" do
|
50
|
+
Movies.find_by_release_name("True.Grit.DVDRip.2010.XviD-AMIABLE").year.should eq(2010)
|
51
|
+
end
|
52
|
+
|
53
|
+
after(:each) do
|
54
|
+
a_request(:get, "http://www.imdbapi.com/?t=True%20Grit&y=2010").should have_been_made.once
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not be possible to pass the callback option" do
|
60
|
+
lambda {
|
61
|
+
Movies.new("http://www.imdbapi.com/?i=tt1285016", {
|
62
|
+
callback: "random"
|
63
|
+
})
|
64
|
+
}.should raise_error(ArgumentError, "Passing the callback option makes not sense.")
|
65
|
+
end
|
66
|
+
|
67
|
+
context "tt1285016" do
|
68
|
+
use_vcr_cassette "tt1285016"
|
69
|
+
|
70
|
+
it "should contain the right content" do
|
71
|
+
|
72
|
+
movie = Movies.new("http://www.imdbapi.com/?i=tt1285016").prepare
|
73
|
+
movie.year.should eq(2010)
|
74
|
+
movie.rated.should eq("PG-13")
|
75
|
+
movie.released.should eq(Date.parse("1 Oct 2010"))
|
76
|
+
movie.should have(3).genres
|
77
|
+
movie.genres.should include("Biography")
|
78
|
+
movie.should have(2).writers
|
79
|
+
movie.writers.should include("Aaron Sorkin")
|
80
|
+
movie.should have(4).actors
|
81
|
+
movie.actors.should include("Andrew Garfield")
|
82
|
+
movie.plot.should_not be_empty
|
83
|
+
movie.poster.should match(URI.regexp)
|
84
|
+
movie.runtime.should eq(120)
|
85
|
+
movie.rating.should eq(8.1)
|
86
|
+
movie.votes.should eq(109863)
|
87
|
+
movie.id.should eq("tt1285016")
|
88
|
+
movie.director.should eq("David Fincher")
|
89
|
+
movie.href.should eq("http://www.imdb.com/title/tt1285016/")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "tt0066026" do
|
94
|
+
use_vcr_cassette "tt0066026"
|
95
|
+
it "should be possible to pass params" do
|
96
|
+
Movies.new("http://www.imdbapi.com/?i=tt0066026", {
|
97
|
+
y: "1970"
|
98
|
+
}).prepare
|
99
|
+
|
100
|
+
a_request(:get, "http://www.imdbapi.com/?i=tt0066026&y=1970").should have_been_made.once
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context "not_found" do
|
105
|
+
use_vcr_cassette "not_found"
|
106
|
+
it "should be set to not found" do
|
107
|
+
Movies.new("http://www.imdbapi.com/?i=ttrandom").prepare.should_not be_found
|
108
|
+
|
109
|
+
a_request(:get, "http://www.imdbapi.com/?i=ttrandom").should have_been_made.once
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "bug1" do
|
114
|
+
use_vcr_cassette "bug1"
|
115
|
+
it "should not raise an error when date is invalid" do
|
116
|
+
lambda {
|
117
|
+
Movies.new("http://www.imdbapi.com/?t=Consinsual&y=2010").prepare.released.should be_nil
|
118
|
+
}.should_not raise_error
|
119
|
+
a_request(:get, "http://www.imdbapi.com/?t=Consinsual&y=2010").should have_been_made.once
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "tomatoes" do
|
124
|
+
use_vcr_cassette "tt0337978"
|
125
|
+
|
126
|
+
it "should be possible to fetch tomatoes specific data" do
|
127
|
+
movie = Movies.new("http://www.imdbapi.com/?i=tt0337978", {
|
128
|
+
tomatoes: "true"
|
129
|
+
}).prepare
|
130
|
+
|
131
|
+
movie.tomato.meter.should eq(82)
|
132
|
+
movie.tomato.image.should eq("certified")
|
133
|
+
movie.tomato.rating.should eq(6.8)
|
134
|
+
movie.tomato.reviews.should eq(198)
|
135
|
+
movie.tomato.fresh.should eq(162)
|
136
|
+
movie.tomato.rotten.should eq(36)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should raise an error if trying to fetch tomato data without passing the tomato option" do
|
140
|
+
lambda {
|
141
|
+
Movies.new("http://www.imdbapi.com/?i=tt0337978").prepare.tomato
|
142
|
+
}.should raise_error(ArgumentError, "You have to set 'tomatoes' to true to get this data.")
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|