lastfm 1.26.0 → 1.27.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -2
- data/.travis.yml +3 -0
- data/README.md +14 -5
- data/lastfm.gemspec +3 -4
- data/lib/lastfm.rb +0 -1
- data/lib/lastfm/method_category/album.rb +68 -1
- data/lib/lastfm/method_category/artist.rb +7 -0
- data/lib/lastfm/method_category/base.rb +1 -1
- data/lib/lastfm/method_category/track.rb +5 -2
- data/lib/lastfm/method_category/user.rb +2 -2
- data/lib/lastfm/response.rb +19 -1
- data/lib/lastfm/util.rb +6 -11
- data/spec/fixtures/album_get_buylinks.xml +31 -0
- data/spec/fixtures/album_get_info_without_release_date.xml +184 -0
- data/spec/fixtures/album_get_shouts.xml +15 -0
- data/spec/fixtures/album_get_tags.xml +13 -0
- data/spec/fixtures/album_get_top_tags.xml +15 -0
- data/spec/fixtures/album_search.xml +35 -0
- data/spec/fixtures/album_search_no_match.xml +10 -0
- data/spec/fixtures/album_search_single_album.xml +23 -0
- data/spec/fixtures/artist_get_correction.xml +12 -0
- data/spec/fixtures/artist_search.xml +1 -1
- data/spec/fixtures/tag_search.xml +1 -1
- data/spec/fixtures/track_search_no_match.xml +11 -0
- data/spec/fixtures/track_search_single_track.xml +1 -1
- data/spec/fixtures/user_get_loved_tracks_no_tracks.xml +5 -0
- data/spec/fixtures/user_get_loved_tracks_single_track.xml +17 -0
- data/spec/lastfm_spec.rb +34 -34
- data/spec/method_category_spec.rb +1 -1
- data/spec/method_specs/album_spec.rb +255 -25
- data/spec/method_specs/artist_spec.rb +82 -70
- data/spec/method_specs/chart_spec.rb +13 -13
- data/spec/method_specs/event_spec.rb +3 -3
- data/spec/method_specs/geo_spec.rb +13 -13
- data/spec/method_specs/group_spec.rb +4 -4
- data/spec/method_specs/library_spec.rb +7 -7
- data/spec/method_specs/radio_spec.rb +10 -10
- data/spec/method_specs/tag_spec.rb +28 -28
- data/spec/method_specs/tasteometer_spec.rb +4 -4
- data/spec/method_specs/track_spec.rb +91 -73
- data/spec/method_specs/user_spec.rb +124 -94
- data/spec/response_spec.rb +6 -6
- data/spec/util_spec.rb +16 -16
- metadata +33 -23
@@ -4,30 +4,30 @@ describe '#user' do
|
|
4
4
|
before { init_lastfm }
|
5
5
|
|
6
6
|
it 'should return an instance of Lastfm::User' do
|
7
|
-
@lastfm.user.
|
7
|
+
expect(@lastfm.user).to be_an_instance_of(Lastfm::MethodCategory::User)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '#get_info' do
|
11
11
|
context 'with params' do
|
12
12
|
it 'should get user info' do
|
13
|
-
@lastfm.
|
13
|
+
expect(@lastfm).to receive(:request).with('user.getInfo', {:user => 'test'}).and_return(make_response('user_get_info'))
|
14
14
|
info = @lastfm.user.get_info(:user => 'test')
|
15
|
-
info['id'].
|
15
|
+
expect(info['id']).to eq('1000002')
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'without params' do
|
20
20
|
it 'should get current user info' do
|
21
|
-
@lastfm.
|
21
|
+
expect(@lastfm).to receive(:request).with('user.getInfo', {}, :get, true, true).and_return(make_response('user_get_info'))
|
22
22
|
info = @lastfm.user.get_info
|
23
|
-
info['id'].
|
23
|
+
expect(info['id']).to eq('1000002')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe '#get_top_artists' do
|
29
29
|
it 'should get user\'s top artists' do
|
30
|
-
@lastfm.
|
30
|
+
expect(@lastfm).to receive(:request).with('user.getTopArtists', {
|
31
31
|
:user => 'test',
|
32
32
|
:period => 'overall',
|
33
33
|
:limit => nil,
|
@@ -38,21 +38,21 @@ describe '#user' do
|
|
38
38
|
:user => 'test',
|
39
39
|
:period => 'overall')
|
40
40
|
|
41
|
-
artists.size.
|
42
|
-
artists[0]['name'].
|
43
|
-
artists[0]['playcount'].
|
41
|
+
expect(artists.size).to eq(3)
|
42
|
+
expect(artists[0]['name']).to eq('Pain of Salvation')
|
43
|
+
expect(artists[0]['playcount']).to eq('1354')
|
44
44
|
|
45
|
-
artists[1]['name'].
|
46
|
-
artists[1]['playcount'].
|
45
|
+
expect(artists[1]['name']).to eq('Opeth')
|
46
|
+
expect(artists[1]['playcount']).to eq('1186')
|
47
47
|
|
48
|
-
artists[2]['name'].
|
49
|
-
artists[2]['playcount'].
|
48
|
+
expect(artists[2]['name']).to eq('Nevermore')
|
49
|
+
expect(artists[2]['playcount']).to eq('959')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe '#get_personal_tags' do
|
54
54
|
it 'should get user\'s tagged artists' do
|
55
|
-
@lastfm.
|
55
|
+
expect(@lastfm).to receive(:request).with('user.getPersonalTags', {
|
56
56
|
:user => 'test',
|
57
57
|
:tag => 'rock',
|
58
58
|
:taggingtype => 'artist',
|
@@ -63,14 +63,14 @@ describe '#user' do
|
|
63
63
|
artists = @lastfm.user.get_personal_tags(
|
64
64
|
:user => 'test',
|
65
65
|
:tag => 'rock')
|
66
|
-
artists[0]['name'].
|
67
|
-
artists[0]['url'].
|
68
|
-
artists[1]['name'].
|
69
|
-
artists.size.
|
66
|
+
expect(artists[0]['name']).to eq('Afghan Whigs')
|
67
|
+
expect(artists[0]['url']).to eq('http://www.last.fm/music/Afghan+Whigs')
|
68
|
+
expect(artists[1]['name']).to eq('Jeff The Brotherhood')
|
69
|
+
expect(artists.size).to eq(5)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'should get user\'s tagged albums' do
|
73
|
-
@lastfm.
|
73
|
+
expect(@lastfm).to receive(:request).with('user.getPersonalTags', {
|
74
74
|
:user => 'test',
|
75
75
|
:tag => 'hip-hop',
|
76
76
|
:taggingtype => 'album',
|
@@ -82,12 +82,12 @@ describe '#user' do
|
|
82
82
|
:user => 'test',
|
83
83
|
:tag => 'hip-hop',
|
84
84
|
:taggingtype => 'album')
|
85
|
-
albums[0]['name'].
|
86
|
-
albums.size.
|
85
|
+
expect(albums[0]['name']).to eq('DJ Bizkid Presents: The Best of Atmosphere')
|
86
|
+
expect(albums.size).to eq(1)
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'should get user\'s tagged tracks' do
|
90
|
-
@lastfm.
|
90
|
+
expect(@lastfm).to receive(:request).with('user.getPersonalTags', {
|
91
91
|
:user => 'test',
|
92
92
|
:tag => 'jazz',
|
93
93
|
:taggingtype => 'track',
|
@@ -99,16 +99,16 @@ describe '#user' do
|
|
99
99
|
:user => 'test',
|
100
100
|
:tag => 'jazz',
|
101
101
|
:taggingtype => 'track')
|
102
|
-
tracks[0]['name'].
|
103
|
-
tracks[1]['name'].
|
104
|
-
tracks[1]['duration'].
|
105
|
-
tracks.size.
|
102
|
+
expect(tracks[0]['name']).to eq('Come Together')
|
103
|
+
expect(tracks[1]['name']).to eq('Dione')
|
104
|
+
expect(tracks[1]['duration']).to eq('450')
|
105
|
+
expect(tracks.size).to eq(5)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
describe '#get_top_albums' do
|
110
110
|
it 'should get user\'s top albums' do
|
111
|
-
@lastfm.
|
111
|
+
expect(@lastfm).to receive(:request).with('user.getTopAlbums', {
|
112
112
|
:user => 'test',
|
113
113
|
:period => 'overall',
|
114
114
|
:limit => nil,
|
@@ -119,21 +119,21 @@ describe '#user' do
|
|
119
119
|
:user => 'test',
|
120
120
|
:period => 'overall')
|
121
121
|
|
122
|
-
albums.size.
|
122
|
+
expect(albums.size).to eq(2)
|
123
123
|
|
124
|
-
albums[0]['rank'].
|
125
|
-
albums[0]['name'].
|
126
|
-
albums[0]['artist']['name'].
|
124
|
+
expect(albums[0]['rank']).to eq('1')
|
125
|
+
expect(albums[0]['name']).to eq('The Wall')
|
126
|
+
expect(albums[0]['artist']['name']).to eq('Pink Floyd')
|
127
127
|
|
128
|
-
albums[1]['rank'].
|
129
|
-
albums[1]['name'].
|
130
|
-
albums[1]['artist']['name'].
|
128
|
+
expect(albums[1]['rank']).to eq('2')
|
129
|
+
expect(albums[1]['name']).to eq('The Perfect Element, Part I')
|
130
|
+
expect(albums[1]['artist']['name']).to eq('Pain of Salvation')
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
134
|
describe '#get_top_tracks' do
|
135
135
|
it 'should get user\'s top tracks' do
|
136
|
-
@lastfm.
|
136
|
+
expect(@lastfm).to receive(:request).with('user.getTopTracks', {
|
137
137
|
:user => 'test',
|
138
138
|
:period => '7day',
|
139
139
|
:limit => nil,
|
@@ -144,21 +144,21 @@ describe '#user' do
|
|
144
144
|
:user => 'test',
|
145
145
|
:period => '7day')
|
146
146
|
|
147
|
-
tracks.size.
|
147
|
+
expect(tracks.size).to eq(2)
|
148
148
|
|
149
|
-
tracks[0]['rank'].
|
150
|
-
tracks[0]['name'].
|
151
|
-
tracks[0]['artist']['name'].
|
149
|
+
expect(tracks[0]['rank']).to eq('1')
|
150
|
+
expect(tracks[0]['name']).to eq('No Light, No Light (TV On The Radio Remix)')
|
151
|
+
expect(tracks[0]['artist']['name']).to eq('Florence + the Machine')
|
152
152
|
|
153
|
-
tracks[1]['rank'].
|
154
|
-
tracks[1]['name'].
|
155
|
-
tracks[1]['artist']['name'].
|
153
|
+
expect(tracks[1]['rank']).to eq('2')
|
154
|
+
expect(tracks[1]['name']).to eq('Backwords (Porcelain Raft cover)')
|
155
|
+
expect(tracks[1]['artist']['name']).to eq('Oupa & Tony Crow')
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
159
|
describe '#get_loved_tracks' do
|
160
160
|
it 'should get user\'s loved tracks' do
|
161
|
-
@lastfm.
|
161
|
+
expect(@lastfm).to receive(:request).with('user.getLovedTracks', {
|
162
162
|
:user => 'test',
|
163
163
|
:period => nil,
|
164
164
|
:limit => nil,
|
@@ -167,61 +167,91 @@ describe '#user' do
|
|
167
167
|
|
168
168
|
tracks = @lastfm.user.get_loved_tracks(:user => 'test')
|
169
169
|
|
170
|
-
tracks.size.
|
170
|
+
expect(tracks.size).to eq(2)
|
171
171
|
|
172
|
-
tracks[0]['rank'].
|
173
|
-
tracks[0]['name'].
|
174
|
-
tracks[0]['artist']['name'].
|
172
|
+
expect(tracks[0]['rank']).to eq(nil)
|
173
|
+
expect(tracks[0]['name']).to eq('I Spy')
|
174
|
+
expect(tracks[0]['artist']['name']).to eq('Mikhael Paskalev')
|
175
175
|
|
176
|
-
tracks[1]['rank'].
|
177
|
-
tracks[1]['name'].
|
178
|
-
tracks[1]['artist']['name'].
|
176
|
+
expect(tracks[1]['rank']).to eq(nil)
|
177
|
+
expect(tracks[1]['name']).to eq('Working Titles')
|
178
|
+
expect(tracks[1]['artist']['name']).to eq('Damien Jurado')
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should always return an array of tracks' do
|
182
|
+
expect(@lastfm).to receive(:request).with('user.getLovedTracks', {
|
183
|
+
:user => 'test',
|
184
|
+
:period => nil,
|
185
|
+
:limit => nil,
|
186
|
+
:page => nil
|
187
|
+
}).and_return(make_response('user_get_loved_tracks_single_track'))
|
188
|
+
|
189
|
+
tracks = @lastfm.user.get_loved_tracks(:user => 'test')
|
190
|
+
|
191
|
+
expect(tracks.size).to eq(1)
|
192
|
+
|
193
|
+
expect(tracks[0]['rank']).to eq(nil)
|
194
|
+
expect(tracks[0]['name']).to eq('I Spy')
|
195
|
+
expect(tracks[0]['artist']['name']).to eq('Mikhael Paskalev')
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should return an empty array when user has 0 loved tracks' do
|
199
|
+
expect(@lastfm).to receive(:request).with('user.getLovedTracks', {
|
200
|
+
:user => 'test',
|
201
|
+
:period => nil,
|
202
|
+
:limit => nil,
|
203
|
+
:page => nil
|
204
|
+
}).and_return(make_response('user_get_loved_tracks_no_tracks'))
|
205
|
+
|
206
|
+
tracks = @lastfm.user.get_loved_tracks(:user => 'test')
|
207
|
+
|
208
|
+
expect(tracks.size).to eq(0)
|
179
209
|
end
|
180
210
|
end
|
181
211
|
|
182
212
|
describe '#get_friends' do
|
183
213
|
it 'should get user\'s friends' do
|
184
|
-
@lastfm.
|
214
|
+
expect(@lastfm).to receive(:request).with('user.getFriends', {
|
185
215
|
:user => 'test',
|
186
216
|
:recenttracks => nil,
|
187
217
|
:page => nil,
|
188
218
|
:limit => nil
|
189
219
|
}).and_return(make_response('user_get_friends'))
|
190
220
|
friends = @lastfm.user.get_friends(:user => 'test')
|
191
|
-
friends.size.
|
192
|
-
friends[0]['name'].
|
221
|
+
expect(friends.size).to eq(1)
|
222
|
+
expect(friends[0]['name']).to eq('polaroide')
|
193
223
|
end
|
194
224
|
end
|
195
225
|
|
196
226
|
describe '#get_neighbours' do
|
197
227
|
it 'should get user\'s neighbours' do
|
198
|
-
@lastfm.
|
228
|
+
expect(@lastfm).to receive(:request).with('user.getNeighbours', {
|
199
229
|
:user => 'rj',
|
200
230
|
:recenttracks => nil,
|
201
231
|
:page => nil,
|
202
232
|
:limit => nil
|
203
233
|
}).and_return(make_response('user_get_neighbours'))
|
204
234
|
neighbours = @lastfm.user.get_neighbours(:user => 'rj')
|
205
|
-
neighbours.size.
|
206
|
-
neighbours[0]['name'].
|
235
|
+
expect(neighbours.size).to eq(5)
|
236
|
+
expect(neighbours[0]['name']).to eq('willywongi')
|
207
237
|
end
|
208
238
|
end
|
209
239
|
|
210
240
|
describe '#get_new_releases' do
|
211
241
|
it 'should get user\'s new releases' do
|
212
|
-
@lastfm.
|
242
|
+
expect(@lastfm).to receive(:request).with('user.getNewReleases', {
|
213
243
|
:user => 'rj',
|
214
244
|
:userecs => nil
|
215
245
|
}).and_return(make_response('user_get_new_releases'))
|
216
246
|
albums = @lastfm.user.get_new_releases(:user => 'rj')
|
217
|
-
albums.size.
|
218
|
-
albums[0]['name'].
|
247
|
+
expect(albums.size).to eq(20)
|
248
|
+
expect(albums[0]['name']).to eq('Ten Redux')
|
219
249
|
end
|
220
250
|
end
|
221
251
|
|
222
252
|
describe '#get_recent_tracks' do
|
223
253
|
it 'should get user\'s recent tracks' do
|
224
|
-
@lastfm.
|
254
|
+
expect(@lastfm).to receive(:request).with('user.getRecentTracks', {
|
225
255
|
:user => 'test',
|
226
256
|
:page => nil,
|
227
257
|
:limit => nil,
|
@@ -229,12 +259,12 @@ describe '#user' do
|
|
229
259
|
:from => nil
|
230
260
|
}, :get, true, true).and_return(make_response('user_get_recent_tracks'))
|
231
261
|
tracks = @lastfm.user.get_recent_tracks(:user => 'test')
|
232
|
-
tracks[1]['artist']['content'].
|
233
|
-
tracks.size.
|
262
|
+
expect(tracks[1]['artist']['content']).to eq('Kylie Minogue')
|
263
|
+
expect(tracks.size).to eq(2)
|
234
264
|
end
|
235
265
|
|
236
266
|
it 'should not error when a user\'s recent tracks includes malformed data' do
|
237
|
-
@lastfm.
|
267
|
+
expect(@lastfm).to receive(:request).with('user.getRecentTracks', {
|
238
268
|
:user => 'test',
|
239
269
|
:page => nil,
|
240
270
|
:limit => nil,
|
@@ -247,99 +277,99 @@ describe '#user' do
|
|
247
277
|
|
248
278
|
describe '#get_top_tags' do
|
249
279
|
it 'should get user\'s top tags' do
|
250
|
-
@lastfm.
|
280
|
+
expect(@lastfm).to receive(:request).with('user.getTopTags', {
|
251
281
|
:user => 'test',
|
252
282
|
:limit => nil
|
253
283
|
}).and_return(make_response('user_get_top_tags'))
|
254
284
|
tags = @lastfm.user.get_top_tags(:user => 'test')
|
255
|
-
tags[0]['name'].
|
256
|
-
tags[0]['count'].
|
257
|
-
tags[1]['count'].
|
258
|
-
tags.size.
|
285
|
+
expect(tags[0]['name']).to eq('rock')
|
286
|
+
expect(tags[0]['count']).to eq('19')
|
287
|
+
expect(tags[1]['count']).to eq('15')
|
288
|
+
expect(tags.size).to eq(5)
|
259
289
|
end
|
260
290
|
end
|
261
291
|
|
262
292
|
describe '#get_weekly_chart_list' do
|
263
293
|
it 'should get user\'s weekly chart list' do
|
264
|
-
@lastfm.
|
294
|
+
expect(@lastfm).to receive(:request).with('user.getWeeklyChartList', {
|
265
295
|
:user => 'test',
|
266
296
|
:limit => nil,
|
267
297
|
}).and_return(make_response('user_get_weekly_chart_list'))
|
268
298
|
weekly_charts = @lastfm.user.get_weekly_chart_list(:user => 'test')
|
269
|
-
weekly_charts[0]['from'].
|
270
|
-
weekly_charts[0]['to'].
|
271
|
-
weekly_charts[1]['from'].
|
272
|
-
weekly_charts.size.
|
299
|
+
expect(weekly_charts[0]['from']).to eq("1108296002")
|
300
|
+
expect(weekly_charts[0]['to']).to eq("1108900802")
|
301
|
+
expect(weekly_charts[1]['from']).to eq("1108900801")
|
302
|
+
expect(weekly_charts.size).to eq(8)
|
273
303
|
end
|
274
304
|
end
|
275
305
|
|
276
306
|
describe '#get_weekly_artist_chart' do
|
277
307
|
it 'should get user\'s weekly artist chart' do
|
278
|
-
@lastfm.
|
308
|
+
expect(@lastfm).to receive(:request).with('user.getWeeklyArtistChart', {
|
279
309
|
:user => 'test',
|
280
310
|
:limit => nil,
|
281
311
|
:to => nil,
|
282
312
|
:from => nil
|
283
313
|
}).and_return(make_response('user_get_weekly_artist_chart'))
|
284
314
|
weekly_artists = @lastfm.user.get_weekly_artist_chart(:user => 'test')
|
285
|
-
weekly_artists[0]['name'].
|
286
|
-
weekly_artists[0]['playcount'].
|
287
|
-
weekly_artists[1]['playcount'].
|
288
|
-
weekly_artists.size.
|
315
|
+
expect(weekly_artists[0]['name']).to eq("Leonard Cohen")
|
316
|
+
expect(weekly_artists[0]['playcount']).to eq("46")
|
317
|
+
expect(weekly_artists[1]['playcount']).to eq("44")
|
318
|
+
expect(weekly_artists.size).to eq(4)
|
289
319
|
end
|
290
320
|
end
|
291
321
|
|
292
322
|
describe '#get_weekly_album_chart' do
|
293
323
|
it 'should get user\'s weekly album chart' do
|
294
|
-
@lastfm.
|
324
|
+
expect(@lastfm).to receive(:request).with('user.getWeeklyAlbumChart', {
|
295
325
|
:user => 'test',
|
296
326
|
:limit => nil,
|
297
327
|
:to => nil,
|
298
328
|
:from => nil
|
299
329
|
}).and_return(make_response('user_get_weekly_album_chart'))
|
300
330
|
weekly_albums = @lastfm.user.get_weekly_album_chart(:user => 'test')
|
301
|
-
weekly_albums[0]['artist']['content'].
|
302
|
-
weekly_albums[0]['playcount'].
|
303
|
-
weekly_albums[1]['playcount'].
|
304
|
-
weekly_albums.size.
|
331
|
+
expect(weekly_albums[0]['artist']['content']).to eq("Leonard Cohen")
|
332
|
+
expect(weekly_albums[0]['playcount']).to eq("25")
|
333
|
+
expect(weekly_albums[1]['playcount']).to eq("18")
|
334
|
+
expect(weekly_albums.size).to eq(3)
|
305
335
|
end
|
306
336
|
end
|
307
337
|
|
308
338
|
describe '#get_weekly_track_chart' do
|
309
339
|
it 'should get user\'s weekly track chart' do
|
310
|
-
@lastfm.
|
340
|
+
expect(@lastfm).to receive(:request).with('user.getWeeklyTrackChart', {
|
311
341
|
:user => 'test',
|
312
342
|
:limit => nil,
|
313
343
|
:to => nil,
|
314
344
|
:from => nil
|
315
345
|
}).and_return(make_response('user_get_weekly_track_chart'))
|
316
346
|
weekly_tracks = @lastfm.user.get_weekly_track_chart(:user => 'test')
|
317
|
-
weekly_tracks[0]['artist']['content'].
|
318
|
-
weekly_tracks[0]['playcount'].
|
319
|
-
weekly_tracks[1]['playcount'].
|
320
|
-
weekly_tracks.size.
|
347
|
+
expect(weekly_tracks[0]['artist']['content']).to eq("Tori Amos")
|
348
|
+
expect(weekly_tracks[0]['playcount']).to eq("2")
|
349
|
+
expect(weekly_tracks[1]['playcount']).to eq("2")
|
350
|
+
expect(weekly_tracks.size).to eq(3)
|
321
351
|
end
|
322
352
|
end
|
323
353
|
|
324
354
|
describe '#get_recommended_events' do
|
325
355
|
it 'should get a user\'s list of recommended events' do
|
326
|
-
@lastfm.
|
356
|
+
expect(@lastfm).to receive(:request).with('user.getRecommendedEvents', {}, :get, true, true) {
|
327
357
|
make_response('user_get_recommended_events') }
|
328
358
|
|
329
359
|
recommended_events = @lastfm.user.get_recommended_events
|
330
|
-
recommended_events[0]['artists']['headliner'].
|
331
|
-
recommended_events[1]['artists']['headliner'].
|
360
|
+
expect(recommended_events[0]['artists']['headliner']).to eq('Toro y Moi')
|
361
|
+
expect(recommended_events[1]['artists']['headliner']).to eq('Reel Big Fish')
|
332
362
|
end
|
333
363
|
end
|
334
364
|
|
335
365
|
describe '#get_recommended_artists' do
|
336
366
|
it 'shoud get user\'s recommended artists' do
|
337
|
-
@lastfm.
|
367
|
+
expect(@lastfm).to receive(:request).with('user.getRecommendedArtists', {}, :get, true, true) {
|
338
368
|
make_response('user_get_recommended_artists') }
|
339
369
|
|
340
370
|
recommended_artists = @lastfm.user.get_recommended_artists
|
341
|
-
recommended_artists[0]['name'].
|
342
|
-
recommended_artists[1]['name'].
|
371
|
+
expect(recommended_artists[0]['name']).to eq('Quest.Room.Project')
|
372
|
+
expect(recommended_artists[1]['name']).to eq('Senior Soul')
|
343
373
|
end
|
344
374
|
end
|
345
375
|
end
|
data/spec/response_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe 'Lastfm::Response' do
|
|
8
8
|
|
9
9
|
describe '.new' do
|
10
10
|
it 'should instantiate' do
|
11
|
-
Lastfm::Response.new(@ok).
|
11
|
+
expect(Lastfm::Response.new(@ok)).to be_an_instance_of(Lastfm::Response)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -18,12 +18,12 @@ describe 'Lastfm::Response' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should be success' do
|
21
|
-
@response.
|
21
|
+
expect(@response).to be_success
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should parse response body as xml' do
|
25
25
|
xml = @response.xml
|
26
|
-
xml['similartracks']['track'].size.
|
26
|
+
expect(xml['similartracks']['track'].size).to eq(7)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -33,15 +33,15 @@ describe 'Lastfm::Response' do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should not be success' do
|
36
|
-
@response.
|
36
|
+
expect(@response).not_to be_success
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'should have message' do
|
40
|
-
@response.message.
|
40
|
+
expect(@response.message).to eq('Invalid API key - You must be granted a valid key by last.fm')
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should have error number' do
|
44
|
-
@response.error.
|
44
|
+
expect(@response.error).to eq(10)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|