worth_watching 0.1.5 → 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.
- checksums.yaml +4 -4
- data/README.md +23 -36
- data/lib/worth_watching.rb +18 -1
- data/lib/worth_watching/aggregator.rb +10 -186
- data/lib/worth_watching/errors.rb +2 -0
- data/lib/worth_watching/imdb/rating_fetcher.rb +38 -0
- data/lib/worth_watching/metacritic/rating_fetcher.rb +28 -0
- data/lib/worth_watching/movie.rb +17 -32
- data/lib/worth_watching/reviews_fetcher.rb +16 -0
- data/lib/worth_watching/rotten_tomatoes/movie_info_fetcher.rb +23 -0
- data/lib/worth_watching/rotten_tomatoes/movie_list_fetcher.rb +51 -0
- data/lib/worth_watching/rotten_tomatoes/movie_parser.rb +47 -0
- data/lib/worth_watching/rotten_tomatoes/review_parser.rb +22 -0
- data/lib/worth_watching/rotten_tomatoes/reviews_fetcher.rb +19 -0
- data/lib/worth_watching/rotten_tomatoes/rotten_tomatoes.rb +5 -0
- data/lib/worth_watching/rotten_tomatoes/searcher.rb +37 -0
- data/lib/worth_watching/tmdb/poster_fetcher.rb +26 -0
- data/lib/worth_watching/version.rb +1 -1
- data/lib/worth_watching/written_review.rb +15 -15
- data/spec/{unit/aggregator_spec.rb → integration/aggregating_a_movie_spec.rb} +18 -45
- data/spec/{test_helper.rb → spec_helper.rb} +0 -0
- data/spec/support/json_responses/a_movie_with_little_info_rt.json +1 -0
- data/spec/unit/imdb/rating_fetcher_spec.rb +31 -0
- data/spec/unit/movie_spec.rb +16 -37
- data/spec/unit/rotten_tomatoes/movie_info_fetcher_spec.rb +63 -0
- data/spec/unit/rotten_tomatoes/movie_list_fetcher_spec.rb +38 -0
- data/spec/unit/rotten_tomatoes/movie_parser_spec.rb +80 -0
- data/spec/unit/rotten_tomatoes/review_parser_spec.rb +47 -0
- data/spec/unit/rotten_tomatoes/reviews_fetcher_spec.rb +18 -0
- data/spec/unit/rotten_tomatoes/searcher_spec.rb +49 -0
- data/spec/unit/tmdb/poster_fetcher_spec.rb +15 -0
- data/spec/unit/written_review_spec.rb +16 -35
- data/worth_watching.gemspec +1 -0
- metadata +51 -7
data/spec/unit/movie_spec.rb
CHANGED
@@ -1,54 +1,33 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
describe "WorthWatching::Movie" do
|
5
5
|
let(:movie) do
|
6
|
-
|
7
|
-
|
6
|
+
WorthWatching::Movie.new({title: "Toy Story 3",
|
7
|
+
plot: "Pixar returns to their first success with Toy Story 3. The movie begins with Andy leaving for college and donating his beloved toys -- including Woody (Tom Hanks) and Buzz (Tim Allen) -- to a daycare. While the crew meets new friends, including Ken (Michael Keaton), they soon grow to hate their new surroundings and plan an escape. The film was directed by Lee Unkrich from a script co-authored by Little Miss Sunshine scribe Michael Arndt. ~ Perry Seibert, Rovi",
|
8
|
+
director: "Lee Unkrich",
|
9
|
+
genre: "Animation",
|
10
|
+
rt_rating: "99",
|
11
|
+
rt_url: "http://www.rottentomatoes.com/m/toy_story_3/",
|
12
|
+
cast: "Tom Hanks, Tim Allen, Joan Cusack, Ned Beatty",
|
13
|
+
imdb_id: "0435761",
|
14
|
+
imdb_url: "http://www.imdb.com/title/tt0435761/",
|
15
|
+
release_date: Date.parse("2010-06-18"),
|
16
|
+
rt_id: "770672122"
|
17
|
+
})
|
8
18
|
end
|
9
19
|
|
10
20
|
it "has a valid constructor" do
|
11
21
|
expect(movie).to be_an_instance_of(WorthWatching::Movie)
|
12
22
|
end
|
13
23
|
|
14
|
-
it "
|
15
|
-
expect(movie.cast).to eq("Tom Hanks, Tim Allen, Joan Cusack, Ned Beatty")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should have the title 'Toy Story 3" do
|
19
|
-
expect(movie.title).to eq("Toy Story 3")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should have correct plot'" do
|
23
|
-
expect(movie.plot).to eq("Pixar returns to their first success with Toy Story 3. The movie begins with Andy leaving for college and donating his beloved toys -- including Woody (Tom Hanks) and Buzz (Tim Allen) -- to a daycare. While the crew meets new friends, including Ken (Michael Keaton), they soon grow to hate their new surroundings and plan an escape. The film was directed by Lee Unkrich from a script co-authored by Little Miss Sunshine scribe Michael Arndt. ~ Perry Seibert, Rovi")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should have a link to RT page 'http://www.rottentomatoes.com/m/toy_story_3/'" do
|
27
|
-
expect(movie.rt_url).to eq("http://www.rottentomatoes.com/m/toy_story_3/")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should have imdb url 'http://www.imdb.com/title/tt0435761/" do
|
31
|
-
expect(movie.imdb_url).to eq("http://www.imdb.com/title/tt0435761/")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should have release date '2010-06-18'" do
|
35
|
-
expect(movie.release_date).to eq(Date.new(2010, 06, 18))
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should have director 'Lee Unkrich'" do
|
39
|
-
expect(movie.director).to eq("Lee Unkrich")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should have genre 'Animation'" do
|
43
|
-
expect(movie.genre).to eq("Animation")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "has a general summary" do
|
24
|
+
it "returns a general summary" do
|
47
25
|
summary = "------------------------------------------------------------\nToy Story 3\n------------------------------------------------------------\nReleased: 18 Jun 2010\n------------------------------------------------------------\nPixar returns to their first success with Toy Story 3. The movie begins with Andy leaving for college and donating his beloved toys -- including Woody (Tom Hanks) and Buzz (Tim Allen) -- to a daycare. While the crew meets new friends, including Ken (Michael Keaton), they soon grow to hate their new surroundings and plan an escape. The film was directed by Lee Unkrich from a script co-authored by Little Miss Sunshine scribe Michael Arndt. ~ Perry Seibert, Rovi\n------------------------------------------------------------\nCast: Tom Hanks, Tim Allen, Joan Cusack, Ned Beatty\n------------------------------------------------------------\nRotten Tomatoes rating: 99\nIMDB rating: Not retrieved\nMetacritic rating: Not retrieved\n\n"
|
26
|
+
|
48
27
|
expect(movie.summary).to eq(summary)
|
49
28
|
end
|
50
29
|
|
51
|
-
it "
|
30
|
+
it "returns a rating summary" do
|
52
31
|
summary = "Rotten Tomatoes rating: 99\nIMDB rating: Not retrieved\nMetacritic rating: Not retrieved\n"
|
53
32
|
expect(movie.rating_summary).to eq(summary)
|
54
33
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "WorthWatching::RottenTomatoes::MovieInfoFetcher" do
|
4
|
+
before do
|
5
|
+
# Single movie RottenTomatoes
|
6
|
+
json_response = File.read(File.dirname(__FILE__) + "/../../support/json_responses/toy_story_rt.json")
|
7
|
+
stub_request(:get, /api\.rottentomatoes\.com\/api\/public\/v1\.0\/movies\/770672122\.json\?apikey\=.*/).to_return(:status => 200, :body => json_response,:headers => {"content-type"=>["application/json; charset=utf-8"]})
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:fetcher) { WorthWatching::RottenTomatoes::MovieInfoFetcher.new("rt_api_key") }
|
11
|
+
|
12
|
+
let(:movie) { fetcher.fetch_info("770672122") }
|
13
|
+
|
14
|
+
describe "the Movie object returned" do
|
15
|
+
it "has the correct movie title" do
|
16
|
+
expect(movie.title).to eq("Toy Story 3")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has the correct movie cast" do
|
20
|
+
expect(movie.cast).to eq("Tom Hanks, Tim Allen, Joan Cusack, Ned Beatty")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has director 'Lee Unkrich'" do
|
24
|
+
expect(movie.director).to eq("Lee Unkrich")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "creates a printable string of cast members from an array of individual actors" do
|
28
|
+
expect(movie.cast).to eq("Tom Hanks, Tim Allen, Joan Cusack, Ned Beatty")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has the title 'Toy Story 3" do
|
32
|
+
expect(movie.title).to eq("Toy Story 3")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "has the correct plot'" do
|
36
|
+
expect(movie.plot).to eq("Pixar returns to their first success with Toy Story 3. The movie begins with Andy leaving for college and donating his beloved toys -- including Woody (Tom Hanks) and Buzz (Tim Allen) -- to a daycare. While the crew meets new friends, including Ken (Michael Keaton), they soon grow to hate their new surroundings and plan an escape. The film was directed by Lee Unkrich from a script co-authored by Little Miss Sunshine scribe Michael Arndt. ~ Perry Seibert, Rovi")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "has a link to RT page 'http://www.rottentomatoes.com/m/toy_story_3/'" do
|
40
|
+
expect(movie.rt_url).to eq("http://www.rottentomatoes.com/m/toy_story_3/")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has imdb url 'http://www.imdb.com/title/tt0435761/" do
|
44
|
+
expect(movie.imdb_url).to eq("http://www.imdb.com/title/tt0435761/")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has the release date '2010-06-18'" do
|
48
|
+
expect(movie.release_date).to eq(Date.new(2010, 06, 18))
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has the genre 'Animation'" do
|
52
|
+
expect(movie.genre).to eq("Animation")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "has a placeholder IMDb rating'" do
|
56
|
+
expect(movie.imdb_rating).to eq("Not retrieved")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has a placeholder Metacritic rating'" do
|
60
|
+
expect(movie.imdb_rating).to eq("Not retrieved")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "WorthWatching::RottenTomatoes::MovieListFetcher" do
|
4
|
+
before do
|
5
|
+
json_response = File.read(File.dirname(__FILE__) + "/../../support/json_responses/rt_top_16_in_cinemas.json")
|
6
|
+
stub_request(:get, "http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json?apikey=rt_api_key&country=uk&limit=16&page=1&page_limit=16").
|
7
|
+
with(:headers => {'User-Agent'=>'Typhoeus - https://github.com/typhoeus/typhoeus'}).
|
8
|
+
to_return(:status => 200, :body => json_response, :headers => {})
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:movie_info_fetcher) { WorthWatching::RottenTomatoes::MovieListFetcher.new("rt_api_key") }
|
12
|
+
let(:movies) { movie_info_fetcher.fetch_list(:in_theaters, :uk, 16) }
|
13
|
+
|
14
|
+
it "retrieves an array of Hash objects, each representing a movie result in the list" do
|
15
|
+
expect(movies).to be_a(Array)
|
16
|
+
movies.each {|movie| expect(movie).to be_a(Hash)}
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "a single movie result in the movies list" do
|
20
|
+
let(:movie_result) { movies.first }
|
21
|
+
|
22
|
+
it "has the title of the movie" do
|
23
|
+
expect(movie_result[:title]).to eq("The Lego Movie")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has the Rotten Tomatoes ID of the movie" do
|
27
|
+
expect(movie_result[:rt_id]).to eq("771305753")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has the year the movie was released" do
|
31
|
+
expect(movie_result[:year]).to eq("2014")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has the year the movie was released" do
|
35
|
+
expect(movie_result[:rt_rating]).to eq(97)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe "WorthWatching::RottenTomatoes::MovieParser" do
|
5
|
+
let (:complete_api_response) do
|
6
|
+
JSON.parse(File.read(File.dirname(__FILE__) + "/../../support/json_responses/toy_story_rt.json"))
|
7
|
+
end
|
8
|
+
|
9
|
+
let (:incomplete_api_response) do
|
10
|
+
JSON.parse(File.read(File.dirname(__FILE__) + "/../../support/json_responses/a_movie_with_little_info_rt.json"))
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns a Movie object representing the movie in the response" do
|
14
|
+
movie = WorthWatching::RottenTomatoes::MovieParser.parse(complete_api_response)
|
15
|
+
expect(movie).to be_a(WorthWatching::Movie)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "the Movie object created after parsing" do
|
19
|
+
context "when full movie information is available via the Rotten Tomatoes API" do
|
20
|
+
let (:movie) { WorthWatching::RottenTomatoes::MovieParser.parse(complete_api_response) }
|
21
|
+
|
22
|
+
it "has the correct movie title" do
|
23
|
+
expect(movie.title).to eq("Toy Story 3")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has the correct movie cast" do
|
27
|
+
expect(movie.cast).to eq("Tom Hanks, Tim Allen, Joan Cusack, Ned Beatty")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has director 'Lee Unkrich'" do
|
31
|
+
expect(movie.director).to eq("Lee Unkrich")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "creates a printable string of cast members from an array of individual actors" do
|
35
|
+
expect(movie.cast).to eq("Tom Hanks, Tim Allen, Joan Cusack, Ned Beatty")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has the title 'Toy Story 3" do
|
39
|
+
expect(movie.title).to eq("Toy Story 3")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "has the correct plot'" do
|
43
|
+
expect(movie.plot).to eq("Pixar returns to their first success with Toy Story 3. The movie begins with Andy leaving for college and donating his beloved toys -- including Woody (Tom Hanks) and Buzz (Tim Allen) -- to a daycare. While the crew meets new friends, including Ken (Michael Keaton), they soon grow to hate their new surroundings and plan an escape. The film was directed by Lee Unkrich from a script co-authored by Little Miss Sunshine scribe Michael Arndt. ~ Perry Seibert, Rovi")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "has a link to RT page 'http://www.rottentomatoes.com/m/toy_story_3/'" do
|
47
|
+
expect(movie.rt_url).to eq("http://www.rottentomatoes.com/m/toy_story_3/")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has imdb url 'http://www.imdb.com/title/tt0435761/" do
|
51
|
+
expect(movie.imdb_url).to eq("http://www.imdb.com/title/tt0435761/")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "has the release date '2010-06-18'" do
|
55
|
+
expect(movie.release_date).to eq(Date.new(2010, 06, 18))
|
56
|
+
end
|
57
|
+
|
58
|
+
it "has the genre 'Animation'" do
|
59
|
+
expect(movie.genre).to eq("Animation")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "has Rotten Tomato rating 99" do
|
63
|
+
expect(movie.rt_rating).to eq(99)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when the Rotten Tomatoes API has information missing about a movie" do
|
68
|
+
let (:movie) { WorthWatching::RottenTomatoes::MovieParser.parse(incomplete_api_response) }
|
69
|
+
|
70
|
+
it "has a director of nil" do
|
71
|
+
expect(movie.director).to eq(nil)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "has a genre of nil" do
|
75
|
+
expect(movie.genre).to eq(nil)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe "WorthWatching::RottenTomatoesReviewParser" do
|
5
|
+
let (:review_response_hash) do
|
6
|
+
JSON.parse(File.read(File.dirname(__FILE__) + "/../../support/json_responses/toy_story_reviews_rt.json"))
|
7
|
+
end
|
8
|
+
|
9
|
+
it "returns an array of Review objects representing the review in the response" do
|
10
|
+
reviews = WorthWatching::RottenTomatoes::ReviewParser.parse(review_response_hash)
|
11
|
+
expect(reviews).to be_a(Array)
|
12
|
+
reviews.each { |review| expect(review).to be_a(WorthWatching::WrittenReview) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "the WrittenReview object created after parsing" do
|
16
|
+
let (:review) { WorthWatching::RottenTomatoes::ReviewParser.parse(review_response_hash).last }
|
17
|
+
|
18
|
+
it "has an author" do
|
19
|
+
expect(review.author).to eq("Ailsa Caine")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has a date" do
|
23
|
+
expect(review.date).to eq(Date.parse("2010-07-22"))
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has a rating" do
|
27
|
+
expect(review.rating).to eq("fresh")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has the original score" do
|
31
|
+
expect(review.original_score).to eq("4/5")
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
it "has a source" do
|
36
|
+
expect(review.source).to eq("Little White Lies")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "has a quote" do
|
40
|
+
expect(review.quote).to eq("By [Pixar's] high standards this isn't the best, but by anyone else's, it's close to perfection.")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has a link" do
|
44
|
+
expect(review.link).to eq("http://www.littlewhitelies.co.uk/theatrical-reviews/toy-story-3/")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "WorthWatching::RottenTomatoes::ReviewsFetcher" do
|
4
|
+
before do
|
5
|
+
# Movie reviews from RottenTomatoes
|
6
|
+
json_response = File.read(File.dirname(__FILE__) + "/../../support/json_responses/toy_story_reviews_rt.json")
|
7
|
+
stub_request(:get, /api\.rottentomatoes\.com\/api\/public\/v1\.0\/movies\/770672122\/reviews\.json\?apikey\=.*&country=uk&page=1&page_limit=5&review_type=top_critic/).to_return(:status => 200, :body => json_response,:headers => {"content-type"=>["application/json; charset=utf-8"]})
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:movie_rt_id) { "770672122" }
|
11
|
+
|
12
|
+
it "retrieves a URL of the movie's poster" do
|
13
|
+
reviews = WorthWatching::RottenTomatoes::ReviewsFetcher.fetch("770672122", "rt_api_key")
|
14
|
+
|
15
|
+
expect(reviews).to be_a(Array)
|
16
|
+
reviews.each { |review| expect(review).to be_a(WorthWatching::WrittenReview) }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "WorthWatching::RottenTomatoes::Searcher" do
|
4
|
+
describe "searching for movies" do
|
5
|
+
before do
|
6
|
+
json_response = File.read(File.dirname(__FILE__) + "/../../support/json_responses/1_movie_search_result.json")
|
7
|
+
stub_request(:get, /api\.rottentomatoes\.com\/api\/public\/v1\.0\/movies\.json\?apikey=.*&page_limit=4&q=finding%20nemo/).to_return(:status => 200, :body => json_response,:headers => {"content-type"=>["application/json; charset=utf-8"]})
|
8
|
+
|
9
|
+
json_response = File.read(File.dirname(__FILE__) + "/../../support/json_responses/3_movie_search_result.json")
|
10
|
+
stub_request(:get, /api\.rottentomatoes\.com\/api\/public\/v1\.0\/movies\.json\?apikey=.*&page_limit=4&q=toy%20story/).to_return(:status => 200, :body => json_response,:headers => {"content-type"=>["application/json; charset=utf-8"]})
|
11
|
+
|
12
|
+
json_response = File.read(File.dirname(__FILE__) + "/../../support/json_responses/0_movie_search_result.json")
|
13
|
+
stub_request(:get, /api\.rottentomatoes\.com\/api\/public\/v1\.0\/movies\.json\?apikey=.*&page_limit=4&q=amoviethatdoesnotexist/).to_return(:status => 200, :body => json_response,:headers => {"content-type"=>["application/json; charset=utf-8"]})
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:searcher) { WorthWatching::RottenTomatoes::Searcher.new("rt_api_key") }
|
17
|
+
|
18
|
+
context "when results exist for the given query string" do
|
19
|
+
let(:results) { searcher.search_by_title("finding nemo", 4) }
|
20
|
+
|
21
|
+
describe "the search results" do
|
22
|
+
it "is an array of movies" do
|
23
|
+
expect(results).to be_an_instance_of(Array)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has the title of the movie result" do
|
27
|
+
expect(results.first[:title]).to eq("Finding Nemo")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has the Rotten Tomatoes ID of the movie result" do
|
31
|
+
expect(results.first[:rt_id]).to eq("9377")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has the release year of the movie result" do
|
35
|
+
expect(results.first[:year]).to eq("2003")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when results do not exist for the given query string" do
|
41
|
+
describe "the search results" do
|
42
|
+
it "returns false" do
|
43
|
+
results = searcher.search_by_title("amoviethatdoesnotexist", 4)
|
44
|
+
expect(results).to be_false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "WorthWatching::TMDB::PosterFetcher" do
|
4
|
+
before do
|
5
|
+
json_response = File.read(File.dirname(__FILE__) + "/../../support/json_responses/toy_story_tmdb.json")
|
6
|
+
stub_request(:get, /api\.themoviedb\.org\/3\/movie\/tt0435761\?api_key\=.*/).to_return(:status => 200, :body => json_response,:headers => {"content-type"=>["application/json; charset=utf-8"]})
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:movie_imdb_id) { "0435761" }
|
10
|
+
let(:poster_fetcher) { WorthWatching::TMDB::PosterFetcher.new("tmdb_api_key") }
|
11
|
+
it "retrieves a URL of the movie's poster" do
|
12
|
+
poster_url = poster_fetcher.fetch(movie_imdb_id)
|
13
|
+
expect(poster_url).to eq("http://cf2.imgobject.com/t/p/original/tOwAAVeL1p3ls9dhOBo45ElodU3.jpg")
|
14
|
+
end
|
15
|
+
end
|
@@ -1,45 +1,22 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "WorthWatching::WrittenReview" do
|
4
|
-
let (:review)
|
4
|
+
let (:review) do
|
5
|
+
WorthWatching::WrittenReview.new(
|
6
|
+
"Joshua Rothkopf",
|
7
|
+
Date.parse("2014-03-27"),
|
8
|
+
"fresh",
|
9
|
+
"Time Out New York",
|
10
|
+
"The Marvel faithful will turn up for the action scenes, and the directors, brothers Anthony and Joe Russo, add an uncommon sharpness to sequences of urban warfare -- these Heat-grade bullet volleys have a real ping to them.",
|
11
|
+
"http://www.timeout.com/us/film/captain-america-the-winter-soldier",
|
12
|
+
"4/5"
|
13
|
+
)
|
14
|
+
end
|
5
15
|
|
6
16
|
it "has a valid constructor" do
|
7
17
|
expect(review).to be_an_instance_of(WorthWatching::WrittenReview)
|
8
18
|
end
|
9
19
|
|
10
|
-
it "has an author" do
|
11
|
-
expect(review.author).to eq("Joshua Rothkopf")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "has a date" do
|
15
|
-
expect(review.date).to eq(Date.parse("2014-03-27"))
|
16
|
-
end
|
17
|
-
|
18
|
-
it "has a rating" do
|
19
|
-
expect(review.rating).to eq("fresh")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "has the original score" do
|
23
|
-
expect(review.original_score).to eq("4/5")
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
it "has a source" do
|
28
|
-
expect(review.source).to eq("Time Out New York")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "has a quote" do
|
32
|
-
expect(review.quote).to eq("The Marvel faithful will turn up for the action scenes, and the directors, brothers Anthony and Joe Russo, add an uncommon sharpness to sequences of urban warfare -- these Heat-grade bullet volleys have a real ping to them.")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "has a link" do
|
36
|
-
expect(review.link).to eq("http://www.timeout.com/us/film/captain-america-the-winter-soldier")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "returns a formatted string representing the review" do
|
40
|
-
expect(review.to_s).to eq("Joshua Rothkopf wrote on 2014-03-27 : The Marvel faithful will turn up for the action scenes, and the directors, brothers Anthony and Joe Russo, add an uncommon sharpness to sequences of urban warfare -- these Heat-grade bullet volleys have a real ping to them.\nRating: 4/5")
|
41
|
-
end
|
42
|
-
|
43
20
|
it "can be converted back to a hash" do
|
44
21
|
expect(review.to_hash).to eq({ author: "Joshua Rothkopf",
|
45
22
|
date: Date.parse("2014-03-27"),
|
@@ -49,4 +26,8 @@ describe "WorthWatching::WrittenReview" do
|
|
49
26
|
link: "http://www.timeout.com/us/film/captain-america-the-winter-soldier",
|
50
27
|
original_score: "4/5"})
|
51
28
|
end
|
29
|
+
|
30
|
+
it "returns a formatted string representing the review" do
|
31
|
+
expect(review.to_s).to eq("Joshua Rothkopf wrote on 2014-03-27 : The Marvel faithful will turn up for the action scenes, and the directors, brothers Anthony and Joe Russo, add an uncommon sharpness to sequences of urban warfare -- these Heat-grade bullet volleys have a real ping to them.\nRating: 4/5")
|
32
|
+
end
|
52
33
|
end
|