lastfm 1.27.3 → 1.27.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.should be_an_instance_of(Lastfm::MethodCategory::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.should_receive(:request).with('user.getInfo', {:user => 'test'}).and_return(make_response('user_get_info'))
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'].should == '1000002'
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.should_receive(:request).with('user.getInfo', {}, :get, true, true).and_return(make_response('user_get_info'))
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'].should == '1000002'
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.should_receive(:request).with('user.getTopArtists', {
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.should == 3
42
- artists[0]['name'].should == 'Pain of Salvation'
43
- artists[0]['playcount'].should == '1354'
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'].should == 'Opeth'
46
- artists[1]['playcount'].should == '1186'
45
+ expect(artists[1]['name']).to eq('Opeth')
46
+ expect(artists[1]['playcount']).to eq('1186')
47
47
 
48
- artists[2]['name'].should == 'Nevermore'
49
- artists[2]['playcount'].should == '959'
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.should_receive(:request).with('user.getPersonalTags', {
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'].should == 'Afghan Whigs'
67
- artists[0]['url'].should == 'http://www.last.fm/music/Afghan+Whigs'
68
- artists[1]['name'].should == 'Jeff The Brotherhood'
69
- artists.size.should == 5
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.should_receive(:request).with('user.getPersonalTags', {
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'].should == 'DJ Bizkid Presents: The Best of Atmosphere'
86
- albums.size.should == 1
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.should_receive(:request).with('user.getPersonalTags', {
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'].should == 'Come Together'
103
- tracks[1]['name'].should == 'Dione'
104
- tracks[1]['duration'].should == '450'
105
- tracks.size.should == 5
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.should_receive(:request).with('user.getTopAlbums', {
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.should == 2
122
+ expect(albums.size).to eq(2)
123
123
 
124
- albums[0]['rank'].should == '1'
125
- albums[0]['name'].should == 'The Wall'
126
- albums[0]['artist']['name'].should == 'Pink Floyd'
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'].should == '2'
129
- albums[1]['name'].should == 'The Perfect Element, Part I'
130
- albums[1]['artist']['name'].should == 'Pain of Salvation'
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.should_receive(:request).with('user.getTopTracks', {
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.should == 2
147
+ expect(tracks.size).to eq(2)
148
148
 
149
- tracks[0]['rank'].should == '1'
150
- tracks[0]['name'].should == 'No Light, No Light (TV On The Radio Remix)'
151
- tracks[0]['artist']['name'].should == 'Florence + the Machine'
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'].should == '2'
154
- tracks[1]['name'].should == 'Backwords (Porcelain Raft cover)'
155
- tracks[1]['artist']['name'].should == 'Oupa & Tony Crow'
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.should_receive(:request).with('user.getLovedTracks', {
161
+ expect(@lastfm).to receive(:request).with('user.getLovedTracks', {
162
162
  :user => 'test',
163
163
  :period => nil,
164
164
  :limit => nil,
@@ -167,19 +167,19 @@ describe '#user' do
167
167
 
168
168
  tracks = @lastfm.user.get_loved_tracks(:user => 'test')
169
169
 
170
- tracks.size.should == 2
170
+ expect(tracks.size).to eq(2)
171
171
 
172
- tracks[0]['rank'].should == nil
173
- tracks[0]['name'].should == 'I Spy'
174
- tracks[0]['artist']['name'].should == 'Mikhael Paskalev'
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'].should == nil
177
- tracks[1]['name'].should == 'Working Titles'
178
- tracks[1]['artist']['name'].should == 'Damien Jurado'
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
179
  end
180
180
 
181
181
  it 'should always return an array of tracks' do
182
- @lastfm.should_receive(:request).with('user.getLovedTracks', {
182
+ expect(@lastfm).to receive(:request).with('user.getLovedTracks', {
183
183
  :user => 'test',
184
184
  :period => nil,
185
185
  :limit => nil,
@@ -188,15 +188,15 @@ describe '#user' do
188
188
 
189
189
  tracks = @lastfm.user.get_loved_tracks(:user => 'test')
190
190
 
191
- tracks.size.should == 1
191
+ expect(tracks.size).to eq(1)
192
192
 
193
- tracks[0]['rank'].should == nil
194
- tracks[0]['name'].should == 'I Spy'
195
- tracks[0]['artist']['name'].should == 'Mikhael Paskalev'
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
196
  end
197
197
 
198
198
  it 'should return an empty array when user has 0 loved tracks' do
199
- @lastfm.should_receive(:request).with('user.getLovedTracks', {
199
+ expect(@lastfm).to receive(:request).with('user.getLovedTracks', {
200
200
  :user => 'test',
201
201
  :period => nil,
202
202
  :limit => nil,
@@ -205,53 +205,53 @@ describe '#user' do
205
205
 
206
206
  tracks = @lastfm.user.get_loved_tracks(:user => 'test')
207
207
 
208
- tracks.size.should == 0
208
+ expect(tracks.size).to eq(0)
209
209
  end
210
210
  end
211
211
 
212
212
  describe '#get_friends' do
213
213
  it 'should get user\'s friends' do
214
- @lastfm.should_receive(:request).with('user.getFriends', {
214
+ expect(@lastfm).to receive(:request).with('user.getFriends', {
215
215
  :user => 'test',
216
216
  :recenttracks => nil,
217
217
  :page => nil,
218
218
  :limit => nil
219
219
  }).and_return(make_response('user_get_friends'))
220
220
  friends = @lastfm.user.get_friends(:user => 'test')
221
- friends.size.should == 1
222
- friends[0]['name'].should == 'polaroide'
221
+ expect(friends.size).to eq(1)
222
+ expect(friends[0]['name']).to eq('polaroide')
223
223
  end
224
224
  end
225
225
 
226
226
  describe '#get_neighbours' do
227
227
  it 'should get user\'s neighbours' do
228
- @lastfm.should_receive(:request).with('user.getNeighbours', {
228
+ expect(@lastfm).to receive(:request).with('user.getNeighbours', {
229
229
  :user => 'rj',
230
230
  :recenttracks => nil,
231
231
  :page => nil,
232
232
  :limit => nil
233
233
  }).and_return(make_response('user_get_neighbours'))
234
234
  neighbours = @lastfm.user.get_neighbours(:user => 'rj')
235
- neighbours.size.should == 5
236
- neighbours[0]['name'].should == 'willywongi'
235
+ expect(neighbours.size).to eq(5)
236
+ expect(neighbours[0]['name']).to eq('willywongi')
237
237
  end
238
238
  end
239
239
 
240
240
  describe '#get_new_releases' do
241
241
  it 'should get user\'s new releases' do
242
- @lastfm.should_receive(:request).with('user.getNewReleases', {
242
+ expect(@lastfm).to receive(:request).with('user.getNewReleases', {
243
243
  :user => 'rj',
244
244
  :userecs => nil
245
245
  }).and_return(make_response('user_get_new_releases'))
246
246
  albums = @lastfm.user.get_new_releases(:user => 'rj')
247
- albums.size.should == 20
248
- albums[0]['name'].should == 'Ten Redux'
247
+ expect(albums.size).to eq(20)
248
+ expect(albums[0]['name']).to eq('Ten Redux')
249
249
  end
250
250
  end
251
251
 
252
252
  describe '#get_recent_tracks' do
253
253
  it 'should get user\'s recent tracks' do
254
- @lastfm.should_receive(:request).with('user.getRecentTracks', {
254
+ expect(@lastfm).to receive(:request).with('user.getRecentTracks', {
255
255
  :user => 'test',
256
256
  :page => nil,
257
257
  :limit => nil,
@@ -259,12 +259,12 @@ describe '#user' do
259
259
  :from => nil
260
260
  }, :get, true, true).and_return(make_response('user_get_recent_tracks'))
261
261
  tracks = @lastfm.user.get_recent_tracks(:user => 'test')
262
- tracks[1]['artist']['content'].should == 'Kylie Minogue'
263
- tracks.size.should == 2
262
+ expect(tracks[1]['artist']['content']).to eq('Kylie Minogue')
263
+ expect(tracks.size).to eq(2)
264
264
  end
265
265
 
266
266
  it 'should not error when a user\'s recent tracks includes malformed data' do
267
- @lastfm.should_receive(:request).with('user.getRecentTracks', {
267
+ expect(@lastfm).to receive(:request).with('user.getRecentTracks', {
268
268
  :user => 'test',
269
269
  :page => nil,
270
270
  :limit => nil,
@@ -277,99 +277,99 @@ describe '#user' do
277
277
 
278
278
  describe '#get_top_tags' do
279
279
  it 'should get user\'s top tags' do
280
- @lastfm.should_receive(:request).with('user.getTopTags', {
280
+ expect(@lastfm).to receive(:request).with('user.getTopTags', {
281
281
  :user => 'test',
282
282
  :limit => nil
283
283
  }).and_return(make_response('user_get_top_tags'))
284
284
  tags = @lastfm.user.get_top_tags(:user => 'test')
285
- tags[0]['name'].should == 'rock'
286
- tags[0]['count'].should == '19'
287
- tags[1]['count'].should == '15'
288
- tags.size.should == 5
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)
289
289
  end
290
290
  end
291
291
 
292
292
  describe '#get_weekly_chart_list' do
293
293
  it 'should get user\'s weekly chart list' do
294
- @lastfm.should_receive(:request).with('user.getWeeklyChartList', {
294
+ expect(@lastfm).to receive(:request).with('user.getWeeklyChartList', {
295
295
  :user => 'test',
296
296
  :limit => nil,
297
297
  }).and_return(make_response('user_get_weekly_chart_list'))
298
298
  weekly_charts = @lastfm.user.get_weekly_chart_list(:user => 'test')
299
- weekly_charts[0]['from'].should == "1108296002"
300
- weekly_charts[0]['to'].should == "1108900802"
301
- weekly_charts[1]['from'].should == "1108900801"
302
- weekly_charts.size.should == 8
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)
303
303
  end
304
304
  end
305
305
 
306
306
  describe '#get_weekly_artist_chart' do
307
307
  it 'should get user\'s weekly artist chart' do
308
- @lastfm.should_receive(:request).with('user.getWeeklyArtistChart', {
308
+ expect(@lastfm).to receive(:request).with('user.getWeeklyArtistChart', {
309
309
  :user => 'test',
310
310
  :limit => nil,
311
311
  :to => nil,
312
312
  :from => nil
313
313
  }).and_return(make_response('user_get_weekly_artist_chart'))
314
314
  weekly_artists = @lastfm.user.get_weekly_artist_chart(:user => 'test')
315
- weekly_artists[0]['name'].should == "Leonard Cohen"
316
- weekly_artists[0]['playcount'].should == "46"
317
- weekly_artists[1]['playcount'].should == "44"
318
- weekly_artists.size.should == 4
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)
319
319
  end
320
320
  end
321
321
 
322
322
  describe '#get_weekly_album_chart' do
323
323
  it 'should get user\'s weekly album chart' do
324
- @lastfm.should_receive(:request).with('user.getWeeklyAlbumChart', {
324
+ expect(@lastfm).to receive(:request).with('user.getWeeklyAlbumChart', {
325
325
  :user => 'test',
326
326
  :limit => nil,
327
327
  :to => nil,
328
328
  :from => nil
329
329
  }).and_return(make_response('user_get_weekly_album_chart'))
330
330
  weekly_albums = @lastfm.user.get_weekly_album_chart(:user => 'test')
331
- weekly_albums[0]['artist']['content'].should == "Leonard Cohen"
332
- weekly_albums[0]['playcount'].should == "25"
333
- weekly_albums[1]['playcount'].should == "18"
334
- weekly_albums.size.should == 3
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)
335
335
  end
336
336
  end
337
337
 
338
338
  describe '#get_weekly_track_chart' do
339
339
  it 'should get user\'s weekly track chart' do
340
- @lastfm.should_receive(:request).with('user.getWeeklyTrackChart', {
340
+ expect(@lastfm).to receive(:request).with('user.getWeeklyTrackChart', {
341
341
  :user => 'test',
342
342
  :limit => nil,
343
343
  :to => nil,
344
344
  :from => nil
345
345
  }).and_return(make_response('user_get_weekly_track_chart'))
346
346
  weekly_tracks = @lastfm.user.get_weekly_track_chart(:user => 'test')
347
- weekly_tracks[0]['artist']['content'].should == "Tori Amos"
348
- weekly_tracks[0]['playcount'].should == "2"
349
- weekly_tracks[1]['playcount'].should == "2"
350
- weekly_tracks.size.should == 3
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)
351
351
  end
352
352
  end
353
353
 
354
354
  describe '#get_recommended_events' do
355
355
  it 'should get a user\'s list of recommended events' do
356
- @lastfm.should_receive(:request).with('user.getRecommendedEvents', {}, :get, true, true) {
356
+ expect(@lastfm).to receive(:request).with('user.getRecommendedEvents', {}, :get, true, true) {
357
357
  make_response('user_get_recommended_events') }
358
358
 
359
359
  recommended_events = @lastfm.user.get_recommended_events
360
- recommended_events[0]['artists']['headliner'].should == 'Toro y Moi'
361
- recommended_events[1]['artists']['headliner'].should == 'Reel Big Fish'
360
+ expect(recommended_events[0]['artists']['headliner']).to eq('Toro y Moi')
361
+ expect(recommended_events[1]['artists']['headliner']).to eq('Reel Big Fish')
362
362
  end
363
363
  end
364
364
 
365
365
  describe '#get_recommended_artists' do
366
366
  it 'shoud get user\'s recommended artists' do
367
- @lastfm.should_receive(:request).with('user.getRecommendedArtists', {}, :get, true, true) {
367
+ expect(@lastfm).to receive(:request).with('user.getRecommendedArtists', {}, :get, true, true) {
368
368
  make_response('user_get_recommended_artists') }
369
369
 
370
370
  recommended_artists = @lastfm.user.get_recommended_artists
371
- recommended_artists[0]['name'].should == 'Quest.Room.Project'
372
- recommended_artists[1]['name'].should == 'Senior Soul'
371
+ expect(recommended_artists[0]['name']).to eq('Quest.Room.Project')
372
+ expect(recommended_artists[1]['name']).to eq('Senior Soul')
373
373
  end
374
374
  end
375
375
  end
@@ -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).should be_an_instance_of(Lastfm::Response)
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.should be_success
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.should == 7
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.should_not be_success
36
+ expect(@response).not_to be_success
37
37
  end
38
38
 
39
39
  it 'should have message' do
40
- @response.message.should == 'Invalid API key - You must be granted a valid key by last.fm'
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.should == 10
44
+ expect(@response.error).to eq(10)
45
45
  end
46
46
  end
47
47
  end