filmaffinity 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +11 -190
- data/Gemfile +1 -1
- data/README.md +42 -44
- data/filmaffinity.gemspec +5 -5
- data/lib/constants/constants.rb +2 -2
- data/lib/filmaffinity.rb +11 -11
- data/lib/filmaffinity/configuration.rb +1 -1
- data/lib/filmaffinity/json-movie-parser.rb +10 -10
- data/lib/filmaffinity/json-movies-parser.rb +2 -2
- data/lib/filmaffinity/movie.rb +47 -17
- data/lib/filmaffinity/poster-manager.rb +4 -4
- data/lib/filmaffinity/search.rb +6 -5
- data/lib/filmaffinity/top.rb +7 -6
- data/spec/filmaffinity/json-movie-parser_spec.rb +7 -6
- data/spec/filmaffinity/matchers/include-movie.rb +1 -1
- data/spec/filmaffinity/movie_spec.rb +155 -119
- data/spec/filmaffinity/search_spec.rb +17 -17
- data/spec/filmaffinity/top_spec.rb +30 -31
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
data/lib/filmaffinity.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
require_relative "constants/constants"
|
5
|
-
require_relative "filmaffinity/configuration"
|
6
|
-
require_relative "filmaffinity/poster-manager"
|
7
|
-
require_relative "filmaffinity/json-movies-parser"
|
8
|
-
require_relative "filmaffinity/json-movie-parser"
|
9
|
-
require_relative "filmaffinity/movie"
|
10
|
-
require_relative "filmaffinity/search"
|
11
|
-
require_relative "filmaffinity/top"
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
12
3
|
|
4
|
+
require_relative 'constants/constants'
|
5
|
+
require_relative 'filmaffinity/configuration'
|
6
|
+
require_relative 'filmaffinity/poster-manager'
|
7
|
+
require_relative 'filmaffinity/json-movies-parser'
|
8
|
+
require_relative 'filmaffinity/json-movie-parser'
|
9
|
+
require_relative 'filmaffinity/movie'
|
10
|
+
require_relative 'filmaffinity/search'
|
11
|
+
require_relative 'filmaffinity/top'
|
12
|
+
# Module FilmAffinity
|
13
13
|
module FilmAffinity
|
14
14
|
class << self
|
15
15
|
attr_accessor :configuration
|
@@ -1,17 +1,17 @@
|
|
1
|
-
require
|
1
|
+
require 'json'
|
2
2
|
|
3
3
|
class JsonMovieParser
|
4
4
|
def to_hash(movie)
|
5
5
|
{
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
'title' => movie.title,
|
7
|
+
'rating' => movie.rating,
|
8
|
+
'director' => movie.director,
|
9
|
+
'year' => movie.year,
|
10
|
+
'duration' => movie.duration,
|
11
|
+
'country' => movie.country,
|
12
|
+
'script' => movie.script,
|
13
|
+
'cast' => movie.cast,
|
14
|
+
'sinopsis' => movie.sinopsis
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
data/lib/filmaffinity/movie.rb
CHANGED
@@ -17,79 +17,109 @@ module FilmAffinity
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def title
|
20
|
-
@title ||= document_html.at(Constants.tag(:title)).content.strip
|
20
|
+
@title ||= document_html.at(Constants.tag(:title)).content.strip
|
21
|
+
rescue
|
22
|
+
nil
|
21
23
|
end
|
22
24
|
|
23
25
|
def year
|
24
|
-
document_html.at(Constants.tag(:year)).content[/\d+/].to_i
|
26
|
+
document_html.at(Constants.tag(:year)).content[/\d+/].to_i
|
27
|
+
rescue
|
28
|
+
nil
|
25
29
|
end
|
26
30
|
|
27
31
|
def duration
|
28
|
-
document_html.at(Constants.tag(:duration)).content[/\d+/].to_i
|
32
|
+
document_html.at(Constants.tag(:duration)).content[/\d+/].to_i
|
33
|
+
rescue
|
34
|
+
nil
|
29
35
|
end
|
30
36
|
|
31
37
|
def country
|
32
|
-
raw_country = document_html.at(Constants.tag(:country)).next_sibling.content
|
38
|
+
raw_country = document_html.at(Constants.tag(:country)).next_sibling.content
|
33
39
|
raw_country.gsub(/\A[[:space:]]+|[[:space:]]+\z/, '') if raw_country
|
40
|
+
rescue
|
41
|
+
nil
|
34
42
|
end
|
35
43
|
|
36
44
|
def director
|
37
|
-
raw_director = document_html.at(Constants.tag(:director)).content
|
45
|
+
raw_director = document_html.at(Constants.tag(:director)).content
|
38
46
|
raw_director.strip if raw_director
|
47
|
+
rescue
|
48
|
+
nil
|
39
49
|
end
|
40
50
|
|
41
51
|
def music
|
42
|
-
document_html.at(Constants.tag(:music)).next_sibling.next_sibling.content
|
52
|
+
document_html.at(Constants.tag(:music)).next_sibling.next_sibling.content
|
53
|
+
rescue
|
54
|
+
nil
|
43
55
|
end
|
44
56
|
|
45
57
|
def company
|
46
|
-
document_html.at(Constants.tag(:company)).next_sibling.next_sibling.content
|
58
|
+
document_html.at(Constants.tag(:company)).next_sibling.next_sibling.content
|
59
|
+
rescue
|
60
|
+
nil
|
47
61
|
end
|
48
62
|
|
49
63
|
def script
|
50
|
-
document_html.at(Constants.tag(:script)).next_sibling.next_sibling.content
|
64
|
+
document_html.at(Constants.tag(:script)).next_sibling.next_sibling.content
|
65
|
+
rescue
|
66
|
+
nil
|
51
67
|
end
|
52
68
|
|
53
69
|
def photography
|
54
|
-
document_html.at(Constants.tag(:photography)).next_sibling.next_sibling.content
|
70
|
+
document_html.at(Constants.tag(:photography)).next_sibling.next_sibling.content
|
71
|
+
rescue
|
72
|
+
nil
|
55
73
|
end
|
56
74
|
|
57
75
|
def cast
|
58
76
|
actors = []
|
59
|
-
node = document_html.search(Constants.tag(:cast))
|
77
|
+
node = document_html.search(Constants.tag(:cast))
|
60
78
|
node.each do |actor|
|
61
79
|
actors << actor.at(Constants.tag(:cast_each)).content.strip
|
62
80
|
end
|
63
81
|
actors
|
82
|
+
rescue
|
83
|
+
[]
|
64
84
|
end
|
65
85
|
|
66
86
|
def genres
|
67
87
|
genres = []
|
68
|
-
node = document_html.at(Constants.tag(:genre)).next_sibling.next_sibling
|
69
|
-
raw_genres = node.search(
|
88
|
+
node = document_html.at(Constants.tag(:genre)).next_sibling.next_sibling
|
89
|
+
raw_genres = node.search('a')
|
70
90
|
raw_genres.each do |raw_genre|
|
71
91
|
genres << raw_genre.content.strip
|
72
92
|
end
|
73
93
|
genres
|
94
|
+
rescue
|
95
|
+
[]
|
74
96
|
end
|
75
97
|
|
76
98
|
def sinopsis
|
77
|
-
document_html.at(Constants.tag(:sinopsis)).content
|
99
|
+
document_html.at(Constants.tag(:sinopsis)).content
|
100
|
+
rescue
|
101
|
+
nil
|
78
102
|
end
|
79
103
|
|
80
104
|
def rating
|
81
|
-
raw_rating = document_html.at(Constants.tag(:rating)).content.strip
|
82
|
-
raw_rating.tr(
|
105
|
+
raw_rating = document_html.at(Constants.tag(:rating)).content.strip
|
106
|
+
raw_rating.tr(',', '.').to_f if raw_rating
|
107
|
+
rescue
|
108
|
+
nil
|
83
109
|
end
|
84
110
|
|
85
111
|
def poster
|
86
|
-
poster_url = document_html.at(Constants.tag(:poster))[
|
112
|
+
poster_url = document_html.at(Constants.tag(:poster))['src']
|
87
113
|
@poster_manager.load_poster(poster_url) if poster_url
|
114
|
+
rescue
|
115
|
+
nil
|
88
116
|
end
|
89
117
|
|
90
118
|
def poster_big
|
91
|
-
poster_url = document_html.at(Constants.tag(:poster_big))[
|
119
|
+
poster_url = document_html.at(Constants.tag(:poster_big))['href']
|
92
120
|
@poster_manager.load_poster(poster_url) if poster_url
|
121
|
+
rescue
|
122
|
+
nil
|
93
123
|
end
|
94
124
|
|
95
125
|
def to_json
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'open-uri'
|
2
|
+
require 'imgur'
|
3
3
|
|
4
4
|
class PosterManager
|
5
5
|
def load_poster(posterurl)
|
@@ -9,7 +9,7 @@ class PosterManager
|
|
9
9
|
|
10
10
|
def upload(posterurl, api_id)
|
11
11
|
imgur = Imgur.new(api_id)
|
12
|
-
@dir = __dir__ +
|
12
|
+
@dir = __dir__ + '/' + construct_name + '.jpg'
|
13
13
|
save_img_locally(posterurl)
|
14
14
|
local_image = Imgur::LocalImage.new(@dir)
|
15
15
|
uploaded = imgur.upload(local_image)
|
@@ -19,7 +19,7 @@ class PosterManager
|
|
19
19
|
|
20
20
|
def save_img_locally(posterurl)
|
21
21
|
open(posterurl) do |f|
|
22
|
-
File.open(@dir,
|
22
|
+
File.open(@dir, 'wb') do |file|
|
23
23
|
file.puts f.read
|
24
24
|
end
|
25
25
|
end
|
data/lib/filmaffinity/search.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'cgi'
|
2
2
|
|
3
3
|
module FilmAffinity
|
4
|
+
# Class Search
|
4
5
|
class Search
|
5
6
|
def initialize(query)
|
6
7
|
@query = query
|
@@ -12,7 +13,7 @@ module FilmAffinity
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def exact_match?
|
15
|
-
!document_html.at(
|
16
|
+
!document_html.at('.z-movie').nil?
|
16
17
|
end
|
17
18
|
|
18
19
|
def document_html
|
@@ -31,9 +32,9 @@ module FilmAffinity
|
|
31
32
|
|
32
33
|
def parse_movies
|
33
34
|
movies = []
|
34
|
-
document_html.search(
|
35
|
-
id = movie_card[
|
36
|
-
title = movie_card.search(
|
35
|
+
document_html.search('.movie-card.movie-card-1').each do |movie_card|
|
36
|
+
id = movie_card['data-movie-id'].to_i
|
37
|
+
title = movie_card.search('.mc-title a').first.content.strip
|
37
38
|
movie = FilmAffinity::Movie.new id, title
|
38
39
|
movies << movie
|
39
40
|
end
|
data/lib/filmaffinity/top.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module FilmAffinity
|
2
|
+
# Class Top
|
2
3
|
class Top
|
3
4
|
def initialize(options: {}, limit: 30)
|
4
5
|
@options = options
|
@@ -15,7 +16,7 @@ module FilmAffinity
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def generate_html(from)
|
18
|
-
params = {'from' => from}
|
19
|
+
params = { 'from' => from }
|
19
20
|
url = URI.parse(Constants.urls[:top] % query_options)
|
20
21
|
data = Net::HTTP.post_form(url, params)
|
21
22
|
data.body
|
@@ -23,11 +24,11 @@ module FilmAffinity
|
|
23
24
|
|
24
25
|
def query_options
|
25
26
|
query_options = ''
|
26
|
-
query_options +=
|
27
|
+
query_options += '?'
|
27
28
|
@options.each do |key, value|
|
28
29
|
query_options += Constants.query_params[key] % value
|
29
30
|
end
|
30
|
-
query_options.gsub(/\&$/,
|
31
|
+
query_options.gsub(/\&$/, '')
|
31
32
|
end
|
32
33
|
|
33
34
|
def movies_with_limit
|
@@ -46,9 +47,9 @@ module FilmAffinity
|
|
46
47
|
|
47
48
|
def parse_movies(document_html)
|
48
49
|
movies = []
|
49
|
-
document_html.search(
|
50
|
-
id = movie_card[
|
51
|
-
title = movie_card.search(
|
50
|
+
document_html.search('.movie-card.movie-card-1').each_with_index do |movie_card, _index|
|
51
|
+
id = movie_card['data-movie-id'].to_i
|
52
|
+
title = movie_card.search('.mc-title a').first.content.strip
|
52
53
|
movie = FilmAffinity::Movie.new id, title
|
53
54
|
movies << movie
|
54
55
|
end
|
@@ -1,11 +1,12 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
describe
|
3
|
+
describe 'JsonMovieParser' do
|
4
|
+
describe '#to_hash' do
|
5
5
|
subject { JsonMovieParser.new }
|
6
|
-
it
|
7
|
-
|
8
|
-
|
6
|
+
it 'return the right director for the given movie' do
|
7
|
+
movie = FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
8
|
+
hash = subject.to_hash movie
|
9
|
+
expect(hash['director']).to eq('Peter Weir')
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -1,242 +1,278 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative '../spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
context
|
5
|
-
describe
|
6
|
-
subject(:movie)
|
7
|
-
|
8
|
-
|
3
|
+
describe 'FilmAffinity::Movie' do
|
4
|
+
context 'english version' do
|
5
|
+
describe '#title' do
|
6
|
+
subject(:movie) do
|
7
|
+
FilmAffinity::Movie.new(504_889)
|
8
|
+
end
|
9
|
+
it 'should return an valid title when initializes with no title' do
|
10
|
+
expect(movie.title).to eq('The Truman Show')
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
12
|
-
describe
|
13
|
-
subject(:movie)
|
14
|
-
|
14
|
+
describe '#rating' do
|
15
|
+
subject(:movie) do
|
16
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
17
|
+
end
|
18
|
+
it 'should return an Float' do
|
15
19
|
expect(movie.rating).to be_a(Float)
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
19
|
-
describe
|
20
|
-
subject(:movie)
|
21
|
-
|
23
|
+
describe '#year' do
|
24
|
+
subject(:movie) do
|
25
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
26
|
+
end
|
27
|
+
it 'should return an Fixnum' do
|
22
28
|
expect(movie.year).to be_an(Fixnum)
|
23
29
|
end
|
24
|
-
it
|
30
|
+
it 'should return 1998' do
|
25
31
|
expect(movie.year).to eq(1998)
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
29
|
-
describe
|
30
|
-
subject(:movie)
|
31
|
-
|
35
|
+
describe '#duration' do
|
36
|
+
subject(:movie) do
|
37
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
38
|
+
end
|
39
|
+
it 'should return an Fixnum' do
|
32
40
|
expect(movie.duration).to be_a(Fixnum)
|
33
41
|
end
|
34
|
-
it
|
42
|
+
it 'should return 103' do
|
35
43
|
expect(movie.duration).to eq(103)
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
39
|
-
describe
|
40
|
-
subject(:movie)
|
41
|
-
|
47
|
+
describe '#country' do
|
48
|
+
subject(:movie) do
|
49
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
50
|
+
end
|
51
|
+
it 'should return a String' do
|
42
52
|
expect(movie.country).to be_a(String)
|
43
53
|
end
|
44
|
-
it
|
45
|
-
expect(movie.country).to eq(
|
54
|
+
it 'should return "United States"' do
|
55
|
+
expect(movie.country).to eq('United States')
|
46
56
|
end
|
47
57
|
end
|
48
58
|
|
49
|
-
describe
|
50
|
-
subject(:movie)
|
51
|
-
|
59
|
+
describe '#director' do
|
60
|
+
subject(:movie) do
|
61
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
62
|
+
end
|
63
|
+
it 'should return a String' do
|
52
64
|
expect(movie.director).to be_a(String)
|
53
65
|
end
|
54
|
-
it
|
55
|
-
expect(movie.director).to eq(
|
66
|
+
it 'should return "Peter Weir"' do
|
67
|
+
expect(movie.director).to eq('Peter Weir')
|
56
68
|
end
|
57
69
|
end
|
58
70
|
|
59
|
-
describe
|
60
|
-
subject(:movie)
|
61
|
-
|
71
|
+
describe '#script' do
|
72
|
+
subject(:movie) do
|
73
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
74
|
+
end
|
75
|
+
it 'should return a String' do
|
62
76
|
expect(movie.script).to be_a(String)
|
63
77
|
end
|
64
|
-
it
|
65
|
-
expect(movie.script).to eq(
|
78
|
+
it 'should return "Andrew Niccol"' do
|
79
|
+
expect(movie.script).to eq('Andrew Niccol')
|
66
80
|
end
|
67
81
|
end
|
68
82
|
|
69
|
-
describe
|
70
|
-
subject(:movie)
|
71
|
-
|
83
|
+
describe '#cast' do
|
84
|
+
subject(:movie) do
|
85
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
86
|
+
end
|
87
|
+
it 'should return an Array' do
|
72
88
|
expect(movie.cast).to be_an(Array)
|
73
89
|
end
|
74
|
-
it
|
90
|
+
it 'should to include the passed cast' do
|
75
91
|
expected_cast = [
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
92
|
+
'Jim Carrey',
|
93
|
+
'Laura Linney',
|
94
|
+
'Noah Emmerich',
|
95
|
+
'Ed Harris'
|
80
96
|
]
|
81
97
|
expect(movie.cast).to include(*expected_cast)
|
82
98
|
end
|
83
99
|
end
|
84
100
|
|
85
|
-
describe
|
86
|
-
subject(:movie)
|
87
|
-
|
101
|
+
describe '#company' do
|
102
|
+
subject(:movie) do
|
103
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
104
|
+
end
|
105
|
+
it 'should return a String' do
|
88
106
|
expect(movie.company).to be_a(String)
|
89
107
|
end
|
90
|
-
it
|
91
|
-
expect(movie.company).to eq(
|
108
|
+
it 'should return "Paramount Pictures / Scott Rudin Productions"' do
|
109
|
+
expect(movie.company).to eq('Paramount Pictures / Scott Rudin Productions')
|
92
110
|
end
|
93
111
|
end
|
94
112
|
|
95
|
-
describe
|
96
|
-
subject(:movie)
|
97
|
-
|
113
|
+
describe '#genres' do
|
114
|
+
subject(:movie) do
|
115
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
116
|
+
end
|
117
|
+
it 'should return an Array' do
|
98
118
|
expect(movie.genres).to be_an(Array)
|
99
119
|
end
|
100
|
-
it
|
101
|
-
expected_genres =
|
102
|
-
"Drama",
|
103
|
-
"Comedy",
|
104
|
-
"Satire"
|
105
|
-
]
|
120
|
+
it 'should to include the passed genres' do
|
121
|
+
expected_genres = %w(Drama Comedy Satire)
|
106
122
|
expect(movie.genres).to include(*expected_genres)
|
107
123
|
end
|
108
124
|
end
|
109
125
|
|
110
|
-
describe
|
111
|
-
subject(:movie)
|
112
|
-
|
126
|
+
describe '#poster' do
|
127
|
+
subject(:movie) do
|
128
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
129
|
+
end
|
130
|
+
it 'should return a String' do
|
113
131
|
expect(movie.poster).to be_a(String)
|
114
132
|
end
|
115
|
-
it
|
116
|
-
expect(movie.poster).to include(
|
133
|
+
it 'should return a .jpg address' do
|
134
|
+
expect(movie.poster).to include('.jpg')
|
117
135
|
end
|
118
136
|
end
|
119
137
|
end
|
120
138
|
|
121
|
-
context
|
139
|
+
context 'spanish version' do
|
122
140
|
before :all do
|
123
141
|
FilmAffinity.configure do |config|
|
124
|
-
config.language =
|
142
|
+
config.language = 'ES'
|
125
143
|
end
|
126
144
|
end
|
127
145
|
|
128
|
-
describe
|
129
|
-
subject(:movie)
|
130
|
-
|
131
|
-
|
146
|
+
describe '#title' do
|
147
|
+
subject(:movie) do
|
148
|
+
FilmAffinity::Movie.new(504_889)
|
149
|
+
end
|
150
|
+
it 'should return an valid title when initializes with no title' do
|
151
|
+
expect(movie.title).to eq('El show de Truman (Una vida en directo)')
|
132
152
|
end
|
133
153
|
end
|
134
154
|
|
135
|
-
describe
|
136
|
-
subject(:movie)
|
137
|
-
|
155
|
+
describe '#rating' do
|
156
|
+
subject(:movie) do
|
157
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
158
|
+
end
|
159
|
+
it 'should return an Float' do
|
138
160
|
expect(movie.rating).to be_a(Float)
|
139
161
|
end
|
140
162
|
end
|
141
163
|
|
142
|
-
describe
|
143
|
-
subject(:movie)
|
144
|
-
|
164
|
+
describe '#year' do
|
165
|
+
subject(:movie) do
|
166
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
167
|
+
end
|
168
|
+
it 'should return an Fixnum' do
|
145
169
|
expect(movie.year).to be_an(Fixnum)
|
146
170
|
end
|
147
|
-
it
|
171
|
+
it 'should return 1998' do
|
148
172
|
expect(movie.year).to eq(1998)
|
149
173
|
end
|
150
174
|
end
|
151
175
|
|
152
|
-
describe
|
153
|
-
subject(:movie)
|
154
|
-
|
176
|
+
describe '#duration' do
|
177
|
+
subject(:movie) do
|
178
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
179
|
+
end
|
180
|
+
it 'should return an Fixnum' do
|
155
181
|
expect(movie.duration).to be_a(Fixnum)
|
156
182
|
end
|
157
|
-
it
|
183
|
+
it 'should return 103' do
|
158
184
|
expect(movie.duration).to eq(103)
|
159
185
|
end
|
160
186
|
end
|
161
187
|
|
162
|
-
describe
|
163
|
-
subject(:movie)
|
164
|
-
|
188
|
+
describe '#country' do
|
189
|
+
subject(:movie) do
|
190
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
191
|
+
end
|
192
|
+
it 'should return a String' do
|
165
193
|
expect(movie.country).to be_a(String)
|
166
194
|
end
|
167
|
-
it
|
168
|
-
expect(movie.country).to eq(
|
195
|
+
it 'should return "Estados Unidos"' do
|
196
|
+
expect(movie.country).to eq('Estados Unidos')
|
169
197
|
end
|
170
198
|
end
|
171
199
|
|
172
|
-
describe
|
173
|
-
subject(:movie)
|
174
|
-
|
200
|
+
describe '#director' do
|
201
|
+
subject(:movie) do
|
202
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
203
|
+
end
|
204
|
+
it 'should return a String' do
|
175
205
|
expect(movie.director).to be_a(String)
|
176
206
|
end
|
177
|
-
it
|
178
|
-
expect(movie.director).to eq(
|
207
|
+
it 'should return "Peter Weir"' do
|
208
|
+
expect(movie.director).to eq('Peter Weir')
|
179
209
|
end
|
180
210
|
end
|
181
211
|
|
182
|
-
describe
|
183
|
-
subject(:movie)
|
184
|
-
|
212
|
+
describe '#script' do
|
213
|
+
subject(:movie) do
|
214
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
215
|
+
end
|
216
|
+
it 'should return a String' do
|
185
217
|
expect(movie.script).to be_a(String)
|
186
218
|
end
|
187
|
-
it
|
188
|
-
expect(movie.script).to eq(
|
219
|
+
it 'should return "Andrew Niccol"' do
|
220
|
+
expect(movie.script).to eq('Andrew Niccol')
|
189
221
|
end
|
190
222
|
end
|
191
223
|
|
192
|
-
describe
|
193
|
-
subject(:movie)
|
194
|
-
|
224
|
+
describe '#cast' do
|
225
|
+
subject(:movie) do
|
226
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
227
|
+
end
|
228
|
+
it 'should return an Array' do
|
195
229
|
expect(movie.cast).to be_an(Array)
|
196
230
|
end
|
197
|
-
it
|
231
|
+
it 'should to include the passed cast' do
|
198
232
|
expected_cast = [
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
233
|
+
'Jim Carrey',
|
234
|
+
'Laura Linney',
|
235
|
+
'Noah Emmerich',
|
236
|
+
'Ed Harris'
|
203
237
|
]
|
204
238
|
expect(movie.cast).to include(*expected_cast)
|
205
239
|
end
|
206
240
|
end
|
207
241
|
|
208
|
-
describe
|
209
|
-
subject(:movie)
|
210
|
-
|
242
|
+
describe '#company' do
|
243
|
+
subject(:movie) do
|
244
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
245
|
+
end
|
246
|
+
it 'should return a String' do
|
211
247
|
expect(movie.company).to be_a(String)
|
212
248
|
end
|
213
|
-
it
|
214
|
-
expect(movie.company).to eq(
|
249
|
+
it 'should return "Paramount Pictures / Scott Rudin Productions"' do
|
250
|
+
expect(movie.company).to eq('Paramount Pictures / Scott Rudin Productions')
|
215
251
|
end
|
216
252
|
end
|
217
253
|
|
218
|
-
describe
|
219
|
-
subject(:movie)
|
220
|
-
|
254
|
+
describe '#genres' do
|
255
|
+
subject(:movie) do
|
256
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
257
|
+
end
|
258
|
+
it 'should return an Array' do
|
221
259
|
expect(movie.genres).to be_an(Array)
|
222
260
|
end
|
223
|
-
it
|
224
|
-
expected_genres =
|
225
|
-
"Drama",
|
226
|
-
"Comedia",
|
227
|
-
"Sátira"
|
228
|
-
]
|
261
|
+
it 'should to include the passed genres' do
|
262
|
+
expected_genres = %w(Drama Comedia Sátira)
|
229
263
|
expect(movie.genres).to include(*expected_genres)
|
230
264
|
end
|
231
265
|
end
|
232
266
|
|
233
|
-
describe
|
234
|
-
subject(:movie)
|
235
|
-
|
267
|
+
describe '#poster' do
|
268
|
+
subject(:movie) do
|
269
|
+
FilmAffinity::Movie.new(504_889, 'El show de Truman (Una vida en directo)')
|
270
|
+
end
|
271
|
+
it 'should return a String' do
|
236
272
|
expect(movie.poster).to be_a(String)
|
237
273
|
end
|
238
|
-
it
|
239
|
-
expect(movie.poster).to include(
|
274
|
+
it 'should return a .jpg address' do
|
275
|
+
expect(movie.poster).to include('.jpg')
|
240
276
|
end
|
241
277
|
end
|
242
278
|
end
|