spec/lastfm_spec.rb in lastfm-0.6.0 vs spec/lastfm_spec.rb in lastfm-1.0.1
- old
+ new
@@ -139,11 +139,13 @@
<key>zzzyyyxxx</key>
<subscriber>0</subscriber>
</session>
</lfm>
XML
- @lastfm.auth.get_session('xxxyyyzzz').should eql('zzzyyyxxx')
+ session = @lastfm.auth.get_session('xxxyyyzzz')
+ session['name'].should eql('MyLastFMUsername')
+ session['key'].should eql('zzzyyyxxx')
end
end
describe '#track' do
it 'should return an instance of Lastfm::Track' do
@@ -310,33 +312,54 @@
it 'should scrobble' do
time = Time.now
@lastfm.should_receive(:request).with('track.scrobble', {
:artist => 'foo artist',
:track => 'foo track',
- :album => nil,
- :timestamp => time
+ :album => 'foo album',
+ :mbid => '0383dadf-2a4e-4d10-a46a-e9e041da8eb3',
+ :timestamp => time,
+ :trackNumber => 1,
+ :duration => nil,
+ :albumArtist => nil,
}, :post, true, true).and_return(@ok_response)
- @lastfm.track.scrobble('foo artist', 'foo track', nil, time)
+ @lastfm.track.scrobble('foo artist', 'foo track', time, 'foo album', 1, '0383dadf-2a4e-4d10-a46a-e9e041da8eb3', nil, nil)
end
it 'should update now playing' do
@lastfm.should_receive(:request).with('track.updateNowPlaying', {
:artist => 'foo artist',
:track => 'foo track',
+ :album => 'foo album',
+ :mbid => '0383dadf-2a4e-4d10-a46a-e9e041da8eb3',
+ :trackNumber => 1,
+ :duration => nil,
+ :albumArtist => nil,
}, :post, true, true).and_return(@ok_response)
- @lastfm.track.update_now_playing('foo artist', 'foo track')
+ @lastfm.track.update_now_playing('foo artist', 'foo track', 'foo album', 1, '0383dadf-2a4e-4d10-a46a-e9e041da8eb3', nil, nil)
end
end
describe '#artist' do
it 'should return an instance of Lastfm::Artist' do
@lastfm.artist.should be_an_instance_of(Lastfm::MethodCategory::Artist)
end
+ it 'should get info' do
+ @lastfm.should_receive(:request).with('artist.getInfo', {
+ :artist => 'Cher'
+ }).and_return(make_response('artist_get_info'))
+
+ artist = @lastfm.artist.get_info('Cher')
+ artist['name'].should eql('Cher')
+ artist['mbid'].should eql('bfcc6d75-a6a5-4bc6-8282-47aec8531818')
+ artist['url'].should eql('http://www.last.fm/music/Cher')
+ artist['image'].size.should eql(5)
+ end
+
it 'should get events' do
@lastfm.should_receive(:request).with('artist.getEvents', {
:artist => 'Cher'
}).and_return(make_response('artist_get_events'))
@@ -356,10 +379,36 @@
events[0]['tickets']['ticket']['content'].should eql("http://www.last.fm/affiliate/byid/29/1584537/12/ws.artist.events.b25b959554ed76058ac220b7b2e0a026")
events[0]['tags']['tag'].should == ["pop", "dance", "female vocalists", "80s", "cher"]
end
end
+ describe '#album' do
+ it 'should return an instance of Lastfm::Album' do
+ @lastfm.album.should be_an_instance_of(Lastfm::MethodCategory::Album)
+ end
+
+ it 'should get info' do
+ @lastfm.should_receive(:request).with('album.getInfo', {
+ :artist => 'Cher', :album => 'Believe'
+ }).and_return(make_response('album_get_info'))
+
+ album = @lastfm.album.get_info('Cher', 'Believe')
+ album['name'].should eql('Believe')
+ album['artist'].should eql('Cher')
+ album['id'].should eql('2026126')
+ album['mbid'].should eql('61bf0388-b8a9-48f4-81d1-7eb02706dfb0')
+ album['url'].should eql('http://www.last.fm/music/Cher/Believe')
+ album['image'].size.should eql(5)
+ album['releasedate'].should eql('6 Apr 1999, 00:00')
+ album['tracks']['track'].size.should eql(10)
+ album['tracks']['track'][0]['name'].should eql('Believe')
+ album['tracks']['track'][0]['duration'].should eql('239')
+ album['tracks']['track'][0]['url'].should eql('http://www.last.fm/music/Cher/_/Believe')
+ end
+
+ end
+
describe '#geo' do
it 'should return an instance of Lastfm::Geo' do
@lastfm.geo.should be_an_instance_of(Lastfm::MethodCategory::Geo)
end
@@ -410,10 +459,10 @@
friends = @lastfm.user.get_friends('test')
friends.size.should == 1
friends[0]['name'].should eql('polaroide')
end
end
-
+
describe '#get_neighbours' do
it 'should get user\'s neighbours' do
@lastfm.should_receive(:request).with('user.getNeighbours', {
:user => 'rj',
:recenttracks => nil,