filmaffinity 0.3.1 → 1.0.0

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.
@@ -1,15 +1,15 @@
1
- require "open-uri"
2
- require "nokogiri"
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
@@ -4,6 +4,6 @@ class Configuration
4
4
 
5
5
  def initialize
6
6
  @imgur_id = nil
7
- @language = "EN"
7
+ @language = 'EN'
8
8
  end
9
9
  end
@@ -1,17 +1,17 @@
1
- require "json"
1
+ require 'json'
2
2
 
3
3
  class JsonMovieParser
4
4
  def to_hash(movie)
5
5
  {
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
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
 
@@ -3,8 +3,8 @@ class JsonMoviesParser
3
3
  hashes = []
4
4
  movies.each do |movie|
5
5
  hash = {
6
- "id" => movie.id,
7
- "title" => movie.title
6
+ 'id' => movie.id,
7
+ 'title' => movie.title
8
8
  }
9
9
  hashes << hash
10
10
  end
@@ -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 rescue nil
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 rescue nil
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 rescue nil
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 rescue nil
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 rescue nil
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 rescue nil
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 rescue nil
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 rescue nil
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 rescue nil
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)) rescue []
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 rescue []
69
- raw_genres = node.search("a")
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 rescue nil
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 rescue nil
82
- raw_rating.tr(",", ".").to_f if raw_rating
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))["src"] rescue nil
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))["href"] rescue nil
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 "open-uri"
2
- require "imgur"
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__ + "/" + construct_name + ".jpg"
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, "wb") do |file|
22
+ File.open(@dir, 'wb') do |file|
23
23
  file.puts f.read
24
24
  end
25
25
  end
@@ -1,6 +1,7 @@
1
- require "cgi"
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(".z-movie").nil?
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(".movie-card.movie-card-1").each do |movie_card|
35
- id = movie_card["data-movie-id"].to_i
36
- title = movie_card.search(".mc-title a").first.content.strip
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
@@ -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(".movie-card.movie-card-1").each_with_index do |movie_card, _index|
50
- id = movie_card["data-movie-id"].to_i
51
- title = movie_card.search(".mc-title a").first.content.strip
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 "../spec_helper"
1
+ require_relative '../spec_helper'
2
2
 
3
- describe "JsonMovieParser" do
4
- describe "#to_hash" do
3
+ describe 'JsonMovieParser' do
4
+ describe '#to_hash' do
5
5
  subject { JsonMovieParser.new }
6
- it "return the right director for the given movie" do
7
- hash = subject.to_hash FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)")
8
- expect(hash["director"]).to eq("Peter Weir")
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,4 +1,4 @@
1
- require "rspec/expectations"
1
+ require 'rspec/expectations'
2
2
 
3
3
  RSpec::Matchers.define :include_movie do |expected|
4
4
  match do |movies|
@@ -1,242 +1,278 @@
1
- require_relative "../spec_helper"
1
+ require_relative '../spec_helper'
2
2
 
3
- describe "FilmAffinity::Movie" do
4
- context "english version" do
5
- describe "#title" do
6
- subject(:movie) { FilmAffinity::Movie.new(504_889) }
7
- it "should return an valid title when initializes with no title" do
8
- expect(movie.title).to eq("The Truman Show")
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 "#rating" do
13
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
14
- it "should return an Float" do
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 "#year" do
20
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
21
- it "should return an Fixnum" do
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 "should return 1998" do
30
+ it 'should return 1998' do
25
31
  expect(movie.year).to eq(1998)
26
32
  end
27
33
  end
28
34
 
29
- describe "#duration" do
30
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
31
- it "should return an Fixnum" do
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 "should return 103" do
42
+ it 'should return 103' do
35
43
  expect(movie.duration).to eq(103)
36
44
  end
37
45
  end
38
46
 
39
- describe "#country" do
40
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
41
- it "should return a String" do
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 "should return 'United States'" do
45
- expect(movie.country).to eq("United States")
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 "#director" do
50
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
51
- it "should return a String" do
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 "should return 'Peter Weir'" do
55
- expect(movie.director).to eq("Peter Weir")
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 "#script" do
60
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
61
- it "should return a String" do
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 "should return 'Andrew Niccol'" do
65
- expect(movie.script).to eq("Andrew Niccol")
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 "#cast" do
70
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
71
- it "should return an Array" do
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 "should to include the passed cast" do
90
+ it 'should to include the passed cast' do
75
91
  expected_cast = [
76
- "Jim Carrey",
77
- "Laura Linney",
78
- "Noah Emmerich",
79
- "Ed Harris"
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 "#company" do
86
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
87
- it "should return a String" do
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 "should return 'Paramount Pictures / Scott Rudin Productions'" do
91
- expect(movie.company).to eq("Paramount Pictures / Scott Rudin Productions")
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 "#genres" do
96
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
97
- it "should return an Array" do
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 "should to include the passed genres" do
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 "#poster" do
111
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
112
- it "should return a String" do
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 "should return a .jpg address" do
116
- expect(movie.poster).to include(".jpg")
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 "spanish version" do
139
+ context 'spanish version' do
122
140
  before :all do
123
141
  FilmAffinity.configure do |config|
124
- config.language = "ES"
142
+ config.language = 'ES'
125
143
  end
126
144
  end
127
145
 
128
- describe "#title" do
129
- subject(:movie) { FilmAffinity::Movie.new(504_889) }
130
- it "should return an valid title when initializes with no title" do
131
- expect(movie.title).to eq("El show de Truman (Una vida en directo)")
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 "#rating" do
136
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
137
- it "should return an Float" do
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 "#year" do
143
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
144
- it "should return an Fixnum" do
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 "should return 1998" do
171
+ it 'should return 1998' do
148
172
  expect(movie.year).to eq(1998)
149
173
  end
150
174
  end
151
175
 
152
- describe "#duration" do
153
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
154
- it "should return an Fixnum" do
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 "should return 103" do
183
+ it 'should return 103' do
158
184
  expect(movie.duration).to eq(103)
159
185
  end
160
186
  end
161
187
 
162
- describe "#country" do
163
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
164
- it "should return a String" do
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 "should return 'Estados Unidos'" do
168
- expect(movie.country).to eq("Estados Unidos")
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 "#director" do
173
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
174
- it "should return a String" do
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 "should return 'Peter Weir'" do
178
- expect(movie.director).to eq("Peter Weir")
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 "#script" do
183
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
184
- it "should return a String" do
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 "should return 'Andrew Niccol'" do
188
- expect(movie.script).to eq("Andrew Niccol")
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 "#cast" do
193
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
194
- it "should return an Array" do
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 "should to include the passed cast" do
231
+ it 'should to include the passed cast' do
198
232
  expected_cast = [
199
- "Jim Carrey",
200
- "Laura Linney",
201
- "Noah Emmerich",
202
- "Ed Harris"
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 "#company" do
209
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
210
- it "should return a String" do
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 "should return 'Paramount Pictures / Scott Rudin Productions'" do
214
- expect(movie.company).to eq("Paramount Pictures / Scott Rudin Productions")
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 "#genres" do
219
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
220
- it "should return an Array" do
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 "should to include the passed genres" do
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 "#poster" do
234
- subject(:movie) { FilmAffinity::Movie.new(504_889, "El show de Truman (Una vida en directo)") }
235
- it "should return a String" do
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 "should return a .jpg address" do
239
- expect(movie.poster).to include(".jpg")
274
+ it 'should return a .jpg address' do
275
+ expect(movie.poster).to include('.jpg')
240
276
  end
241
277
  end
242
278
  end