bts-scrobbler2 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. data/README.rdoc +155 -0
  2. data/Rakefile +8 -0
  3. data/VERSION.yml +4 -0
  4. data/generators/acceptance_test/USAGE +9 -0
  5. data/generators/acceptance_test/acceptance_test_generator.rb +57 -0
  6. data/generators/acceptance_test/templates/acceptance_test.rb.erb +14 -0
  7. data/generators/resource/USAGE +8 -0
  8. data/generators/resource/resource_generator.rb +47 -0
  9. data/generators/resource/templates/resource.rb.erb +11 -0
  10. data/generators/resource/templates/spec.rb.erb +22 -0
  11. data/lib/scrobbler2.rb +23 -0
  12. data/lib/scrobbler2/album.rb +11 -0
  13. data/lib/scrobbler2/artist.rb +26 -0
  14. data/lib/scrobbler2/auth.rb +19 -0
  15. data/lib/scrobbler2/base.rb +100 -0
  16. data/lib/scrobbler2/event.rb +12 -0
  17. data/lib/scrobbler2/geo.rb +15 -0
  18. data/lib/scrobbler2/group.rb +14 -0
  19. data/lib/scrobbler2/library.rb +12 -0
  20. data/lib/scrobbler2/playlist.rb +10 -0
  21. data/lib/scrobbler2/tag.rb +18 -0
  22. data/lib/scrobbler2/track.rb +13 -0
  23. data/lib/scrobbler2/user.rb +29 -0
  24. data/lib/scrobbler2/venue.rb +12 -0
  25. data/test/acceptance/album/info_test.rb +56 -0
  26. data/test/acceptance/artist/add_tags_test.rb +14 -0
  27. data/test/acceptance/artist/events_test.rb +47 -0
  28. data/test/acceptance/artist/info_test.rb +53 -0
  29. data/test/acceptance/artist/shouts_test.rb +48 -0
  30. data/test/acceptance/artist/similar_artists_test.rb +20 -0
  31. data/test/acceptance/artist/tags_test.rb +24 -0
  32. data/test/acceptance/artist/top_albums_test.rb +34 -0
  33. data/test/acceptance/artist/top_fans.rb +19 -0
  34. data/test/acceptance/artist/top_tags.rb +18 -0
  35. data/test/acceptance/artist/top_tracks.rb +47 -0
  36. data/test/acceptance/auth/auth_test.rb +21 -0
  37. data/test/acceptance/event/info_test.rb +66 -0
  38. data/test/acceptance/event/shouts_test.rb +49 -0
  39. data/test/acceptance/geo/events_test.rb +14 -0
  40. data/test/acceptance/geo/top_artists_test.rb +16 -0
  41. data/test/acceptance/geo/top_tracks_test.rb +16 -0
  42. data/test/acceptance/group/members_test.rb +60 -0
  43. data/test/acceptance/group/weekly_album_chart_test.rb +61 -0
  44. data/test/acceptance/group/weekly_artist_chart_test.rb +54 -0
  45. data/test/acceptance/group/weekly_chart_list_test.rb +39 -0
  46. data/test/acceptance/group/weekly_track_chart_test.rb +61 -0
  47. data/test/acceptance/library/albums_test.rb +34 -0
  48. data/test/acceptance/library/artists_test.rb +33 -0
  49. data/test/acceptance/library/tracks_test.rb +33 -0
  50. data/test/acceptance/playlist/fetch_test.rb +68 -0
  51. data/test/acceptance/shared/album.rb +41 -0
  52. data/test/acceptance/shared/artist.rb +16 -0
  53. data/test/acceptance/shared/paged_result.rb +16 -0
  54. data/test/acceptance/shared/top_fans.rb +29 -0
  55. data/test/acceptance/shared/top_tags.rb +23 -0
  56. data/test/acceptance/shared/track.rb +23 -0
  57. data/test/acceptance/tag/similar_test.rb +15 -0
  58. data/test/acceptance/tag/top_albums_test.rb +37 -0
  59. data/test/acceptance/tag/top_artists_test.rb +31 -0
  60. data/test/acceptance/tag/top_tags_test.rb +32 -0
  61. data/test/acceptance/tag/top_tracks_test.rb +33 -0
  62. data/test/acceptance/tag/weekly_artist_chart.rb +54 -0
  63. data/test/acceptance/tag/weekly_chart_list.rb +39 -0
  64. data/test/acceptance/test_helper.rb +15 -0
  65. data/test/acceptance/track/info_test.rb +47 -0
  66. data/test/acceptance/track/similar_test.rb +22 -0
  67. data/test/acceptance/track/top_fans_test.rb +23 -0
  68. data/test/acceptance/track/top_tags_test.rb +24 -0
  69. data/test/acceptance/user/events_test.rb +27 -0
  70. data/test/acceptance/user/friends_test.rb +14 -0
  71. data/test/acceptance/user/info_test.rb +19 -0
  72. data/test/acceptance/user/loved_tracks_test.rb +14 -0
  73. data/test/acceptance/user/neighbours_test.rb +14 -0
  74. data/test/acceptance/user/past_events_test.rb +14 -0
  75. data/test/acceptance/user/playlists_test.rb +14 -0
  76. data/test/acceptance/user/recent_tracks_test.rb +14 -0
  77. data/test/acceptance/user/recommended_artists_test.rb +16 -0
  78. data/test/acceptance/user/recommended_events_test.rb +16 -0
  79. data/test/acceptance/user/shouts_test.rb +14 -0
  80. data/test/acceptance/user/top_albums_test.rb +14 -0
  81. data/test/acceptance/user/top_artists_test.rb +14 -0
  82. data/test/acceptance/user/top_tags_test.rb +14 -0
  83. data/test/acceptance/user/top_tracks_test.rb +14 -0
  84. data/test/acceptance/user/weekly_album_chart_test.rb +14 -0
  85. data/test/acceptance/user/weekly_artist_chart_test.rb +14 -0
  86. data/test/acceptance/user/weekly_chart_list_test.rb +14 -0
  87. data/test/acceptance/user/weekly_track_chart_test.rb +14 -0
  88. data/test/acceptance/venue/events_test.rb +14 -0
  89. data/test/acceptance/venue/past_events_test.rb +14 -0
  90. data/test/generators/test_acceptance_test_generator.rb +46 -0
  91. data/test/generators/test_generator_helper.rb +29 -0
  92. data/test/generators/test_resource_generator.rb +71 -0
  93. data/test/unit/album_spec.rb +17 -0
  94. data/test/unit/artist_spec.rb +62 -0
  95. data/test/unit/auth_spec.rb +22 -0
  96. data/test/unit/base_spec.rb +193 -0
  97. data/test/unit/event_spec.rb +23 -0
  98. data/test/unit/geo_spec.rb +36 -0
  99. data/test/unit/group_spec.rb +38 -0
  100. data/test/unit/library_spec.rb +27 -0
  101. data/test/unit/playlist_spec.rb +18 -0
  102. data/test/unit/spec_helper.rb +7 -0
  103. data/test/unit/tag_spec.rb +50 -0
  104. data/test/unit/track_spec.rb +33 -0
  105. data/test/unit/user_spec.rb +148 -0
  106. data/test/unit/venue_spec.rb +29 -0
  107. metadata +260 -0
