tmdb-api 0.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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +148 -0
  7. data/Rakefile +1 -0
  8. data/lib/tmdb.rb +18 -0
  9. data/lib/tmdb/changes.rb +22 -0
  10. data/lib/tmdb/fetcher.rb +30 -0
  11. data/lib/tmdb/movie.rb +105 -0
  12. data/lib/tmdb/searchable.rb +33 -0
  13. data/lib/tmdb/version.rb +3 -0
  14. data/spec/fixtures/alternative_titles.json +41 -0
  15. data/spec/fixtures/alternative_titles_by_country.json +9 -0
  16. data/spec/fixtures/changes/movie_changes.json +407 -0
  17. data/spec/fixtures/changes/movie_changes_page_2.json +407 -0
  18. data/spec/fixtures/changes/movie_changes_start_date.json +407 -0
  19. data/spec/fixtures/find_movie.json +19 -0
  20. data/spec/fixtures/find_movie_by_id.json +85 -0
  21. data/spec/fixtures/find_movie_by_id_and_language.json +66 -0
  22. data/spec/fixtures/invalid_id.json +4 -0
  23. data/spec/fixtures/movie/upcoming.json +251 -0
  24. data/spec/fixtures/movie/upcoming_page_2.json +251 -0
  25. data/spec/fixtures/movie_images.json +214 -0
  26. data/spec/fixtures/movie_images_by_language.json +42 -0
  27. data/spec/fixtures/movie_keywords.json +33 -0
  28. data/spec/fixtures/movie_releases.json +35 -0
  29. data/spec/fixtures/no_results.json +6 -0
  30. data/spec/fixtures/search_movie_by_name.json +91 -0
  31. data/spec/fixtures/search_movie_by_name_and_adult_filter.json +55 -0
  32. data/spec/fixtures/search_movie_by_name_and_page.json +247 -0
  33. data/spec/fixtures/search_movie_by_name_and_year.json +19 -0
  34. data/spec/spec_helper.rb +19 -0
  35. data/spec/support/stubber.rb +33 -0
  36. data/spec/tmdb/changes_spec.rb +52 -0
  37. data/spec/tmdb/movie/upcoming_spec.rb +28 -0
  38. data/spec/tmdb/movie_spec.rb +473 -0
  39. data/spec/tmdb/searchable_spec.rb +9 -0
  40. data/spec/tmdb/tmdb_spec.rb +13 -0
  41. data/tmdb.gemspec +28 -0
  42. metadata +195 -0
