spec/enceladus/models/account_spec.rb in enceladus-0.0.3 vs spec/enceladus/models/account_spec.rb in enceladus-0.0.4

- old
+ new

@@ -1,13 +1,13 @@ require 'spec_helper' describe Enceladus::Account do - let(:request_token_response) { RequestTokenResponse.new } - let(:authentication_response) { AuthenticationResponse.new } - let(:session_response) { SessionResponse.new } - let(:account_response) { AccountResponse.new } + let(:request_token_response) { build(:request_token_response) } + let(:authentication_response) { build(:authentication_response) } + let(:session_response) { build(:session_response) } + let(:account_response) { build(:account_response) } let(:username) { "ashlynn_brooke" } let(:password) { "corinthians" } before do stub_request(:get, "https://api.themoviedb.org/3/authentication/token/new?api_key=token"). @@ -108,19 +108,15 @@ describe "#favorite_movies" do subject(:favorite_movies) { account.favorite_movies } let(:account) { Enceladus::Account.new(username, password) } let(:collection) { Enceladus::MovieCollection.new(path) } - let(:movie_1) { MovieCollectionResourceResponse.new } - let(:movie_2) { MovieCollectionResourceResponse.new } - let(:response) { MovieCollectionResponse.new } + let(:movie_1) { build(:movie_collection_resource_response) } + let(:movie_2) { build(:movie_collection_resource_response) } + let(:response) { build(:movie_collection_response, results: [movie_1, movie_2]) } before do - movie_1.id = 111 - movie_2.id = 222 - response.results = [movie_1, movie_2] - stub_request(:get, "https://api.themoviedb.org/3/account/#{account.id}/favorite/movies?api_key=token&page=1&session_id=#{session_response.session_id}"). to_return(status: 200, body: response.to_json) end it "should return all favorite movies" do @@ -131,19 +127,15 @@ describe "#rated_movies" do subject(:rated_movies) { account.rated_movies } let(:account) { Enceladus::Account.new(username, password) } let(:collection) { Enceladus::MovieCollection.new(path) } - let(:movie_1) { MovieCollectionResourceResponse.new } - let(:movie_2) { MovieCollectionResourceResponse.new } - let(:response) { MovieCollectionResponse.new } + let(:movie_1) { build(:movie_collection_resource_response) } + let(:movie_2) { build(:movie_collection_resource_response) } + let(:response) { build(:movie_collection_response, results: [movie_1, movie_2]) } before do - movie_1.id = 111 - movie_2.id = 222 - response.results = [movie_1, movie_2] - stub_request(:get, "https://api.themoviedb.org/3/account/#{account.id}/rated/movies?api_key=token&page=1&session_id=#{session_response.session_id}"). to_return(status: 200, body: response.to_json) end it "should return all rated movies" do @@ -154,18 +146,14 @@ describe "#watchlist" do subject(:watchlist) { account.watchlist } let(:account) { Enceladus::Account.new(username, password) } let(:collection) { Enceladus::MovieCollection.new(path) } - let(:movie_1) { MovieCollectionResourceResponse.new } - let(:movie_2) { MovieCollectionResourceResponse.new } - let(:response) { MovieCollectionResponse.new } + let(:movie_1) { build(:movie_collection_resource_response) } + let(:movie_2) { build(:movie_collection_resource_response) } + let(:response) { build(:movie_collection_response, results: [movie_1, movie_2]) } before do - movie_1.id = 111 - movie_2.id = 222 - response.results = [movie_1, movie_2] - stub_request(:get, "https://api.themoviedb.org/3/account/#{account.id}/watchlist/movies?api_key=token&page=1&session_id=#{session_response.session_id}"). to_return(status: 200, body: response.to_json) end it "should return all rated movies" do \ No newline at end of file