@@ -0,0 +1,62 @@
1
+ require File.dirname(__FILE__) + "/spec_helper.rb"
2
+
3
+ describe "Artist" do
4
+ before(:each) do
5
+ @artist = Scrobbler2::Artist.new "Metallica"
6
+ @artist.class.stub!(:get).and_return Hash.new
7
+ end
8
+
9
+ it "should have a default query {:artist => 'Metallica'}" do
10
+ @artist.instance_variable_get(:@query).should == {:artist => 'Metallica'}
11
+ end
12
+
13
+ it "info should call get with 'artist.getInfo' with query params :artist => @name" do
14
+ @artist.class.should_receive(:get).with('artist.getinfo', {:artist => "Metallica"}, {}).and_return Hash.new
15
+ @artist.info
16
+ end
17
+
18
+ it "similar should call get with 'artist.getSimilar' with query params :artist => @name" do
19
+ @artist.class.should_receive(:get).with('artist.getsimilar', {:artist => "Metallica"}, {}).and_return Hash.new
20
+ @artist.similar
21
+ end
22
+
23
+ it "top_albums should call get with 'artist.getTopAlbums' with query params :artist => @name" do
24
+ @artist.class.should_receive(:get).with('artist.gettopalbums', {:artist => "Metallica"}, {}).and_return Hash.new
25
+ @artist.top_albums
26
+ end
27
+
28
+ it "events should call get with 'artist.getEvents' with query params :artist => @name" do
29
+ @artist.class.should_receive(:get).with('artist.getevents', {:artist => "Metallica"}, {}).and_return Hash.new
30
+ @artist.events
31
+ end
32
+
33
+ it "shouts should call get with 'artist.getShouts' with query params :artist => @name" do
34
+ @artist.class.should_receive(:get).with('artist.getshouts', {:artist => "Metallica"}, {}).and_return Hash.new
35
+ @artist.shouts
36
+ end
37
+
38
+ it "top_fans should call get with 'artist.getTopFans' with query params :artist => @name" do
39
+ @artist.class.should_receive(:get).with('artist.gettopfans', {:artist => "Metallica"}, {}).and_return Hash.new
40
+ @artist.top_fans
41
+ end
42
+
43
+ it "top_tags should call get with 'artist.getTopTags' with query params :artist => @name" do
44
+ @artist.class.should_receive(:get).with('artist.gettoptags', {:artist => "Metallica"}, {}).and_return Hash.new
45
+ @artist.top_tags
46
+ end
47
+
48
+ it "top_tracks should call get with 'artist.getTopTrakcs' with query params :artist => @name" do
49
+ @artist.class.should_receive(:get).with('artist.gettoptracks', {:artist => "Metallica"}, {}).and_return Hash.new
50
+ @artist.top_tracks
51
+ end
52
+
53
+ it "tags should call get_with_auth with 'artist.getTags', and query params :artist => @name" do
54
+ @artist.class.should_receive(:get_with_auth).with('artist.gettags', {:artist => "Metallica"}).and_return Hash.new :tags => []
55
+ @artist.tags
56
+ end
57
+
58
+ it "add tags should post_with_auth with 'artist.addTags', and query params :artist => @name, :tags => 'test1, test2'" do
59
+ @artist.class.should_receive(:post_with_auth).with('artist.addtags', {:artist => "Metallica", :tags => "test1,test2"}).and_return Hash.new
60
+ @artist.add_tags ["test1", "test2"]
61
+ end
62
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + "/spec_helper.rb"
2
+
3
+
4
+ describe "Auth" do
5
+ before(:each) do
6
+ @auth = Scrobbler2::Auth.new
7
+ @artist.class.stub!(:get_with_auth).and_return Hash.new
8
+ end
9
+
10
+ it "token should call get_with_auth with auth.gettoken" do
11
+ @auth.class.should_receive(:get_with_auth).with('auth.gettoken').and_return Hash.new :lfm => {}
12
+ @auth.token
13
+ end
14
+
15
+ it "session should call get_with_auth with auth.getsession and token=token" do
16
+ @auth.should_receive(:token).and_return :test_token
17
+ @auth.class.should_receive(:get_with_auth).with('auth.getsession', {:token => :test_token}).and_return Hash.new :lfm => {}
18
+ @auth.session
19
+ end
20
+
21
+
22
+ end
@@ -0,0 +1,193 @@
1
+ require File.dirname(__FILE__) + "/spec_helper.rb"
2
+
3
+ class TestBaseImplementation < Scrobbler2::Base
4
+ end
5
+
6
+ describe "Base" do
7
+
8
+ before(:each) do
9
+ HTTParty.stub!(:get)
10
+ Scrobbler2::Base.api_key = "api_key"
11
+ Scrobbler2::Base.api_secret = "api_secret"
12
+ end
13
+
14
+ it "should have attribute api key" do
15
+ Scrobbler2::Base.api_key = "blah"
16
+ Scrobbler2::Base.api_key.should == "blah"
17
+ end
18
+
19
+ it "should have attribute session_key" do
20
+ Scrobbler2::Base.session_key = "blah"
21
+ Scrobbler2::Base.session_key.should == "blah"
22
+ end
23
+
24
+ it "should have attribute api secret" do
25
+ Scrobbler2::Base.api_secret = "blah"
26
+ Scrobbler2::Base.api_secret.should == "blah"
27
+ end
28
+
29
+ describe "has_resource" do
30
+
31
+ before(:each) do
32
+ TestBaseImplementation.module_eval("has_resource :test_info, :root => :test");
33
+ TestBaseImplementation.stub!(:get).and_return({})
34
+ @test = TestBaseImplementation.new
35
+ end
36
+
37
+ it "should create a named method" do
38
+ @test.method(:test_info).should_not be_nil
39
+ end
40
+
41
+ describe "the method" do
42
+ it "the method should call self.get" do
43
+ TestBaseImplementation.should_receive(:get)
44
+ @test.test_info
45
+ end
46
+
47
+ it "should call get with resource name got from the class name and the method name" do
48
+ TestBaseImplementation.should_receive(:get).with("testbaseimplementation.gettestinfo", an_instance_of(Hash), an_instance_of(Hash))
49
+ @test.test_info
50
+ end
51
+
52
+ it "should get with query options from @query" do
53
+ @test.instance_variable_set(:@query, {:name => "test"})
54
+ TestBaseImplementation.should_receive(:get).with("testbaseimplementation.gettestinfo", {:name => "test"}, an_instance_of(Hash))
55
+ @test.test_info
56
+ end
57
+
58
+ it "should return the root element" do
59
+ TestBaseImplementation.should_receive(:get).and_return({:test=>:root_element});
60
+ @test.test_info.should == :root_element
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+ describe "has_resource with options = {:resource_name => resource.method}" do
67
+ before(:each) do
68
+ TestBaseImplementation.module_eval("has_resource :test_info, :root => :test, :resource_name => 'resource.method'");
69
+ TestBaseImplementation.stub!(:get).and_return({})
70
+ @test = TestBaseImplementation.new
71
+ end
72
+
73
+ it "should call get with resource name got from options" do
74
+ TestBaseImplementation.should_receive(:get).with("resource.method", an_instance_of(Hash), an_instance_of(Hash))
75
+ @test.test_info
76
+ end
77
+ end
78
+
79
+ describe "sign" do
80
+ it "should return an md5 digest of the 'query_signature'" do
81
+ Scrobbler2::Base.should_receive(:query_signature).with(:query).and_return('query_signature')
82
+ Scrobbler2::Base.sign(:query).should == '4987b19cfbded59cd717b8ffd9f1a6bf'
83
+ end
84
+ end
85
+
86
+ describe "query_signature" do
87
+ it "should return an unencoded api_signature" do
88
+ query = {:method => "artist.getInfo", :api_key => "api_key", :format => "json"}
89
+ Scrobbler2::Base.query_signature(query).should == "api_keyapi_keyformatjsonmethodartist.getInfoapi_secret"
90
+ end
91
+
92
+ end
93
+
94
+ describe "get" do
95
+ it "should call HTTParty.get" do
96
+ HTTParty.should_receive(:get).with('http://ws.audioscrobbler.com/2.0/', {:query => {:method=>'artist.getInfo', :format=>'json', :api_key => 'api_key'}})
97
+ Scrobbler2::Base.get('artist.getInfo', {})
98
+ end
99
+ end
100
+
101
+
102
+ describe "auth_request", :shared => true do
103
+
104
+ it "should set the query method" do
105
+ HTTParty.should_receive(http_method) do |url, options|
106
+ options[options_param][:method].should == 'artist.getInfo'
107
+ end
108
+ action
109
+ end
110
+
111
+ it "should set the api_key" do
112
+ HTTParty.should_receive(http_method) do |url, options|
113
+ options[options_param][:api_key].should == 'api_key'
114
+ end
115
+ action
116
+ end
117
+
118
+ it "should set the api_sginature" do
119
+ Scrobbler2::Base.should_receive(:sign).with(an_instance_of(Hash)).and_return('signature')
120
+ HTTParty.should_receive(http_method) do |url, options|
121
+ options[options_param][:api_sig].should == 'signature'
122
+ end
123
+ action
124
+ end
125
+
126
+ it "should set the session_key, if available" do
127
+ Scrobbler2::Base.should_receive(:session_key).at_least(1).and_return("SESSIONKEY");
128
+ HTTParty.should_receive(http_method) do |url, options|
129
+ options[options_param][:sk].should == 'SESSIONKEY'
130
+ end
131
+ action
132
+ end
133
+
134
+ it "should not set the session_key, if unavailable" do
135
+ Scrobbler2::Base.should_receive(:session_key).at_least(1).and_return(nil);
136
+ HTTParty.should_receive(http_method) do |url, options|
137
+ options[options_param].should_not have_key(:sk)
138
+ end
139
+ action
140
+ end
141
+
142
+ end
143
+
144
+
145
+ describe "get_with_auth" do
146
+ it "should call HTTParty.get" do
147
+ HTTParty.should_receive(:get).with('http://ws.audioscrobbler.com/2.0/', an_instance_of(Hash))
148
+ Scrobbler2::Base.get_with_auth('artist.getInfo', {})
149
+ end
150
+
151
+ def action
152
+ Scrobbler2::Base.get_with_auth('artist.getInfo', {})
153
+ end
154
+
155
+ def http_method
156
+ :get
157
+ end
158
+
159
+ def options_param
160
+ :query
161
+ end
162
+
163
+ it_should_behave_like "auth_request"
164
+ end
165
+
166
+
167
+ describe "post_with_auth" do
168
+ it "should call HTTParty.post" do
169
+ HTTParty.should_receive(:post).with('http://ws.audioscrobbler.com/2.0/', an_instance_of(Hash))
170
+ Scrobbler2::Base.post_with_auth('artist.getInfo', {})
171
+ end
172
+
173
+ def action
174
+ Scrobbler2::Base.post_with_auth('artist.getInfo', {})
175
+ end
176
+
177
+ def http_method
178
+ :post
179
+ end
180
+
181
+ def options_param
182
+ :body
183
+ end
184
+
185
+
186
+ it_should_behave_like "auth_request"
187
+
188
+
189
+ end
190
+
191
+ end
192
+
193
+
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + "/spec_helper.rb"
2
+
3
+ describe "Event" do
4
+ before(:each) do
5
+ @event = Scrobbler2::Event.new "328799"
6
+ @event.class.stub!(:get).and_return Hash.new
7
+ end
8
+
9
+ it "should have a default query {:event => '328799'}" do
10
+ @event.instance_variable_get(:@query).should == {:event => "328799"}
11
+ end
12
+
13
+ it "info should call get with 'event.getInfo' with query params :event => @event" do
14
+ @event.class.should_receive(:get).with('event.getinfo', {:event => "328799"}, {}).and_return Hash.new
15
+ @event.info
16
+ end
17
+
18
+ it "shouts should call get with 'event.getShouts' with query params :event => @event" do
19
+ @event.class.should_receive(:get).with('event.getshouts', {:event => "328799"}, {}).and_return Hash.new
20
+ @event.shouts
21
+ end
22
+
23
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + "/spec_helper.rb"
2
+
3
+ describe "Geo" do
4
+ before(:each) do
5
+ @geo = Scrobbler2::Geo.new
6
+ @geo.class.stub!(:get).and_return Hash.new
7
+ end
8
+
9
+ it "should have no default query" do
10
+ @geo.instance_variable_get(:@query).should == {}
11
+ end
12
+
13
+
14
+
15
+ it "events should call get with 'geo.getevents'" do
16
+ @geo.class.should_receive(:get).with('geo.getevents', anything(), anything()).and_return Hash.new
17
+ @geo.events
18
+ end
19
+
20
+
21
+
22
+ it "top_artists should call get with 'geo.gettop_artists'" do
23
+ @geo.class.should_receive(:get).with('geo.gettopartists', anything(), anything()).and_return Hash.new
24
+ @geo.top_artists
25
+ end
26
+
27
+
28
+
29
+ it "top_tracks should call get with 'geo.gettop_tracks'" do
30
+ @geo.class.should_receive(:get).with('geo.gettoptracks', anything(), anything()).and_return Hash.new
31
+ @geo.top_tracks
32
+ end
33
+
34
+
35
+
36
+ end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + "/spec_helper.rb"
2
+
3
+ describe "Group" do
4
+ before(:each) do
5
+ @group = Scrobbler2::Group.new "Stubborn Tiny Lights"
6
+ @group.class.stub!(:get).and_return Hash.new
7
+ end
8
+
9
+ it "should have a default query {:group => 'Stubborn Tiny Lights'}" do
10
+ @group.instance_variable_get(:@query).should == {:group => 'Stubborn Tiny Lights'}
11
+ end
12
+
13
+ it "members should call get with 'group.getMembers' with query params :group => @group" do
14
+ @group.class.should_receive(:get).with('group.getmembers', {:group => 'Stubborn Tiny Lights'}, {}).and_return Hash.new
15
+ @group.members
16
+ end
17
+
18
+ it "weekly_artist_chart should call get with 'group.getShouts' with query params :group => @group" do
19
+ @group.class.should_receive(:get).with('group.getweeklyartistchart', {:group => 'Stubborn Tiny Lights'}, {}).and_return Hash.new
20
+ @group.weekly_artist_chart
21
+ end
22
+
23
+ it "weekly_album_chart should call get with 'group.getShouts' with query params :group => @group" do
24
+ @group.class.should_receive(:get).with('group.getweeklyalbumchart', {:group => 'Stubborn Tiny Lights'}, {}).and_return Hash.new
25
+ @group.weekly_album_chart
26
+ end
27
+
28
+ it "weekly_track_chart should call get with 'group.getShouts' with query params :group => @group" do
29
+ @group.class.should_receive(:get).with('group.getweeklytrackchart', {:group => 'Stubborn Tiny Lights'}, {}).and_return Hash.new
30
+ @group.weekly_track_chart
31
+ end
32
+
33
+ it "weekly_chart_list should call get with 'group.getShouts' with query params :group => @group" do
34
+ @group.class.should_receive(:get).with('group.getweeklychartlist', {:group => 'Stubborn Tiny Lights'}, {}).and_return Hash.new
35
+ @group.weekly_chart_list
36
+ end
37
+
38
+ end
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + "/spec_helper.rb"
2
+
3
+ describe "Library" do
4
+ before(:each) do
5
+ @library = Scrobbler2::Library.new "gingerhendrix"
6
+ @library.class.stub!(:get).and_return Hash.new
7
+ end
8
+
9
+ it "should have a default query {:user => 'gingerhendrix'}" do
10
+ @library.instance_variable_get(:@query).should == {:user => 'gingerhendrix'}
11
+ end
12
+
13
+ it "tracks should call get with 'library.getTracks' with query params :user => @user" do
14
+ @library.class.should_receive(:get).with('library.gettracks', {:user => 'gingerhendrix'}, {}).and_return Hash.new
15
+ @library.tracks
16
+ end
17
+
18
+ it "artists should call get with 'library.getArtists' with query params :user => @user" do
19
+ @library.class.should_receive(:get).with('library.getartists', {:user => 'gingerhendrix'}, {}).and_return Hash.new
20
+ @library.artists
21
+ end
22
+
23
+ it "tracks should call get with 'library.getTracks' with query params :user => @user" do
24
+ @library.class.should_receive(:get).with('library.getalbums', {:user => 'gingerhendrix'}, {}).and_return Hash.new
25
+ @library.albums
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + "/spec_helper.rb"
2
+
3
+ describe "Playlist" do
4
+ before(:each) do
5
+ @playlist = Scrobbler2::Playlist.new "lastfm://playlist/album/2026126"
6
+ @playlist.class.stub!(:get).and_return Hash.new
7
+ end
8
+
9
+ it "should have a default query {:playlistURL => 'lastfm://playlist/album/2026126'}" do
10
+ @playlist.instance_variable_get(:@query).should == {:playlistURL => 'lastfm://playlist/album/2026126'}
11
+ end
12
+
13
+ it "fetch should call get with 'playlist.fetch' with query params :playlistURL => @url" do
14
+ @playlist.class.should_receive(:get).with('playlist.fetch', {:playlistURL => 'lastfm://playlist/album/2026126'}, {}).and_return Hash.new
15
+ @playlist.fetch
16
+ end
17
+
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require 'spec/interop/test'
4
+
5
+ $: << File.dirname(__FILE__) + "/../../lib/"
6
+
7
+ require 'scrobbler2'
@@ -0,0 +1,50 @@
1
+ require File.dirname(__FILE__) + "/spec_helper.rb"
2
+
3
+ describe "Tag" do
4
+ before(:each) do
5
+ @tag = Scrobbler2::Tag.new "Disco"
6
+ @tag.class.stub!(:get).and_return Hash.new
7
+ end
8
+
9
+ it "should have a default query {:tag => 'Disco'}" do
10
+ @tag.instance_variable_get(:@query).should == {:tag => 'Disco'}
11
+ end
12
+
13
+ it "similar should call get with 'tag.getSimilar' with query params :tag => @tag" do
14
+ @tag.class.should_receive(:get).with('tag.getsimilar', {:tag => "Disco"}, {}).and_return Hash.new
15
+ @tag.similar
16
+ end
17
+
18
+ it "top_albums should call get with 'tag.getTopAlbums' with query params :tag => @tag" do
19
+ @tag.class.should_receive(:get).with('tag.gettopalbums', {:tag => "Disco"}, {}).and_return Hash.new
20
+ @tag.top_albums
21
+ end
22
+
23
+ it "top_artists should call get with 'tag.getTopArtists' with query params :tag => @tag" do
24
+ @tag.class.should_receive(:get).with('tag.gettopartists', {:tag => "Disco"}, {}).and_return Hash.new
25
+ @tag.top_artists
26
+ end
27
+
28
+ it "top_tracks should call get with 'tag.getTopTracks' with query params :tag => @tag" do
29
+ @tag.class.should_receive(:get).with('tag.gettoptracks', {:tag => "Disco"}, {}).and_return Hash.new
30
+ @tag.top_tracks
31
+ end
32
+
33
+ it "top_tags should call get with 'tag.getTopTags' with query params :tag => @tag" do
34
+ @tag.class.should_receive(:get).with('tag.gettoptags', {:tag => "Disco"}, {}).and_return Hash.new
35
+ @tag.top_tags
36
+ end
37
+
38
+ it "weekly_artist_chart should call get with 'tag.getWeeklyArtistChart' with query params :tag => @tag" do
39
+ @tag.class.should_receive(:get).with('tag.getweeklyartistchart', {:tag => "Disco"}, {}).and_return Hash.new
40
+ @tag.weekly_artist_chart
41
+ end
42
+
43
+
44
+ it "weekly_chart_list should call get with 'tag.getWeeklyChartList' with query params :tag => @tag" do
45
+ @tag.class.should_receive(:get).with('tag.getweeklychartlist', {:tag => "Disco"}, {}).and_return Hash.new
46
+ @tag.weekly_chart_list
47
+ end
48
+
49
+ end
50
+