spec/lib/rspotify/album_spec.rb in rspotify-1.2.0 vs spec/lib/rspotify/album_spec.rb in rspotify-1.3.0
- old
+ new
@@ -2,11 +2,13 @@
describe 'Album::find receiving id as a string' do
before(:each) do
# Get Arctic Monkeys's AM album as a testing sample
- @album = RSpotify::Album.find('5bU1XKYxHhEwukllT20xtk')
+ @album = VCR.use_cassette('album:find:5bU1XKYxHhEwukllT20xtk') do
+ RSpotify::Album.find('5bU1XKYxHhEwukllT20xtk')
+ end
end
it 'should find album with correct attributes' do
expect(@album.album_type) .to eq 'album'
expect(@album.available_markets) .to include *%w(AD AT BE BG CA EE ES FR GR MC TW US)
@@ -42,42 +44,54 @@
end
describe 'Album::find receiving array of ids' do
it 'should find the right albums' do
ids = ['2agWNCZl5Ts9W05mij8EPh']
- albums = RSpotify::Album.find(ids)
+ albums = VCR.use_cassette('album:find:2agWNCZl5Ts9W05mij8EPh') do
+ RSpotify::Album.find(ids)
+ end
expect(albums) .to be_an Array
expect(albums.size) .to eq 1
expect(albums.first.name) .to eq 'The Next Day Extra'
ids << '3JquYMWj5wrzuZCNAvOYN9'
- albums = RSpotify::Album.find(ids)
+ albums = VCR.use_cassette('album:find:3JquYMWj5wrzuZCNAvOYN9') do
+ RSpotify::Album.find(ids)
+ end
expect(albums) .to be_an Array
expect(albums.size) .to eq 2
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::search' do
it 'should search for the right albums' do
- albums = RSpotify::Album.search('AM')
+ albums = VCR.use_cassette('album:search:AM') do
+ RSpotify::Album.search('AM')
+ end
expect(albums) .to be_an Array
expect(albums.size) .to eq 20
expect(albums.first) .to be_an RSpotify::Album
expect(albums.map(&:name)) .to include('AM', 'Am I Wrong', 'A.M.', 'Melody AM')
end
it 'should accept additional options' do
- albums = RSpotify::Album.search('AM', limit: 10)
+ albums = VCR.use_cassette('album:search:AM:limit:10') do
+ RSpotify::Album.search('AM', limit: 10)
+ end
expect(albums.size) .to eq 10
expect(albums.map(&:name)) .to include('AM', 'Am I Wrong')
- albums = RSpotify::Album.search('AM', offset: 10)
+ albums = VCR.use_cassette('album:search:AM:offset:10') do
+ RSpotify::Album.search('AM', offset: 10)
+ end
expect(albums.size) .to eq 20
expect(albums.map(&:name)) .to include('Melody AM', 'I Am')
- albums = RSpotify::Album.search('AM', limit: 10, offset: 10)
+ 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')
end
end
end