hornairs-scrobbler 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/.gitignore +13 -0
  2. data/.loadpath +5 -0
  3. data/History.txt +5 -0
  4. data/MIT-LICENSE +19 -0
  5. data/Manifest +75 -0
  6. data/README.rdoc +104 -0
  7. data/Rakefile +10 -0
  8. data/VERSION.yml +5 -0
  9. data/examples/album.rb +20 -0
  10. data/examples/artist.rb +13 -0
  11. data/examples/playlist.rb +7 -0
  12. data/examples/scrobble.rb +31 -0
  13. data/examples/tag.rb +11 -0
  14. data/examples/track.rb +12 -0
  15. data/examples/user.rb +15 -0
  16. data/lib/scrobbler.rb +33 -0
  17. data/lib/scrobbler/album.rb +181 -0
  18. data/lib/scrobbler/artist.rb +165 -0
  19. data/lib/scrobbler/auth.rb +47 -0
  20. data/lib/scrobbler/base.rb +105 -0
  21. data/lib/scrobbler/event.rb +105 -0
  22. data/lib/scrobbler/geo.rb +27 -0
  23. data/lib/scrobbler/helper/image.rb +52 -0
  24. data/lib/scrobbler/helper/streamable.rb +40 -0
  25. data/lib/scrobbler/library.rb +112 -0
  26. data/lib/scrobbler/playing.rb +49 -0
  27. data/lib/scrobbler/playlist.rb +87 -0
  28. data/lib/scrobbler/radio.rb +12 -0
  29. data/lib/scrobbler/rest.rb +47 -0
  30. data/lib/scrobbler/scrobble.rb +116 -0
  31. data/lib/scrobbler/session.rb +9 -0
  32. data/lib/scrobbler/shout.rb +21 -0
  33. data/lib/scrobbler/simpleauth.rb +60 -0
  34. data/lib/scrobbler/tag.rb +113 -0
  35. data/lib/scrobbler/track.rb +152 -0
  36. data/lib/scrobbler/user.rb +222 -0
  37. data/lib/scrobbler/venue.rb +67 -0
  38. data/setup.rb +1585 -0
  39. data/tasks/jeweler.rake +15 -0
  40. data/tasks/rdoc.rake +7 -0
  41. data/tasks/tests.rake +13 -0
  42. data/tasks/yardoc.rake +8 -0
  43. data/test/fixtures/xml/album/info.xml +43 -0
  44. data/test/fixtures/xml/artist/fans.xml +52 -0
  45. data/test/fixtures/xml/artist/info.xml +58 -0
  46. data/test/fixtures/xml/artist/similar.xml +1004 -0
  47. data/test/fixtures/xml/artist/topalbums.xml +61 -0
  48. data/test/fixtures/xml/artist/toptags.xml +19 -0
  49. data/test/fixtures/xml/artist/toptracks.xml +62 -0
  50. data/test/fixtures/xml/auth/session.xml +7 -0
  51. data/test/fixtures/xml/auth/token.xml +3 -0
  52. data/test/fixtures/xml/event/attend.xml +3 -0
  53. data/test/fixtures/xml/event/attendees.xml +53 -0
  54. data/test/fixtures/xml/event/event.xml +35 -0
  55. data/test/fixtures/xml/event/shouts.xml +35 -0
  56. data/test/fixtures/xml/geo/events-distance-p1.xml +151 -0
  57. data/test/fixtures/xml/geo/events-lat-long.xml +167 -0
  58. data/test/fixtures/xml/geo/events-p1.xml +152 -0
  59. data/test/fixtures/xml/geo/events-p2.xml +380 -0
  60. data/test/fixtures/xml/geo/events-p3.xml +427 -0
  61. data/test/fixtures/xml/geo/top_artists-p1.xml +76 -0
  62. data/test/fixtures/xml/geo/top_tracks-p1.xml +77 -0
  63. data/test/fixtures/xml/library/albums-f30.xml +454 -0
  64. data/test/fixtures/xml/library/albums-p1.xml +754 -0
  65. data/test/fixtures/xml/library/albums-p2.xml +754 -0
  66. data/test/fixtures/xml/library/albums-p3.xml +754 -0
  67. data/test/fixtures/xml/library/albums-p4.xml +739 -0
  68. data/test/fixtures/xml/library/albums-p5.xml +754 -0
  69. data/test/fixtures/xml/library/albums-p6.xml +754 -0
  70. data/test/fixtures/xml/library/albums-p7.xml +739 -0
  71. data/test/fixtures/xml/library/albums-p8.xml +724 -0
  72. data/test/fixtures/xml/library/artists-f30.xml +334 -0
  73. data/test/fixtures/xml/library/artists-p1.xml +554 -0
  74. data/test/fixtures/xml/library/artists-p2.xml +554 -0
  75. data/test/fixtures/xml/library/artists-p3.xml +554 -0
  76. data/test/fixtures/xml/library/artists-p4.xml +554 -0
  77. data/test/fixtures/xml/library/artists-p5.xml +554 -0
  78. data/test/fixtures/xml/library/artists-p6.xml +554 -0
  79. data/test/fixtures/xml/library/artists-p7.xml +444 -0
  80. data/test/fixtures/xml/library/tracks-f30.xml +472 -0
  81. data/test/fixtures/xml/library/tracks-p1.xml +789 -0
  82. data/test/fixtures/xml/library/tracks-p10.xml +771 -0
  83. data/test/fixtures/xml/library/tracks-p11.xml +792 -0
  84. data/test/fixtures/xml/library/tracks-p12.xml +777 -0
  85. data/test/fixtures/xml/library/tracks-p13.xml +762 -0
  86. data/test/fixtures/xml/library/tracks-p14.xml +759 -0
  87. data/test/fixtures/xml/library/tracks-p15.xml +762 -0
  88. data/test/fixtures/xml/library/tracks-p16.xml +756 -0
  89. data/test/fixtures/xml/library/tracks-p17.xml +780 -0
  90. data/test/fixtures/xml/library/tracks-p18.xml +756 -0
  91. data/test/fixtures/xml/library/tracks-p19.xml +774 -0
  92. data/test/fixtures/xml/library/tracks-p2.xml +765 -0
  93. data/test/fixtures/xml/library/tracks-p20.xml +777 -0
  94. data/test/fixtures/xml/library/tracks-p21.xml +777 -0
  95. data/test/fixtures/xml/library/tracks-p22.xml +771 -0
  96. data/test/fixtures/xml/library/tracks-p23.xml +765 -0
  97. data/test/fixtures/xml/library/tracks-p24.xml +783 -0
  98. data/test/fixtures/xml/library/tracks-p25.xml +777 -0
  99. data/test/fixtures/xml/library/tracks-p26.xml +777 -0
  100. data/test/fixtures/xml/library/tracks-p27.xml +756 -0
  101. data/test/fixtures/xml/library/tracks-p28.xml +771 -0
  102. data/test/fixtures/xml/library/tracks-p29.xml +753 -0
  103. data/test/fixtures/xml/library/tracks-p3.xml +771 -0
  104. data/test/fixtures/xml/library/tracks-p30.xml +780 -0
  105. data/test/fixtures/xml/library/tracks-p31.xml +753 -0
  106. data/test/fixtures/xml/library/tracks-p32.xml +771 -0
  107. data/test/fixtures/xml/library/tracks-p33.xml +762 -0
  108. data/test/fixtures/xml/library/tracks-p34.xml +538 -0
  109. data/test/fixtures/xml/library/tracks-p4.xml +792 -0
  110. data/test/fixtures/xml/library/tracks-p5.xml +780 -0
  111. data/test/fixtures/xml/library/tracks-p6.xml +789 -0
  112. data/test/fixtures/xml/library/tracks-p7.xml +789 -0
  113. data/test/fixtures/xml/library/tracks-p8.xml +780 -0
  114. data/test/fixtures/xml/library/tracks-p9.xml +774 -0
  115. data/test/fixtures/xml/tag/similar.xml +254 -0
  116. data/test/fixtures/xml/tag/topalbums.xml +805 -0
  117. data/test/fixtures/xml/tag/topartists.xml +605 -0
  118. data/test/fixtures/xml/tag/toptags.xml +1254 -0
  119. data/test/fixtures/xml/tag/toptracks.xml +852 -0
  120. data/test/fixtures/xml/track/fans.xml +34 -0
  121. data/test/fixtures/xml/track/info.xml +53 -0
  122. data/test/fixtures/xml/track/toptags.xml +504 -0
  123. data/test/fixtures/xml/user/events.xml +401 -0
  124. data/test/fixtures/xml/user/friends.xml +30 -0
  125. data/test/fixtures/xml/user/lovedtracks.xml +678 -0
  126. data/test/fixtures/xml/user/neighbours.xml +23 -0
  127. data/test/fixtures/xml/user/playlists.xml +61 -0
  128. data/test/fixtures/xml/user/profile.xml +12 -0
  129. data/test/fixtures/xml/user/recentbannedtracks.xml +24 -0
  130. data/test/fixtures/xml/user/recentlovedtracks.xml +24 -0
  131. data/test/fixtures/xml/user/recenttracks.xml +124 -0
  132. data/test/fixtures/xml/user/systemrecs.xml +18 -0
  133. data/test/fixtures/xml/user/topalbums.xml +61 -0
  134. data/test/fixtures/xml/user/topartists.xml +41 -0
  135. data/test/fixtures/xml/user/toptags.xml +44 -0
  136. data/test/fixtures/xml/user/toptracks.xml +65 -0
  137. data/test/fixtures/xml/user/weeklyalbumchart.xml +256 -0
  138. data/test/fixtures/xml/user/weeklyartistchart.xml +220 -0
  139. data/test/fixtures/xml/user/weeklytrackchart.xml +746 -0
  140. data/test/fixtures/xml/venue/events.xml +151 -0
  141. data/test/fixtures/xml/venue/venue.xml +16 -0
  142. data/test/mocks/rest.rb +212 -0
  143. data/test/spec_helper.rb +7 -0
  144. data/test/test_helper.rb +20 -0
  145. data/test/unit/album_spec.rb +52 -0
  146. data/test/unit/artist_spec.rb +130 -0
  147. data/test/unit/auth_spec.rb +36 -0
  148. data/test/unit/event_spec.rb +109 -0
  149. data/test/unit/geo_spec.rb +148 -0
  150. data/test/unit/library_spec.rb +133 -0
  151. data/test/unit/playing_test.rb +53 -0
  152. data/test/unit/playlist_spec.rb +25 -0
  153. data/test/unit/radio_spec.rb +22 -0
  154. data/test/unit/scrobble_spec.rb +55 -0
  155. data/test/unit/scrobble_test.rb +69 -0
  156. data/test/unit/simpleauth_test.rb +45 -0
  157. data/test/unit/tag_spec.rb +101 -0
  158. data/test/unit/track_spec.rb +95 -0
  159. data/test/unit/user_spec.rb +264 -0
  160. data/test/unit/venue_spec.rb +104 -0
  161. metadata +265 -0
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class TestPlaying < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'
7
+ @now_playing_url = 'http://62.216.251.203:80/nowplaying'
8
+ @artist = 'Anberlin'
9
+ @track = 'A Day Late'
10
+ @album = 'Never Take Friendship Personal'
11
+
12
+ @playing = Scrobbler::Playing.new(:session_id => @session_id, :now_playing_url => @now_playing_url,
13
+ :artist => @artist, :track => @track, :album => @album, :length => 214,
14
+ :track_number => 5)
15
+ end
16
+
17
+ test 'should require a session id' do
18
+ assert_raises(ArgumentError) { Scrobbler::Playing.new(
19
+ :now_playing_url => @now_playing_url, :artist => @artist, :track => @track,
20
+ :album => @album, :length => 214, :track_number => 5) }
21
+ end
22
+
23
+ test 'should require a now playing url' do
24
+ assert_raises(ArgumentError) { Scrobbler::Playing.new(
25
+ :session_id => @session_id, :artist => @artist, :track => @track,
26
+ :album => @album, :length => 214, :track_number => 5) }
27
+ end
28
+
29
+ test 'should require an artist' do
30
+ assert_raises(ArgumentError) { Scrobbler::Playing.new(
31
+ :session_id => @session_id, :now_playing_url => @now_playing_url,
32
+ :track => @track, :album => @album, :length => 214, :track_number => 5) }
33
+ end
34
+
35
+ test 'should require a track' do
36
+ assert_raises(ArgumentError) { Scrobbler::Playing.new(
37
+ :session_id => @session_id, :now_playing_url => @now_playing_url,
38
+ :artist => @artist, :album => @album, :length => 214, :track_number => 5) }
39
+ end
40
+
41
+ test 'should require a length greater than 30 seconds' do
42
+ assert_raises(ArgumentError) { Scrobbler::Playing.new(
43
+ :session_id => @session_id, :now_playing_url => @now_playing_url,
44
+ :artist => @artist, :track => @track, :album => @album, :length => 29,
45
+ :track_number => 5) }
46
+ end
47
+
48
+ test 'should submit successfully' do
49
+ @playing.submit!
50
+ assert_equal('OK', @playing.status)
51
+ end
52
+
53
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Scrobbler::Playlist do
4
+
5
+ before(:all) do
6
+ @playlist = Scrobbler::Playlist.new('lastfm://playlist/album/2026126')
7
+ end
8
+
9
+ it 'should know its url' do
10
+ @playlist.url.should eql('lastfm://playlist/album/2026126')
11
+ end
12
+
13
+ it 'should implement all methods from the Last.fm 2.0 API' do
14
+ @playlist.should respond_to(:fetch)
15
+ @playlist.should respond_to(:add_track)
16
+ Scrobbler::Playlist.should respond_to(:create)
17
+ end
18
+
19
+ it 'should be able to add a track'
20
+
21
+ it 'should be able to create a new'
22
+
23
+ it 'should be able to fetch more information'
24
+
25
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Scrobbler::Radio do
4
+
5
+ before(:all) do
6
+ @radio = Scrobbler::Radio.new('lastfm://globaltags/disco')
7
+ end
8
+
9
+ it 'should know its station' do
10
+ @radio.station.should eql('lastfm://globaltags/disco')
11
+ end
12
+
13
+ it 'should implement all methods from the Last.fm 2.0 API' do
14
+ @radio.should respond_to(:tune)
15
+ @radio.should respond_to(:playlist)
16
+ end
17
+
18
+ it 'should be able to tune in'
19
+
20
+ it 'should be able to fetch the playlist'
21
+
22
+ end
@@ -0,0 +1,55 @@
1
+ describe Scrobbler::Scrobble do
2
+ before do
3
+ Scrobbler::Scrobble.client_id = 'spec'
4
+ @user = Scrobbler::User.new('TestUser')
5
+ @session = Scrobbler::Session.new(:key => 'testKey', :name => 'testName', :subscriber => true)
6
+ @scrobble = Scrobbler::Scrobble.new(:handshake_on_init => false, :user => @user, :session => @session)
7
+ end
8
+
9
+ describe 'should implement the method' do
10
+ [:submit, :now_playing, :handshake].each do |method_name|
11
+ it "'#{method_name}'" do
12
+ @scrobble.should respond_to(method_name)
13
+ end
14
+ end
15
+ end
16
+
17
+ describe 'doing initialization should require' do
18
+ it 'a session' do
19
+ lambda {
20
+ Scrobbler::Scrobble.new(:session => nil, :user => @user)
21
+ }.should raise_error(ArgumentError)
22
+ end
23
+
24
+ it 'a user' do
25
+ lambda {
26
+ Scrobbler::Scrobble.new(:session => @session, :user => nil)
27
+ }.should raise_error(ArgumentError)
28
+ end
29
+ end
30
+
31
+ describe 'handshaking should provide' do
32
+ it 'a session id'
33
+ it 'a now-playing url'
34
+ it 'a submisson url'
35
+ end
36
+
37
+ describe 'handshaking could fail with' do
38
+ it BadAuthError
39
+ it BadTimeError
40
+ it RequestFailedError
41
+ it ClientBannedError
42
+ end
43
+
44
+ describe 'now_playing should work with' do
45
+ it 'just track and artist'
46
+ it 'additionally the duration'
47
+ it 'additionally the album name'
48
+ it 'additionally the track\'s MusicBrainz id'
49
+ end
50
+
51
+ describe 'now_playing could fail with' do
52
+ it BadSessionError
53
+ end
54
+
55
+ end
@@ -0,0 +1,69 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class TestScrobble < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'
7
+ @submission_url = 'http://62.216.251.205:80/protocol_1.2'
8
+ @artist = 'Coldplay'
9
+ @name = 'Viva La Vida'
10
+
11
+ @scrobble = Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
12
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
13
+ :length => 244, :track_number => 7)
14
+ end
15
+
16
+ test 'should require a session id' do
17
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:submission_url => @submission_url,
18
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
19
+ :length => 244, :track_number => 7) }
20
+ end
21
+
22
+ test 'should require a submission url' do
23
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id,
24
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
25
+ :length => 244, :track_number => 7) }
26
+ end
27
+
28
+ test 'should require an artist' do
29
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
30
+ :track => @name, :album => @name, :time => Time.new,
31
+ :length => 244, :track_number => 7) }
32
+ end
33
+
34
+ test 'should require a track' do
35
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
36
+ :artist => @artist, :album => @name, :time => Time.new,
37
+ :length => 244, :track_number => 7) }
38
+ end
39
+
40
+ test 'should require a Time object' do
41
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
42
+ :artist => @artist, :track => @name, :album => @name, :time => 'chunky_bacon',
43
+ :length => 244, :track_number => 7) }
44
+ end
45
+
46
+ test 'should require a valid source' do
47
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
48
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
49
+ :length => 244, :track_number => 7, :source => 'Z') }
50
+ end
51
+
52
+ test 'should require a length if source is set to P' do
53
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
54
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
55
+ :track_number => 7, :source => 'P') }
56
+ end
57
+
58
+ test 'should require a length greater than 30 if source is set to P' do
59
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
60
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
61
+ :length => 29, :track_number => 7, :source => 'P') }
62
+ end
63
+
64
+ test 'should submit successfully' do
65
+ @scrobble.submit!
66
+ assert_equal('OK', @scrobble.status)
67
+ end
68
+
69
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class TestSimpleAuth < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @auth = Scrobbler::SimpleAuth.new(:user => 'chunky', :password => 'bacon')
7
+ end
8
+
9
+ test 'should require a user' do
10
+ assert_raises(ArgumentError) { Scrobbler::SimpleAuth.new(:password => 'bacon') }
11
+ end
12
+
13
+ test 'should require a password' do
14
+ assert_raises(ArgumentError) { Scrobbler::SimpleAuth.new(:user => 'chunky') }
15
+ end
16
+
17
+ test 'should have the right client id' do
18
+ assert_equal('rbs', @auth.client_id)
19
+ end
20
+
21
+ test 'should have the right version' do
22
+ assert_equal('0.2.13', @auth.client_ver)
23
+ end
24
+
25
+ test 'should handshake successfully' do
26
+ @auth.handshake!
27
+ assert_equal('OK', @auth.status)
28
+ end
29
+
30
+ test 'should get a session id' do
31
+ @auth.handshake!
32
+ assert_equal('17E61E13454CDD8B68E8D7DEEEDF6170', @auth.session_id)
33
+ end
34
+
35
+ test 'should get a now playing url' do
36
+ @auth.handshake!
37
+ assert_equal('http://62.216.251.203:80/nowplaying', @auth.now_playing_url)
38
+ end
39
+
40
+ test 'should get a submission url' do
41
+ @auth.handshake!
42
+ assert_equal('http://62.216.251.205:80/protocol_1.2', @auth.submission_url)
43
+ end
44
+
45
+ end
@@ -0,0 +1,101 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Scrobbler::Tag do
4
+
5
+ before(:all) do
6
+ @tag = Scrobbler::Tag.new('rock')
7
+ end
8
+
9
+ it 'should know its name' do
10
+ @tag.name.should eql('rock')
11
+ end
12
+
13
+ it 'should implement all methods from the Last.fm 2.0 API' do
14
+ @tag.should respond_to(:similar)
15
+ @tag.should respond_to(:top_albums)
16
+ @tag.should respond_to(:top_artists)
17
+ Scrobbler::Tag.should respond_to(:top_tags)
18
+ @tag.should respond_to(:top_tracks)
19
+ @tag.should respond_to(:weekly_artist_chart)
20
+ @tag.should respond_to(:weekly_chart_list)
21
+ Scrobbler::Tag.should respond_to(:search)
22
+ end
23
+
24
+ it 'should be able to get similar tags' do
25
+ @tag.should have(50).similar
26
+ first = @tag.similar.first
27
+ first.should be_kind_of(Scrobbler::Tag)
28
+ first.name.should eql('classic rock')
29
+ first.url.should eql('http://www.last.fm/tag/classic%20rock')
30
+ first.streamable.should be_true
31
+ end
32
+
33
+ it 'should be able to find its top albums' do
34
+ @tag.top_albums.should be_kind_of(Array)
35
+ @tag.top_albums.should have(50).items
36
+ @tag.top_albums.first.should be_kind_of(Scrobbler::Album)
37
+ @tag.top_albums.first.rank.should eql(1)
38
+ @tag.top_albums.first.name.should eql('Overpowered')
39
+ @tag.top_albums.first.tagcount.should eql(105)
40
+ @tag.top_albums.first.mbid.should eql('')
41
+ @tag.top_albums.first.url.should eql('http://www.last.fm/music/R%C3%B3is%C3%ADn+Murphy/Overpowered')
42
+ @tag.top_albums.first.artist.should be_kind_of(Scrobbler::Artist)
43
+ @tag.top_albums.first.artist.name.should eql('Róisín Murphy')
44
+ @tag.top_albums.first.artist.mbid.should eql('4c56405d-ba8e-4283-99c3-1dc95bdd50e7')
45
+ @tag.top_albums.first.artist.url.should eql('http://www.last.fm/music/R%C3%B3is%C3%ADn+Murphy')
46
+ @tag.top_albums.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/26856969.png')
47
+ @tag.top_albums.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/26856969.png')
48
+ @tag.top_albums.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/26856969.png')
49
+ end
50
+
51
+ it 'should be able to find its top artists' do
52
+ @tag.top_artists.should be_kind_of(Array)
53
+ @tag.top_artists.should have(50).items
54
+ @tag.top_artists.first.should be_kind_of(Scrobbler::Artist)
55
+ @tag.top_artists.first.rank.should eql(1)
56
+ @tag.top_artists.first.name.should eql('ABBA')
57
+ @tag.top_artists.first.tagcount.should eql(1229)
58
+ @tag.top_artists.first.mbid.should eql('d87e52c5-bb8d-4da8-b941-9f4928627dc8')
59
+ @tag.top_artists.first.url.should eql('http://www.last.fm/music/ABBA')
60
+ @tag.top_artists.first.streamable.should be_true
61
+ @tag.top_artists.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34/135930.jpg')
62
+ @tag.top_artists.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/135930.jpg')
63
+ @tag.top_artists.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/135930.jpg')
64
+ end
65
+
66
+ it 'should be able to find global top tags' do
67
+ Scrobbler::Tag.should have(250).top_tags
68
+ first = Scrobbler::Tag.top_tags.first
69
+ first.should be_kind_of(Scrobbler::Tag)
70
+ first.name.should eql('rock')
71
+ first.count.should eql(2267576)
72
+ first.url.should eql('www.last.fm/tag/rock')
73
+ end
74
+
75
+ it 'should be able to find its top tracks' do
76
+ @tag.top_tracks.should be_kind_of(Array)
77
+ @tag.top_tracks.should have(50).items
78
+ @tag.top_tracks.first.should be_kind_of(Scrobbler::Track)
79
+ @tag.top_tracks.first.rank.should eql(1)
80
+ @tag.top_tracks.first.name.should eql('Stayin\' Alive')
81
+ @tag.top_tracks.first.tagcount.should eql(422)
82
+ @tag.top_tracks.first.mbid.should eql('')
83
+ @tag.top_tracks.first.streamable.should be_true
84
+ @tag.top_tracks.first.url.should eql('http://www.last.fm/music/Bee+Gees/_/Stayin%27+Alive')
85
+ @tag.top_tracks.first.artist.should be_kind_of(Scrobbler::Artist)
86
+ @tag.top_tracks.first.artist.name.should eql('Bee Gees')
87
+ @tag.top_tracks.first.artist.mbid.should eql('bf0f7e29-dfe1-416c-b5c6-f9ebc19ea810')
88
+ @tag.top_tracks.first.artist.url.should eql('http://www.last.fm/music/Bee+Gees')
89
+ @tag.top_tracks.first.image(:small).should eql('http://images.amazon.com/images/P/B00069590Q.01._SCMZZZZZZZ_.jpg')
90
+ @tag.top_tracks.first.image(:medium).should eql('http://images.amazon.com/images/P/B00069590Q.01._SCMZZZZZZZ_.jpg')
91
+ @tag.top_tracks.first.image(:large).should eql('http://images.amazon.com/images/P/B00069590Q.01._SCMZZZZZZZ_.jpg')
92
+ end
93
+
94
+ it 'should be able to get the weekly artist chart'
95
+
96
+ it 'should be able to get the weekly chart list'
97
+
98
+ it 'should be able to search for a tag'
99
+
100
+ end
101
+
@@ -0,0 +1,95 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Scrobbler::Track do
4
+
5
+ before(:all) do
6
+ @track = Scrobbler::Track.new(Scrobbler::Artist.new('Carrie Underwood'), 'Before He Cheats')
7
+ end
8
+
9
+ it 'should know the artist' do
10
+ @track.artist.should be_kind_of(Scrobbler::Artist)
11
+ @track.artist.name.should eql('Carrie Underwood')
12
+ end
13
+
14
+ it 'should know the name' do
15
+ @track.name.should eql('Before He Cheats')
16
+ end
17
+
18
+ it 'should implement all methods from the Last.fm 2.0 API' do
19
+ @track.should respond_to(:add_tags)
20
+ @track.should respond_to(:ban)
21
+ @track.should respond_to(:load_info)
22
+ @track.should respond_to(:similar)
23
+ @track.should respond_to(:tags)
24
+ @track.should respond_to(:top_tags)
25
+ @track.should respond_to(:top_fans)
26
+ @track.should respond_to(:love)
27
+ @track.should respond_to(:remove_tag)
28
+ @track.should respond_to(:search)
29
+ @track.should respond_to(:share)
30
+ end
31
+
32
+ it 'should be able to add tags'
33
+
34
+ it 'should be able to be banned'
35
+
36
+ it 'should be able to load more information' do
37
+ @track.load_info
38
+ @track.id.should eql(1019817)
39
+ @track.mbid.should eql('')
40
+ @track.url.should eql('http://www.last.fm/music/Cher/_/Believe')
41
+ @track.duration.should eql(222000)
42
+ @track.streamable.should be_true
43
+ @track.listeners.should eql(114831)
44
+ @track.playcount.should eql(435094)
45
+ @track.artist.should be_kind_of(Scrobbler::Artist)
46
+ @track.artist.name.should eql('Cher')
47
+ @track.artist.mbid.should eql('bfcc6d75-a6a5-4bc6-8282-47aec8531818')
48
+ @track.artist.url.should eql('http://www.last.fm/music/Cher')
49
+ @track.album.should be_kind_of(Scrobbler::Album)
50
+ @track.album.position.should eql(1)
51
+ @track.album.artist.should be_kind_of(Scrobbler::Artist)
52
+ @track.album.artist.name.should eql('Cher')
53
+ @track.album.name.should eql('Believe')
54
+ @track.album.mbid.should eql('61bf0388-b8a9-48f4-81d1-7eb02706dfb0')
55
+ @track.album.url.should eql('http://www.last.fm/music/Cher/Believe')
56
+ @track.album.image(:small).should eql('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
57
+ @track.album.image(:medium).should eql('http://userserve-ak.last.fm/serve/126/8674593.jpg')
58
+ @track.album.image(:large).should eql('http://userserve-ak.last.fm/serve/174s/8674593.jpg')
59
+ end
60
+
61
+ it 'should be able to get similar tracks'
62
+
63
+ it 'should be able to get the user\'s tags'
64
+
65
+ it 'should be able to get its top tags' do
66
+ @track.top_tags.should be_kind_of(Array)
67
+ @track.top_tags.should have(100).items
68
+ @track.top_tags.first.should be_kind_of(Scrobbler::Tag)
69
+ @track.top_tags.first.name.should eql('pop')
70
+ @track.top_tags.first.count.should eql(924808)
71
+ @track.top_tags.first.url.should eql('www.last.fm/tag/pop')
72
+ end
73
+
74
+ it 'should be able to get its top fans' do
75
+ @track.top_fans.should be_kind_of(Array)
76
+ @track.top_fans.should have(3).items
77
+ @track.top_fans.first.should be_kind_of(Scrobbler::User)
78
+ @track.top_fans.first.name.should eql('ccaron0')
79
+ @track.top_fans.first.url.should eql('http://www.last.fm/user/ccaron0')
80
+ @track.top_fans.first.image(:small).should eql('')
81
+ @track.top_fans.first.image(:medium).should eql('')
82
+ @track.top_fans.first.image(:large).should eql('')
83
+ @track.top_fans.first.weight.should eql(335873)
84
+ end
85
+
86
+ it 'should be able to love this track'
87
+
88
+ it 'should be able to remove a tag'
89
+
90
+ it 'should be able to search for a track'
91
+
92
+ it 'should be able to share a track'
93
+
94
+ end
95
+