spec/lib/rspotify/album_spec.rb in rspotify-1.7.0 vs spec/lib/rspotify/album_spec.rb in rspotify-1.8.0

- old
+ new

@@ -62,10 +62,44 @@ expect(albums.first.name) .to eq 'The Next Day Extra' expect(albums.last.name) .to eq 'A Beard Of Stars (Deluxe Edition)' end end + describe 'Album::new_releases' do + # Keys generated specifically for the tests. Should be removed in the future + let(:client_id) { '5ac1cda2ad354aeaa1ad2693d33bb98c' } + let(:client_secret) { '155fc038a85840679b55a1822ef36b9b' } + + before(:each) do + VCR.use_cassette('authenticate:client') do + RSpotify.authenticate(client_id, client_secret) + end + end + + it 'should find the appropriate new releases' do + albums = VCR.use_cassette('album:new_releases') do + RSpotify::Album.new_releases + end + expect(albums.size) .to eq 20 + expect(albums.map(&:name)) .to include('A13', 'Singles', 'Magic') + end + + it 'should accept additional options' do + albums = VCR.use_cassette('album:new_releases:limit:10:offset:10') do + RSpotify::Album.new_releases(limit: 10, offset: 10) + end + expect(albums.size) .to eq 10 + expect(albums.map(&:name)) .to include('Recess', 'Atlas', 'Magic') + + albums = VCR.use_cassette('album:new_releases:country:ES') do + RSpotify::Album.new_releases(country: 'ES') + end + expect(albums.size) .to eq 20 + expect(albums.map(&:name)) .to include('Me Olvide de Vivir', 'Amor Futuro') + end + end + describe 'Album::search' do it 'should search for the right albums' do albums = VCR.use_cassette('album:search:AM') do RSpotify::Album.search('AM') end @@ -91,8 +125,14 @@ albums = VCR.use_cassette('album:search:AM:offset:10:limit:10') do RSpotify::Album.search('AM', limit: 10, offset: 10) end expect(albums.size) .to eq 10 expect(albums.map(&:name)) .to include('Melody AM') + + albums = VCR.use_cassette('album:search:AM:market:ES') do + RSpotify::Album.search('AM', market: 'ES') + end + ES_albums = albums.select { |a| a.available_markets.include?('ES') } + expect(ES_albums.length).to eq(albums.length) end end end