@@ -0,0 +1,247 @@
1
+ {
2
+ "page": 2,
3
+ "results": [
4
+ {
5
+ "adult": false,
6
+ "backdrop_path": "/sNqj5kwBRxz91xJWFxgYRsdXuyp.jpg",
7
+ "id": 119199,
8
+ "original_title": "Arena of the Street Fighter",
9
+ "release_date": "2012-07-26",
10
+ "poster_path": "/8OFWwM7MeqZDXsLsZm4q6vLU1zB.jpg",
11
+ "popularity": 0.4,
12
+ "title": "Arena of the Street Fighter",
13
+ "vote_average": 0.5,
14
+ "vote_count": 1
15
+ },
16
+ {
17
+ "adult": false,
18
+ "backdrop_path": "/3UNBXbqijQFq45OqMJJgiSK4tDV.jpg",
19
+ "id": 17336,
20
+ "original_title": "Fighting",
21
+ "release_date": "2009-04-24",
22
+ "poster_path": "/4XQfxCYdZsyBBrg6bSGm5XfKPlH.jpg",
23
+ "popularity": 1.6060113774468765,
24
+ "title": "Fighting",
25
+ "vote_average": 7.2,
26
+ "vote_count": 3
27
+ },
28
+ {
29
+ "adult": false,
30
+ "backdrop_path": null,
31
+ "id": 75837,
32
+ "original_title": "Nan bei tui wang",
33
+ "release_date": "1980-01-01",
34
+ "poster_path": "/mKUMWdn9JErOVFyWF9F4QWqBOwW.jpg",
35
+ "popularity": 0.2,
36
+ "title": "The Leg Fighters",
37
+ "vote_average": 0,
38
+ "vote_count": 0
39
+ },
40
+ {
41
+ "adult": false,
42
+ "backdrop_path": "/98AJnQXRG6GB33DnE6BjQlk44VY.jpg",
43
+ "id": 157919,
44
+ "original_title": "Knife Fight",
45
+ "release_date": "2013-01-25",
46
+ "poster_path": "/4dsaLWsiHSwk3hAzBGVmikqnGKR.jpg",
47
+ "popularity": 0.3781471851,
48
+ "title": "Knife Fight",
49
+ "vote_average": 0,
50
+ "vote_count": 0
51
+ },
52
+ {
53
+ "adult": false,
54
+ "backdrop_path": null,
55
+ "id": 167614,
56
+ "original_title": "ストリートファイターⅡ よみがえる藤原京",
57
+ "release_date": "1995-03-29",
58
+ "poster_path": "/eKssUtIj7ZttjrYUYwHX7gcBz0A.jpg",
59
+ "popularity": 0.2,
60
+ "title": "Street Fighter II: Return to Fujiwara Capital",
61
+ "vote_average": 0,
62
+ "vote_count": 0
63
+ },
64
+ {
65
+ "adult": false,
66
+ "backdrop_path": null,
67
+ "id": 188371,
68
+ "original_title": "Cock fight, no. 2",
69
+ "release_date": "1894-01-01",
70
+ "poster_path": null,
71
+ "popularity": 0.46,
72
+ "title": "Cock fight, no. 2",
73
+ "vote_average": 0,
74
+ "vote_count": 0
75
+ },
76
+ {
77
+ "adult": false,
78
+ "backdrop_path": null,
79
+ "id": 149692,
80
+ "original_title": "I vendicatori dell'Ave Maria",
81
+ "release_date": "1970-10-15",
82
+ "poster_path": "/7xVWoFd8ekfI1gafOmzaqklc0Ok.jpg",
83
+ "popularity": 0.278,
84
+ "title": "Fighters from Ave Maria",
85
+ "vote_average": 0,
86
+ "vote_count": 0
87
+ },
88
+ {
89
+ "adult": false,
90
+ "backdrop_path": "/kx9hVXtX8iSbbCwCbuUovbKrWyH.jpg",
91
+ "id": 11667,
92
+ "original_title": "Street Fighter",
93
+ "release_date": "1994-12-22",
94
+ "poster_path": "/271l3Gs2Abis6JLQWaMNRjpCFV4.jpg",
95
+ "popularity": 0.473201532344,
96
+ "title": "Street Fighter",
97
+ "vote_average": 3.6,
98
+ "vote_count": 13
99
+ },
100
+ {
101
+ "adult": false,
102
+ "backdrop_path": null,
103
+ "id": 184474,
104
+ "original_title": "The Fighting Dude",
105
+ "release_date": "1925-12-05",
106
+ "poster_path": null,
107
+ "popularity": 0.398,
108
+ "title": "The Fighting Dude",
109
+ "vote_average": 0,
110
+ "vote_count": 0
111
+ },
112
+ {
113
+ "adult": false,
114
+ "backdrop_path": null,
115
+ "id": 91847,
116
+ "original_title": "Sister Street Fighter Fifth Level Fist",
117
+ "release_date": "1976-05-29",
118
+ "poster_path": "/J60vGUaoTQ1OW6mXe7osoo8MpL.jpg",
119
+ "popularity": 0.2,
120
+ "title": "Sister Street Fighter Fifth Level Fist",
121
+ "vote_average": 9,
122
+ "vote_count": 1
123
+ },
124
+ {
125
+ "adult": false,
126
+ "backdrop_path": null,
127
+ "id": 57258,
128
+ "original_title": "The Indian Fighter",
129
+ "release_date": "1955-12-21",
130
+ "poster_path": "/v6drilUdCMYFeg85WxOvscaXL42.jpg",
131
+ "popularity": 0.2,
132
+ "title": "The Indian Fighter",
133
+ "vote_average": 7,
134
+ "vote_count": 1
135
+ },
136
+ {
137
+ "adult": false,
138
+ "backdrop_path": null,
139
+ "id": 78027,
140
+ "original_title": "Fighting For Love",
141
+ "release_date": "2001-10-10",
142
+ "poster_path": "/5DjJV5vHMDOeFrwgxWmgcW14KMp.jpg",
143
+ "popularity": 0.4,
144
+ "title": "Fighting For Love",
145
+ "vote_average": 7.5,
146
+ "vote_count": 1
147
+ },
148
+ {
149
+ "adult": false,
150
+ "backdrop_path": null,
151
+ "id": 35038,
152
+ "original_title": "Long zai tian ya",
153
+ "release_date": "1989-01-01",
154
+ "poster_path": "/1my6YGbfLw44wNmpjPLsT6JoAZN.jpg",
155
+ "popularity": 0.46,
156
+ "title": "Dragon Fight",
157
+ "vote_average": 6,
158
+ "vote_count": 1
159
+ },
160
+ {
161
+ "adult": false,
162
+ "backdrop_path": null,
163
+ "id": 116524,
164
+ "original_title": "WWE: Greatest Street Fights, Falls Count Anywhere, and Other Out of Control Matches (Volume 2)",
165
+ "release_date": "2012-01-01",
166
+ "poster_path": null,
167
+ "popularity": 0.550306,
168
+ "title": "WWE: Greatest Street Fights, Falls Count Anywhere, and Other Out of Control Matches (Volume 2)",
169
+ "vote_average": 0,
170
+ "vote_count": 0
171
+ },
172
+ {
173
+ "adult": false,
174
+ "backdrop_path": null,
175
+ "id": 103210,
176
+ "original_title": "Fighting Back",
177
+ "release_date": "1982-05-21",
178
+ "poster_path": "/eGtL0MNKoSdJYamvC3fnxc0D1HP.jpg",
179
+ "popularity": 0.4,
180
+ "title": "Fighting Back",
181
+ "vote_average": 0,
182
+ "vote_count": 0
183
+ },
184
+ {
185
+ "adult": false,
186
+ "backdrop_path": null,
187
+ "id": 30817,
188
+ "original_title": "Stealth Fighter",
189
+ "release_date": "1999-01-01",
190
+ "poster_path": "/gw0y3MRSOogA72ZAGfHfu4DxjKy.jpg",
191
+ "popularity": 0.2888,
192
+ "title": "Stealth Fighter",
193
+ "vote_average": 0,
194
+ "vote_count": 0
195
+ },
196
+ {
197
+ "adult": false,
198
+ "backdrop_path": null,
199
+ "id": 190138,
200
+ "original_title": "The Fighting 69½th",
201
+ "release_date": "1941-01-18",
202
+ "poster_path": "/2CeUT4SZ8CuGHF6akQyecIAbiqm.jpg",
203
+ "popularity": 0.6000000000000001,
204
+ "title": "The Fighting 69½th",
205
+ "vote_average": 0,
206
+ "vote_count": 0
207
+ },
208
+ {
209
+ "adult": false,
210
+ "backdrop_path": null,
211
+ "id": 89472,
212
+ "original_title": "Fire Fight",
213
+ "release_date": null,
214
+ "poster_path": null,
215
+ "popularity": 0.4,
216
+ "title": "Fire Fight",
217
+ "vote_average": 2,
218
+ "vote_count": 1
219
+ },
220
+ {
221
+ "adult": false,
222
+ "backdrop_path": "/qgdL7ehlZybEEMY8vqoNPatULFx.jpg",
223
+ "id": 182127,
224
+ "original_title": "Ip Man: The Final Fight",
225
+ "release_date": "2013-03-28",
226
+ "poster_path": "/evektz5IWITLOd1MdVboewwSH1Q.jpg",
227
+ "popularity": 1.0476,
228
+ "title": "Ip Man: The Final Fight",
229
+ "vote_average": 0,
230
+ "vote_count": 0
231
+ },
232
+ {
233
+ "adult": false,
234
+ "backdrop_path": null,
235
+ "id": 62328,
236
+ "original_title": "Shootfighter: Fight to the Death",
237
+ "release_date": "1993-05-05",
238
+ "poster_path": "/A19LO7ykBXoIVdh0QZ4yD4xoVCt.jpg",
239
+ "popularity": 0.6000000000000001,
240
+ "title": "Shootfighter: Fight to the Death",
241
+ "vote_average": 4.5,
242
+ "vote_count": 1
243
+ }
244
+ ],
245
+ "total_pages": 16,
246
+ "total_results": 307
247
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "page": 1,
3
+ "results": [
4
+ {
5
+ "adult": false,
6
+ "backdrop_path": "/gM3KKiN80qbJgKHjPnmAfwxSicG.jpg",
7
+ "id": 603,
8
+ "original_title": "The Matrix",
9
+ "release_date": "1999-03-30",
10
+ "poster_path": "/gynBNzwyaHKtXqlEKKLioNkjKgN.jpg",
11
+ "popularity": 7.94015698023987,
12
+ "title": "The Matrix",
13
+ "vote_average": 8.5,
14
+ "vote_count": 364
15
+ }
16
+ ],
17
+ "total_pages": 1,
18
+ "total_results": 1
19
+ }
@@ -0,0 +1,19 @@
1
+ require 'tmdb'
2
+ require 'rspec'
3
+ require 'webmock/rspec'
4
+
5
+ # Load all support files
6
+ Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|r| require r}
7
+
8
+ # Fake API Key
9
+ TMDb.api_key = '56565958363476674e5e63643c787867'
10
+
11
+ RSpec.configure do |config|
12
+ config.expect_with :rspec do |c|
13
+
14
+ # Set RSpec to accept only the new syntax.
15
+ # http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
16
+ c.syntax = :expect
17
+ end
18
+ end
19
+
@@ -0,0 +1,33 @@
1
+ def stub_get(url, options = {}, key = true)
2
+ stub_request(:get, tmdb_url(url, key))
3
+ end
4
+
5
+ # Retuns absolute path of fixtures directory.
6
+ def fixture_path
7
+ File.expand_path('../../fixtures', __FILE__)
8
+ end
9
+
10
+ # Returns the fixture File object given a file.
11
+ def fixture(file)
12
+ File.new(fixture_path + '/' + file)
13
+ end
14
+
15
+ # Set the stub return to be JSON.
16
+ def json_response(file, status = 200)
17
+ options = {
18
+ :body => fixture(file),
19
+ :headers => {
20
+ :content_type => 'application/json; charset=utf-8'
21
+ },
22
+ :status => status
23
+ }
24
+ end
25
+
26
+ # Returns the entire URL of TMDb API.
27
+ def tmdb_url(url, key)
28
+ if key
29
+ "http://api.themoviedb.org/3#{url}?api_key=#{TMDb.api_key}"
30
+ else
31
+ "http://api.themoviedb.org/3#{url}?api_key="
32
+ end
33
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe TMDb::Changes do
4
+ describe '.movies' do
5
+ it 'returns the changed movies' do
6
+ stub_get('/movie/changes').to_return(json_response('changes/movie_changes.json'))
7
+
8
+ changes = TMDb::Changes.movies
9
+
10
+ expect(changes['results']).to have(100).items
11
+ expect(changes['total_results']).to eql(4645)
12
+ expect(changes['total_pages']).to eql(47)
13
+ expect(changes['page']).to eql(1)
14
+ expect(changes['results'].first).to eql({
15
+ 'id' => 128149,
16
+ 'adult' => false
17
+ })
18
+ end
19
+
20
+ it 'returns the changed movies of page 2' do
21
+ stub_get('/movie/changes').with(query: { page: 2 }).
22
+ to_return(json_response('changes/movie_changes_page_2.json'))
23
+
24
+ changes = TMDb::Changes.movies(page: 2)
25
+
26
+ expect(changes['results']).to have(100).items
27
+ expect(changes['total_results']).to eql(4648)
28
+ expect(changes['total_pages']).to eql(47)
29
+ expect(changes['page']).to eql(2)
30
+ expect(changes['results'].first).to eql({
31
+ 'id' => 163536,
32
+ 'adult' => false
33
+ })
34
+ end
35
+
36
+ it 'returns the changed movies filtered by start_date' do
37
+ stub_get('/movie/changes').with(query: { start_date: '2013-07-05' }).
38
+ to_return(json_response('changes/movie_changes_start_date.json'))
39
+
40
+ changes = TMDb::Changes.movies(start_date: '2013-07-05')
41
+
42
+ expect(changes['results']).to have(100).items
43
+ expect(changes['total_results']).to eql(773)
44
+ expect(changes['total_pages']).to eql(8)
45
+ expect(changes['page']).to eql(1)
46
+ expect(changes['results'].first).to eql({
47
+ 'id' => 205372,
48
+ 'adult' => false
49
+ })
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe TMDb::Movie do
4
+ describe '.upcoming' do
5
+ it 'returns the upcoming movies' do
6
+ stub_get('/movie/upcoming').to_return(json_response('movie/upcoming.json'))
7
+
8
+ upcoming = TMDb::Movie.upcoming
9
+
10
+ expect(upcoming).to have(20).movies
11
+ expect(upcoming.first.id).to eql(68726)
12
+ expect(upcoming.first.title).to eql('Pacific Rim')
13
+ end
14
+
15
+ it 'returns the upcoming movies of page 2' do
16
+ stub_get('/movie/upcoming').with(query: { page: 2 }).
17
+ to_return(json_response('movie/upcoming_page_2.json'))
18
+
19
+ upcoming = TMDb::Movie.upcoming(page: 2)
20
+
21
+ # TODO: find a way to return the page number, total_pages and total_results
22
+ # expect(page).to eql(2)
23
+ expect(upcoming).to have(20).movies
24
+ expect(upcoming.first.id).to eql(185407)
25
+ expect(upcoming.first.title).to eql('Israel: A Home Movie / Kach Ra’inu')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,473 @@
1
+ require "spec_helper"
2
+
3
+ describe TMDb::Movie do
4
+ describe ".search" do
5
+ it "searches movies given only the movie name" do
6
+ stub_get('/search/movie').with(query: { query: 'The Lord of the Rings' })
7
+ .to_return(json_response('search_movie_by_name.json'))
8
+
9
+ movies = TMDb::Movie.search("The Lord of the Rings")
10
+
11
+ expect(movies).to have(7).items
12
+
13
+ expect(movies.first.adult).to eq(false)
14
+ expect(movies.first.backdrop_path).to eq("/pIUvQ9Ed35wlWhY2oU6OmwEsmzG.jpg")
15
+ expect(movies.first.id).to eq(120)
16
+ expect(movies.first.original_title).to eq("The Lord of the Rings: The Fellowship of the Ring")
17
+ expect(movies.first.release_date).to eq("2001-12-19")
18
+ expect(movies.first.poster_path).to eq("/9HG6pINW1KoFTAKY3LdybkoOKAm.jpg")
19
+ expect(movies.first.popularity).to eq(10.895025450078979)
20
+ expect(movies.first.title).to eq("The Lord of the Rings: The Fellowship of the Ring")
21
+ expect(movies.first.vote_average).to eq(8.3)
22
+ expect(movies.first.vote_count).to eq(187)
23
+ end
24
+
25
+ it "searches movies given movie name and year" do
26
+ stub_get('/search/movie').with(query: { query: 'Matrix', year: 1999 })
27
+ .to_return(json_response('search_movie_by_name_and_year.json'))
28
+
29
+ movies = TMDb::Movie.search('Matrix', year: 1999)
30
+
31
+ expect(movies).to have(1).item
32
+
33
+ expect(movies.first.adult).to eq(false)
34
+ expect(movies.first.backdrop_path).to eq("/gM3KKiN80qbJgKHjPnmAfwxSicG.jpg")
35
+ expect(movies.first.id).to eq(603)
36
+ expect(movies.first.original_title).to eq("The Matrix")
37
+ expect(movies.first.release_date).to eq("1999-03-30")
38
+ expect(movies.first.poster_path).to eq("/gynBNzwyaHKtXqlEKKLioNkjKgN.jpg")
39
+ expect(movies.first.popularity).to eq(7.94015698023987)
40
+ expect(movies.first.title).to eq("The Matrix")
41
+ expect(movies.first.vote_average).to eq(8.5)
42
+ expect(movies.first.vote_count).to eq(364)
43
+ end
44
+
45
+ it "searches movies given movie name and page number" do
46
+ stub_get('/search/movie').with(query: { query: 'Fight', page: 2 })
47
+ .to_return(json_response('search_movie_by_name_and_page.json'))
48
+
49
+ movies = TMDb::Movie.search('Fight', page: 2)
50
+
51
+ expect(movies).to have(20).items
52
+
53
+ expect(movies.first.adult).to eq(false)
54
+ expect(movies.first.backdrop_path).to eq("/sNqj5kwBRxz91xJWFxgYRsdXuyp.jpg")
55
+ expect(movies.first.id).to eq(119199)
56
+ expect(movies.first.original_title).to eq("Arena of the Street Fighter")
57
+ expect(movies.first.release_date).to eq("2012-07-26")
58
+ expect(movies.first.poster_path).to eq("/8OFWwM7MeqZDXsLsZm4q6vLU1zB.jpg")
59
+ expect(movies.first.popularity).to eq(0.4)
60
+ expect(movies.first.title).to eq("Arena of the Street Fighter")
61
+ expect(movies.first.vote_average).to eq(0.5)
62
+ expect(movies.first.vote_count).to eq(1)
63
+ end
64
+
65
+ it "searches movies given movie name and adult filter" do
66
+ stub_get('/search/movie').with(query: { query: 'Gang Bang 5', include_adult: true.to_s })
67
+ .to_return(json_response('search_movie_by_name_and_adult_filter.json'))
68
+
69
+ movies = TMDb::Movie.search('Gang Bang 5', include_adult: true.to_s)
70
+
71
+ expect(movies).to have(4).items
72
+
73
+ expect(movies.first.adult).to eq(true)
74
+ expect(movies.first.backdrop_path).to eq(nil)
75
+ expect(movies.first.id).to eq(68025)
76
+ expect(movies.first.original_title).to eq("Gang Bang 5")
77
+ expect(movies.first.release_date).to eq(nil)
78
+ expect(movies.first.poster_path).to eq("/j2rfswcwXNSzYKORb5tJQO7u4UY.jpg")
79
+ expect(movies.first.popularity).to eq(0.4)
80
+ expect(movies.first.title).to eq("Gang Bang 5")
81
+ expect(movies.first.vote_average).to eq(0)
82
+ expect(movies.first.vote_count).to eq(0)
83
+ end
84
+
85
+ it "returns an empty array when no movies found" do
86
+ stub_get('/search/movie').with(query: { query: 'Inexistent Movie' })
87
+ .to_return(json_response('no_results.json'))
88
+
89
+ movies = TMDb::Movie.search('Inexistent Movie')
90
+
91
+ expect(movies).to match_array([])
92
+ end
93
+ end
94
+
95
+ describe ".find" do
96
+ it "find a movie given your ID" do
97
+ stub_get('/movie/24').to_return(json_response('find_movie_by_id.json'))
98
+
99
+ movie = TMDb::Movie.find(24)
100
+
101
+ expect(movie.adult).to eq(false)
102
+ expect(movie.backdrop_path).to eq("/hSaH9tt67bozo9K50sbH0s4YjEc.jpg")
103
+ expect(movie.belongs_to_collection).to eq(nil)
104
+ expect(movie.budget).to eq(3300000)
105
+ expect(movie.genres).to eq([
106
+ {
107
+ "id" => 28,
108
+ "name" => "Action"
109
+ },
110
+ {
111
+ "id" => 80,
112
+ "name" => "Crime"
113
+ },
114
+ {
115
+ "id" => 18,
116
+ "name" => "Drama"
117
+ },
118
+ {
119
+ "id" => 10769,
120
+ "name" => "Foreign"
121
+ }
122
+ ])
123
+ expect(movie.homepage).to eq('http://cidadededeus.globo.com/')
124
+ expect(movie.id).to eq(598)
125
+ expect(movie.imdb_id).to eq('tt0317248')
126
+ expect(movie.original_title).to eq("Cidade de Deus")
127
+ expect(movie.overview).to eq("City of God depicts the raw violence in the ghettos of Rio de Janeiro. In the 1970’s that kids are carrying guns and joining gangs when they should be playing hide-and-seek.")
128
+ expect(movie.popularity).to eq(1.3497251049225558)
129
+ expect(movie.poster_path).to eq("/mwDnSQR1CkxuDjSKfgiNT0sIOjM.jpg")
130
+ expect(movie.production_companies).to eq([
131
+ {
132
+ "name" => "O2 Filmes",
133
+ "id" => 345
134
+ },
135
+ {
136
+ "name" => "VideoFilmes",
137
+ "id" => 346
138
+ },
139
+ {
140
+ "name" => "Globo filmes",
141
+ "id" => 10954
142
+ },
143
+ {
144
+ "name" => "Lumiere",
145
+ "id" => 11444
146
+ },
147
+ {
148
+ "name" => "Wild Bunch",
149
+ "id" => 856
150
+ },
151
+ {
152
+ "name" => "Hank Levine Film",
153
+ "id" => 11445
154
+ },
155
+ {
156
+ "name" => "Lereby Productions",
157
+ "id" => 11446
158
+ }
159
+ ])
160
+ expect(movie.production_countries).to eq([
161
+ {
162
+ "iso_3166_1" => "BR",
163
+ "name" => "Brazil"
164
+ },
165
+ {
166
+ "iso_3166_1" => "FR",
167
+ "name" => "France"
168
+ }
169
+ ])
170
+ expect(movie.release_date).to eq("2002-08-31")
171
+ expect(movie.revenue).to eq(27387381)
172
+ expect(movie.runtime).to eq(130)
173
+ expect(movie.spoken_languages).to eq([
174
+ {
175
+ "iso_639_1" => "pt",
176
+ "name" => "Português"
177
+ }
178
+ ])
179
+ expect(movie.status).to eq("Released")
180
+ expect(movie.tagline).to eq("If you run you're dead...if you stay, you're dead again. Period.")
181
+ expect(movie.title).to eq("City of God")
182
+ expect(movie.vote_average).to eq(8.2)
183
+ expect(movie.vote_count).to eq(52)
184
+ end
185
+
186
+ it "find a movie given your ID and language" do
187
+ stub_get('/movie/550').with(query: { language: 'pt' })
188
+ .to_return(json_response('find_movie_by_id_and_language.json'))
189
+
190
+ movie = TMDb::Movie.find(550, language: 'pt')
191
+
192
+ expect(movie.adult).to eq(false)
193
+ expect(movie.backdrop_path).to eq("/kkS8PKa8c134vXsj2fQkNqOaCXU.jpg")
194
+ expect(movie.belongs_to_collection).to eq({
195
+ "id" => 2883,
196
+ "name" => "Kill Bill Collection",
197
+ "poster_path" => "/tf1nUtw3LJGUGv1EFFi23iz6ngr.jpg",
198
+ "backdrop_path" => "/oCLKNACMNrEf4T1EP6BpMXDl5m1.jpg"
199
+ })
200
+ expect(movie.budget).to eq(55000000)
201
+ expect(movie.genres).to eq([
202
+ {
203
+ "id" => 28,
204
+ "name" => "Ação"
205
+ },
206
+ {
207
+ "id" => 80,
208
+ "name" => "Crime"
209
+ },
210
+ {
211
+ "id" => 53,
212
+ "name" => "Thriller"
213
+ }
214
+ ])
215
+ expect(movie.homepage).to eq('')
216
+ expect(movie.id).to eq(24)
217
+ expect(movie.imdb_id).to eq('tt0266697')
218
+ expect(movie.original_title).to eq("Kill Bill: Vol. 1")
219
+ expect(movie.overview).to eq("Kill Bill presta uma grande homenagem aos filmes de Kung-fu das décadas de 60 e 70, seus atores e estilos. Dirigido com exímia presteza, a obra foi delicadamente produzida o que dá ao expectador um deleite frente às diversas mudanças de sensibilidade do filme, cenas em preto e branco, seqüências, sombras, ângulos de câmera e intertextualidade com outras mídias como o trecho do filme feito em anime e a sensacional trilha sonora que se tornou um dos deliciosos hábitos viciantes dos filmes de Tarantino. O primeiro volume do filme narra o início da vingança da ex-assassina Black Mamba (cujo nome real só nos é revelado ao final do segundo filme). Ao acordar do coma, Black Mamba percebe que foi a única sobrevivente do extermínio ocorrido no dia de seu casamento e que levara as vidas de todos a quem amava, inclusive do filho que levava no ventre. Ela começa então uma caçada impiedosa aos assassinos, seus ex-companheiros do esquadrão de assassinato Deadly Viper.")
220
+ expect(movie.popularity).to eq(2.884757761614897)
221
+ expect(movie.poster_path).to eq("/viscNSLi1rDyMuTytUojf0G2DIy.jpg")
222
+ expect(movie.production_companies).to eq([
223
+ {
224
+ "name" => "Miramax Films",
225
+ "id" => 14
226
+ },
227
+ {
228
+ "name" => "A Band Apart",
229
+ "id" => 59
230
+ }
231
+ ])
232
+ expect(movie.production_countries).to eq([
233
+ {
234
+ "iso_3166_1" => "JP",
235
+ "name" => "Japan"
236
+ },
237
+ {
238
+ "iso_3166_1" => "US",
239
+ "name" => "United States of America"
240
+ }
241
+ ])
242
+ expect(movie.release_date).to eq("2003-10-09")
243
+ expect(movie.revenue).to eq(180949000)
244
+ expect(movie.runtime).to eq(111)
245
+ expect(movie.spoken_languages).to eq([
246
+ {
247
+ "iso_639_1" => "en",
248
+ "name" => "English"
249
+ }
250
+ ])
251
+ expect(movie.status).to eq("Released")
252
+ expect(movie.tagline).to eq("")
253
+ expect(movie.title).to eq("Kill Bill - Volume 1")
254
+ expect(movie.vote_average).to eq(7.6)
255
+ expect(movie.vote_count).to eq(92)
256
+ end
257
+
258
+ it 'raises error with id not found' do
259
+ stub_get('/movie/1234').to_return(json_response('invalid_id.json', 404))
260
+ expect { TMDb::Movie.find(1234) }.to raise_error(ArgumentError)
261
+ end
262
+ end
263
+
264
+ describe "#alternative_titles" do
265
+ it "returns the alternative titles for a specific movie" do
266
+ stub_get('/movie/598').to_return(json_response('find_movie_by_id.json'))
267
+ stub_get('/movie/598/alternative_titles')
268
+ .to_return(json_response('alternative_titles.json'))
269
+
270
+ alternative_titles = TMDb::Movie.alternative_titles(598)
271
+
272
+ expect(alternative_titles).to match_array([
273
+ {
274
+ "iso_3166_1" => "RU",
275
+ "title" => "Город бога"
276
+ },
277
+ {
278
+ "iso_3166_1" => "IT",
279
+ "title" => "City of God - La città di Dio"
280
+ },
281
+ {
282
+ "iso_3166_1" => "BR",
283
+ "title" => "Cidade de Deus"
284
+ },
285
+ {
286
+ "iso_3166_1" => "FR",
287
+ "title" => "La cité de Dieu"
288
+ },
289
+ {
290
+ "iso_3166_1" => "DE",
291
+ "title" => "City of God"
292
+ },
293
+ {
294
+ "iso_3166_1" => "CN",
295
+ "title" => "上帝之城"
296
+ },
297
+ {
298
+ "iso_3166_1" => "HK",
299
+ "title" => "无主之城"
300
+ },
301
+ {
302
+ "iso_3166_1" => "US",
303
+ "title" => "City of God"
304
+ },
305
+ {
306
+ "iso_3166_1" => "TW",
307
+ "title" => "無法無天"
308
+ }
309
+ ])
310
+ end
311
+
312
+ it "returns the alternative titles for a specific movie and a specific country" do
313
+ stub_get('/movie/598').to_return(json_response('find_movie_by_id.json'))
314
+ stub_get('/movie/598/alternative_titles').with(query: { country: 'br' })
315
+ .to_return(json_response('alternative_titles_by_country.json'))
316
+
317
+ alternative_titles = TMDb::Movie.alternative_titles(598, country: 'br')
318
+
319
+ expect(alternative_titles).to match_array([
320
+ {
321
+ "iso_3166_1" => "BR",
322
+ "title" => "Cidade de Deus"
323
+ }
324
+ ])
325
+ end
326
+ end
327
+
328
+ describe '#images' do
329
+ it 'returns the images (posters and backdrops) for a specific movie ID' do
330
+ stub_get('/movie/598').to_return(json_response('find_movie_by_id.json'))
331
+ stub_get('/movie/598/images')
332
+ .to_return(json_response('movie_images.json'))
333
+
334
+ images = TMDb::Movie.images(598)
335
+
336
+ expect(images['backdrops']).to have(7).items
337
+ expect(images['posters']).to have(16).items
338
+
339
+ expect(images['backdrops'].first).to eq(
340
+ {
341
+ "file_path" => "/hSaH9tt67bozo9K50sbH0s4YjEc.jpg",
342
+ "width" => 1532,
343
+ "height" => 862,
344
+ "iso_639_1" => nil,
345
+ "aspect_ratio" => 1.78,
346
+ "vote_average" => 5.4421768707483,
347
+ "vote_count" => 7
348
+ }
349
+ )
350
+
351
+ expect(images['posters'].first).to eq(
352
+ {
353
+ "file_path" => "/mwDnSQR1CkxuDjSKfgiNT0sIOjM.jpg",
354
+ "width" => 1000,
355
+ "height" => 1500,
356
+ "iso_639_1" => "en",
357
+ "aspect_ratio" => 0.67,
358
+ "vote_average" => 5.384615384615385,
359
+ "vote_count" => 2
360
+ }
361
+ )
362
+ end
363
+
364
+ it 'returns the images (posters and backdrops) for a specific movie ID and a specific language' do
365
+ stub_get('/movie/598').to_return(json_response('find_movie_by_id.json'))
366
+ stub_get('/movie/598/images')
367
+ .to_return(json_response('movie_images_by_language.json'))
368
+
369
+ images = TMDb::Movie.images(598)
370
+
371
+ expect(images['backdrops']).to have(0).items
372
+ expect(images['posters']).to have(4).items
373
+
374
+ expect(images['posters'].first).to eq(
375
+ {
376
+ "file_path" => "/c9qkycW5DFsycCmuPDPnWvpmCJ5.jpg",
377
+ "width" => 748,
378
+ "height" => 1102,
379
+ "iso_639_1" => "pt",
380
+ "aspect_ratio" => 0.68,
381
+ "vote_average" => 5.27891156462585,
382
+ "vote_count" => 7
383
+ }
384
+ )
385
+ end
386
+ end
387
+
388
+ describe '#keywords' do
389
+ it 'return the plot keywords for a specific movie id' do
390
+ stub_get('/movie/598').to_return(json_response('find_movie_by_id.json'))
391
+ stub_get('/movie/598/keywords').to_return(json_response('movie_keywords.json'))
392
+
393
+ keywords = TMDb::Movie.keywords(598)
394
+
395
+ expect(keywords).to have(7).items
396
+
397
+ expect(keywords).to match_array([
398
+ {
399
+ "id" => 542,
400
+ "name" => "street gang"
401
+ },
402
+ {
403
+ "id" => 983,
404
+ "name" => "brazilian"
405
+ },
406
+ {
407
+ "id" => 1228,
408
+ "name" => "seventies"
409
+ },
410
+ {
411
+ "id" => 1525,
412
+ "name" => "puberty"
413
+ },
414
+ {
415
+ "id" => 1687,
416
+ "name" => "80s"
417
+ },
418
+ {
419
+ "id" => 2394,
420
+ "name" => "ghetto"
421
+ },
422
+ {
423
+ "id" => 2987,
424
+ "name" => "gang war"
425
+ }
426
+ ])
427
+ end
428
+ end
429
+
430
+ describe '#releases' do
431
+ it 'returns the release date by country for a specific movie id' do
432
+ stub_get('/movie/598').to_return(json_response('find_movie_by_id.json'))
433
+ stub_get('/movie/598/releases').to_return(json_response('movie_releases.json'))
434
+
435
+ releases = TMDb::Movie.releases(598)
436
+
437
+ expect(releases).to have(6).items
438
+
439
+ expect(releases).to match_array([
440
+ {
441
+ "iso_3166_1" => "RU",
442
+ "certification" => "",
443
+ "release_date" => "2002-02-05"
444
+ },
445
+ {
446
+ "iso_3166_1" => "US",
447
+ "certification" => "R",
448
+ "release_date" => "2002-08-31"
449
+ },
450
+ {
451
+ "iso_3166_1" => "BR",
452
+ "certification" => "",
453
+ "release_date" => "2002-08-30"
454
+ },
455
+ {
456
+ "iso_3166_1" => "CA",
457
+ "certification" => "",
458
+ "release_date" => "2002-09-06"
459
+ },
460
+ {
461
+ "iso_3166_1" => "GB",
462
+ "certification" => "18",
463
+ "release_date" => "2002-11-08"
464
+ },
465
+ {
466
+ "iso_3166_1" => "DE",
467
+ "certification" => "16",
468
+ "release_date" => "2003-05-08"
469
+ }
470
+ ])
471
+ end
472
+ end
473
+ end