lastfm 1.27.3 → 1.27.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.
- checksums.yaml +4 -4
- data/.rspec +2 -2
- data/lastfm.gemspec +3 -3
- data/spec/lastfm_spec.rb +34 -34
- data/spec/method_category_spec.rb +1 -1
- data/spec/method_specs/album_spec.rb +92 -92
- data/spec/method_specs/artist_spec.rb +73 -73
- 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 +76 -76
- data/spec/method_specs/user_spec.rb +101 -101
- data/spec/response_spec.rb +6 -6
- data/spec/util_spec.rb +16 -16
- metadata +7 -7
@@ -4,12 +4,12 @@ describe '#radio' do
|
|
4
4
|
before { init_lastfm }
|
5
5
|
|
6
6
|
it 'should return an instance of Lastfm::Radio' do
|
7
|
-
@lastfm.radio.
|
7
|
+
expect(@lastfm.radio).to be_an_instance_of(Lastfm::MethodCategory::Radio)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '#tune' do
|
11
11
|
it 'should tune' do
|
12
|
-
@lastfm.
|
12
|
+
expect(@lastfm).to receive(:request).with('radio.tune', {
|
13
13
|
:station => 'lastfm://globaltags/pop',
|
14
14
|
}, :post, true, true).and_return(@ok_response)
|
15
15
|
@lastfm.radio.tune("lastfm://globaltags/pop")
|
@@ -18,20 +18,20 @@ describe '#radio' do
|
|
18
18
|
|
19
19
|
describe '#get_playlist' do
|
20
20
|
it 'should return some playlist' do
|
21
|
-
@lastfm.
|
21
|
+
expect(@lastfm).to receive(:request).with("radio.getPlaylist", {}, :get, true, true).and_return(make_response('radio_get_playlist'))
|
22
22
|
playlist = @lastfm.radio.get_playlist
|
23
23
|
tracklist = playlist["trackList"]["track"]
|
24
|
-
tracklist.
|
25
|
-
tracklist[0]['title'].
|
26
|
-
tracklist[1]['location'].
|
27
|
-
tracklist[2]['creator'].
|
28
|
-
tracklist[3]['album'].
|
24
|
+
expect(tracklist).to be_an_instance_of(Array)
|
25
|
+
expect(tracklist[0]['title']).to eq("All The Things She Said")
|
26
|
+
expect(tracklist[1]['location']).to eq("http://play.last.fm/user/bca46e434c3389217ef1b8d20db1690c.mp3")
|
27
|
+
expect(tracklist[2]['creator']).to eq("Culture Club")
|
28
|
+
expect(tracklist[3]['album']).to eq("The E.N.D.")
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should always return playlists with arrays of tracks' do
|
32
|
-
@lastfm.
|
32
|
+
expect(@lastfm).to receive(:request).with("radio.getPlaylist", {}, :get, true, true).and_return(make_response('radio_get_playlist_single_track'))
|
33
33
|
playlist = @lastfm.radio.get_playlist
|
34
|
-
playlist["trackList"]["track"].
|
34
|
+
expect(playlist["trackList"]["track"]).to be_an_instance_of(Array)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -4,86 +4,86 @@ describe '#tag' do
|
|
4
4
|
before { init_lastfm }
|
5
5
|
|
6
6
|
it 'should return an instance of Lastfm::Tag' do
|
7
|
-
@lastfm.tag.
|
7
|
+
expect(@lastfm.tag).to be_an_instance_of(Lastfm::MethodCategory::Tag)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '#get_top_artists' do
|
11
11
|
it 'should get top artists of some tag' do
|
12
|
-
@lastfm.
|
12
|
+
expect(@lastfm).to receive(:request).with('tag.getTopArtists', {
|
13
13
|
:tag => 'Disco',
|
14
14
|
:limit => nil,
|
15
15
|
:page => nil
|
16
16
|
}).and_return(make_response('tag_get_top_artists'))
|
17
17
|
|
18
18
|
artists = @lastfm.tag.get_top_artists(:tag => 'Disco')
|
19
|
-
artists.size.
|
20
|
-
artists[0]['name'].
|
21
|
-
artists[0]['url'].
|
22
|
-
artists[1]['name'].
|
19
|
+
expect(artists.size).to eq(5)
|
20
|
+
expect(artists[0]['name']).to eq('Bee Gees')
|
21
|
+
expect(artists[0]['url']).to eq('http://www.last.fm/music/Bee+Gees')
|
22
|
+
expect(artists[1]['name']).to eq('ABBA')
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe '#get_top_tracks' do
|
27
27
|
it 'should get top tracks of a given tag' do
|
28
|
-
@lastfm.
|
28
|
+
expect(@lastfm).to receive(:request).with('tag.getTopTracks', {
|
29
29
|
:tag => 'Disco',
|
30
30
|
:limit => 5,
|
31
31
|
:page => nil
|
32
32
|
}).and_return(make_response('tag_get_top_tracks'))
|
33
33
|
|
34
34
|
tracks = @lastfm.tag.get_top_tracks(:tag => 'Disco', :limit => 5)
|
35
|
-
tracks.size.
|
36
|
-
tracks[0]['name'].
|
37
|
-
tracks[0]['url'].
|
38
|
-
tracks[0]['artist']['name'].
|
39
|
-
tracks[1]['name'].
|
35
|
+
expect(tracks.size).to eq(5)
|
36
|
+
expect(tracks[0]['name']).to eq('Stayin\' Alive')
|
37
|
+
expect(tracks[0]['url']).to eq('http://www.last.fm/music/Bee+Gees/_/Stayin%27+Alive')
|
38
|
+
expect(tracks[0]['artist']['name']).to eq('Bee Gees')
|
39
|
+
expect(tracks[1]['name']).to eq('September')
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#get_top_albums' do
|
44
44
|
it 'should get top albums of a given tag' do
|
45
|
-
@lastfm.
|
45
|
+
expect(@lastfm).to receive(:request).with('tag.getTopAlbums', {
|
46
46
|
:tag => 'Disco',
|
47
47
|
:limit => 5,
|
48
48
|
:page => nil
|
49
49
|
}).and_return(make_response('tag_get_top_albums'))
|
50
50
|
|
51
51
|
albums = @lastfm.tag.get_top_albums(:tag => 'Disco', :limit => 5)
|
52
|
-
albums.size.
|
53
|
-
albums[0]['name'].
|
54
|
-
albums[0]['url'].
|
55
|
-
albums[0]['artist']['name'].
|
56
|
-
albums[1]['name'].
|
52
|
+
expect(albums.size).to eq(5)
|
53
|
+
expect(albums[0]['name']).to eq('Number Ones')
|
54
|
+
expect(albums[0]['url']).to eq('http://www.last.fm/music/Bee+Gees/Number+Ones')
|
55
|
+
expect(albums[0]['artist']['name']).to eq('Bee Gees')
|
56
|
+
expect(albums[1]['name']).to eq('Gold: Greatest Hits')
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe '#search' do
|
61
61
|
it 'should get all tags related to a given one' do
|
62
|
-
@lastfm.
|
62
|
+
expect(@lastfm).to receive(:request).with('tag.search', {
|
63
63
|
:tag => 'Disco',
|
64
64
|
:limit => 5,
|
65
65
|
:page => nil
|
66
66
|
}).and_return(make_response('tag_search'))
|
67
67
|
|
68
68
|
tags = @lastfm.tag.search(:tag => 'Disco', :limit => 5)
|
69
|
-
tags.size.
|
70
|
-
tags[0]['name'].
|
71
|
-
tags[0]['count'].
|
72
|
-
tags[0]['url'].
|
73
|
-
tags[1]['name'].
|
69
|
+
expect(tags.size).to eq(5)
|
70
|
+
expect(tags[0]['name']).to eq('disco')
|
71
|
+
expect(tags[0]['count']).to eq('157207')
|
72
|
+
expect(tags[0]['url']).to eq('www.last.fm/tag/disco')
|
73
|
+
expect(tags[1]['name']).to eq('italo disco')
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
describe '#get_info' do
|
78
78
|
it 'should get detailed info of a given tag' do
|
79
|
-
@lastfm.
|
79
|
+
expect(@lastfm).to receive(:request).with('tag.getInfo', {
|
80
80
|
:tag => 'Disco'
|
81
81
|
}).and_return(make_response('tag_get_info'))
|
82
82
|
|
83
83
|
tags = @lastfm.tag.get_info(:tag => 'Disco')
|
84
|
-
tags[0]['name'].
|
85
|
-
tags[0]['reach'].
|
86
|
-
tags[0]['url'].
|
84
|
+
expect(tags[0]['name']).to eq('disco')
|
85
|
+
expect(tags[0]['reach']).to eq('33745')
|
86
|
+
expect(tags[0]['url']).to eq('http://www.last.fm/tag/disco')
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -4,12 +4,12 @@ describe '#tasteometer' do
|
|
4
4
|
before { init_lastfm }
|
5
5
|
|
6
6
|
it 'should return an instance of Lastfm::Tasteometer' do
|
7
|
-
@lastfm.tasteometer.
|
7
|
+
expect(@lastfm.tasteometer).to be_an_instance_of(Lastfm::MethodCategory::Tasteometer)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '#compare' do
|
11
11
|
it 'should compare users' do
|
12
|
-
@lastfm.
|
12
|
+
expect(@lastfm).to receive(:request).with('tasteometer.compare', {
|
13
13
|
:type1 => 'user',
|
14
14
|
:type2 => 'user',
|
15
15
|
:value1 => 'foo',
|
@@ -17,8 +17,8 @@ describe '#tasteometer' do
|
|
17
17
|
:limit => nil
|
18
18
|
}).and_return(make_response('tasteometer_compare'))
|
19
19
|
compare = @lastfm.tasteometer.compare(:type1 => 'user', :type2 => 'user', :value1 =>'foo', :value2 => 'bar')
|
20
|
-
compare['score'].
|
21
|
-
compare['artists']['artist'][1]['name'].
|
20
|
+
expect(compare['score']).to eq('0.74')
|
21
|
+
expect(compare['artists']['artist'][1]['name']).to eq('The Beatles')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -4,39 +4,39 @@ describe '#track' do
|
|
4
4
|
before { init_lastfm }
|
5
5
|
|
6
6
|
it 'should return an instance of Lastfm::Track' do
|
7
|
-
@lastfm.track.
|
7
|
+
expect(@lastfm.track).to be_an_instance_of(Lastfm::MethodCategory::Track)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '#add_tags' do
|
11
11
|
it 'should add tags' do
|
12
|
-
@lastfm.
|
12
|
+
expect(@lastfm).to receive(:request).with('track.addTags', {
|
13
13
|
:artist => 'foo artist',
|
14
14
|
:track => 'foo track',
|
15
15
|
:tags => 'aaa,bbb,ccc'
|
16
16
|
}, :post, true, true).and_return(@ok_response)
|
17
17
|
|
18
|
-
@lastfm.track.add_tags(
|
18
|
+
expect(@lastfm.track.add_tags(
|
19
19
|
:artist => 'foo artist',
|
20
20
|
:track => 'foo track',
|
21
21
|
:tags => 'aaa,bbb,ccc'
|
22
|
-
).
|
22
|
+
)).to be_truthy
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe '#ban' do
|
27
27
|
it 'should ban' do
|
28
|
-
@lastfm.
|
28
|
+
expect(@lastfm).to receive(:request).with('track.ban', {
|
29
29
|
:artist => 'foo artist',
|
30
30
|
:track => 'foo track',
|
31
31
|
}, :post, true, true).and_return(@ok_response)
|
32
32
|
|
33
|
-
@lastfm.track.ban(:artist => 'foo artist', :track => 'foo track').
|
33
|
+
expect(@lastfm.track.ban(:artist => 'foo artist', :track => 'foo track')).to be_truthy
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe '#get_info' do
|
38
38
|
it 'should get info by track and artist' do
|
39
|
-
@lastfm.
|
39
|
+
expect(@lastfm).to receive(:request).with('track.getInfo', {
|
40
40
|
:artist => 'Cher',
|
41
41
|
:track => 'Believe',
|
42
42
|
:username => 'youpy',
|
@@ -46,16 +46,16 @@ describe '#track' do
|
|
46
46
|
:artist => 'Cher',
|
47
47
|
:track => 'Believe',
|
48
48
|
:username => 'youpy')
|
49
|
-
track['name'].
|
50
|
-
track['album']['image'].size.
|
51
|
-
track['album']['image'].first['size'].
|
52
|
-
track['album']['image'].first['content'].
|
53
|
-
track['toptags']['tag'].size.
|
54
|
-
track['toptags']['tag'].first['name'].
|
49
|
+
expect(track['name']).to eq('Believe')
|
50
|
+
expect(track['album']['image'].size).to eq(4)
|
51
|
+
expect(track['album']['image'].first['size']).to eq('small')
|
52
|
+
expect(track['album']['image'].first['content']).to eq('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
|
53
|
+
expect(track['toptags']['tag'].size).to eq(5)
|
54
|
+
expect(track['toptags']['tag'].first['name']).to eq('pop')
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should get info by mbid' do
|
58
|
-
@lastfm.
|
58
|
+
expect(@lastfm).to receive(:request).with('track.getInfo', {
|
59
59
|
:mbid => 'xxx',
|
60
60
|
:username => nil
|
61
61
|
}
|
@@ -64,16 +64,16 @@ describe '#track' do
|
|
64
64
|
track = @lastfm.track.get_info(
|
65
65
|
:mbid => 'xxx'
|
66
66
|
)
|
67
|
-
track['name'].
|
68
|
-
track['album']['image'].size.
|
69
|
-
track['album']['image'].first['size'].
|
70
|
-
track['album']['image'].first['content'].
|
71
|
-
track['toptags']['tag'].size.
|
72
|
-
track['toptags']['tag'].first['name'].
|
67
|
+
expect(track['name']).to eq('Believe')
|
68
|
+
expect(track['album']['image'].size).to eq(4)
|
69
|
+
expect(track['album']['image'].first['size']).to eq('small')
|
70
|
+
expect(track['album']['image'].first['content']).to eq('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
|
71
|
+
expect(track['toptags']['tag'].size).to eq(5)
|
72
|
+
expect(track['toptags']['tag'].first['name']).to eq('pop')
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'should get xml with force array option' do
|
76
|
-
@lastfm.
|
76
|
+
expect(@lastfm).to receive(:request).with('track.getInfo', {
|
77
77
|
:artist => 'Cher',
|
78
78
|
:track => 'Believe',
|
79
79
|
:username => 'youpy',
|
@@ -83,17 +83,17 @@ describe '#track' do
|
|
83
83
|
:artist => 'Cher',
|
84
84
|
:track => 'Believe',
|
85
85
|
:username => 'youpy')
|
86
|
-
track['album']['image'].size.
|
87
|
-
track['album']['image'].first['size'].
|
88
|
-
track['album']['image'].first['content'].
|
89
|
-
track['toptags']['tag'].size.
|
90
|
-
track['toptags']['tag'].first['name'].
|
86
|
+
expect(track['album']['image'].size).to eq(1)
|
87
|
+
expect(track['album']['image'].first['size']).to eq('small')
|
88
|
+
expect(track['album']['image'].first['content']).to eq('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
|
89
|
+
expect(track['toptags']['tag'].size).to eq(1)
|
90
|
+
expect(track['toptags']['tag'].first['name']).to eq('pop')
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
describe '#get_correction' do
|
95
95
|
it 'should get correction' do
|
96
|
-
@lastfm.
|
96
|
+
expect(@lastfm).to receive(:request).with('track.getCorrection', {
|
97
97
|
:artist => 'White Stripes',
|
98
98
|
:track => 'One More Cup of Coffee'
|
99
99
|
}).and_return(make_response('track_get_correction'))
|
@@ -103,16 +103,16 @@ describe '#track' do
|
|
103
103
|
:track => 'One More Cup of Coffee')
|
104
104
|
correction = corrections.first
|
105
105
|
|
106
|
-
corrections.size.
|
107
|
-
correction['track']['name'].
|
108
|
-
correction['track']['artist']['name'].
|
109
|
-
correction['track']['url'].
|
106
|
+
expect(corrections.size).to eql(1)
|
107
|
+
expect(correction['track']['name']).to eq('One More Cup of Coffee')
|
108
|
+
expect(correction['track']['artist']['name']).to eq('The White Stripes')
|
109
|
+
expect(correction['track']['url']).to eq('www.last.fm/music/The+White+Stripes/_/One+More+Cup+of+Coffee')
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
describe '#get_similar' do
|
114
114
|
it 'should get similar' do
|
115
|
-
@lastfm.
|
115
|
+
expect(@lastfm).to receive(:request).with('track.getSimilar', {
|
116
116
|
:artist => 'Cher',
|
117
117
|
:track => 'Believe',
|
118
118
|
:limit => nil
|
@@ -121,16 +121,16 @@ describe '#track' do
|
|
121
121
|
tracks = @lastfm.track.get_similar(
|
122
122
|
:artist => 'Cher',
|
123
123
|
:track => 'Believe')
|
124
|
-
tracks.size.
|
125
|
-
tracks.first['name'].
|
126
|
-
tracks.first['image'][1]['content'].
|
127
|
-
tracks[1]['image'][0]['content'].
|
124
|
+
expect(tracks.size).to eq(5)
|
125
|
+
expect(tracks.first['name']).to eq('Strong Enough')
|
126
|
+
expect(tracks.first['image'][1]['content']).to eq('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
|
127
|
+
expect(tracks[1]['image'][0]['content']).to eq('http://userserve-ak.last.fm/serve/34s/8674593.jpg')
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
131
|
describe '#get_tags' do
|
132
132
|
it 'should get tags' do
|
133
|
-
@lastfm.
|
133
|
+
expect(@lastfm).to receive(:request).with('track.getTags', {
|
134
134
|
:artist => 'foo artist',
|
135
135
|
:track => 'foo track',
|
136
136
|
}).and_return(make_response('track_get_tags'))
|
@@ -138,15 +138,15 @@ describe '#track' do
|
|
138
138
|
tags = @lastfm.track.get_tags(
|
139
139
|
:artist => 'foo artist',
|
140
140
|
:track => 'foo track')
|
141
|
-
tags.size.
|
142
|
-
tags[0]['name'].
|
143
|
-
tags[0]['url'].
|
141
|
+
expect(tags.size).to eq(2)
|
142
|
+
expect(tags[0]['name']).to eq('swedish')
|
143
|
+
expect(tags[0]['url']).to eq('http://www.last.fm/tag/swedish')
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
147
|
describe '#get_top_fans' do
|
148
148
|
it 'should get top fans' do
|
149
|
-
@lastfm.
|
149
|
+
expect(@lastfm).to receive(:request).with('track.getTopFans', {
|
150
150
|
:artist => 'foo artist',
|
151
151
|
:track => 'foo track',
|
152
152
|
}).and_return(make_response('track_get_top_fans'))
|
@@ -154,14 +154,14 @@ describe '#track' do
|
|
154
154
|
users = @lastfm.track.get_top_fans(
|
155
155
|
:artist => 'foo artist',
|
156
156
|
:track => 'foo track')
|
157
|
-
users.size.
|
158
|
-
users[0]['name'].
|
157
|
+
expect(users.size).to eq(2)
|
158
|
+
expect(users[0]['name']).to eq('Through0glass')
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
162
|
describe '#get_top_tags' do
|
163
163
|
it 'should get top tags' do
|
164
|
-
@lastfm.
|
164
|
+
expect(@lastfm).to receive(:request).with('track.getTopTags', {
|
165
165
|
:artist => 'foo artist',
|
166
166
|
:track => 'foo track',
|
167
167
|
}).and_return(make_response('track_get_top_tags'))
|
@@ -169,44 +169,44 @@ describe '#track' do
|
|
169
169
|
tags = @lastfm.track.get_top_tags(
|
170
170
|
:artist => 'foo artist',
|
171
171
|
:track => 'foo track')
|
172
|
-
tags.size.
|
173
|
-
tags[0]['name'].
|
174
|
-
tags[0]['count'].
|
175
|
-
tags[0]['url'].
|
172
|
+
expect(tags.size).to eq(2)
|
173
|
+
expect(tags[0]['name']).to eq('alternative')
|
174
|
+
expect(tags[0]['count']).to eq('100')
|
175
|
+
expect(tags[0]['url']).to eq('www.last.fm/tag/alternative')
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
179
|
describe '#love' do
|
180
180
|
it 'should love' do
|
181
|
-
@lastfm.
|
181
|
+
expect(@lastfm).to receive(:request).with('track.love', {
|
182
182
|
:artist => 'foo artist',
|
183
183
|
:track => 'foo track',
|
184
184
|
}, :post, true, true).and_return(@ok_response)
|
185
185
|
|
186
|
-
@lastfm.track.love(
|
186
|
+
expect(@lastfm.track.love(
|
187
187
|
:artist => 'foo artist',
|
188
|
-
:track => 'foo track').
|
188
|
+
:track => 'foo track')).to be_truthy
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
192
|
describe '#remove_tag' do
|
193
193
|
it 'should remove tag' do
|
194
|
-
@lastfm.
|
194
|
+
expect(@lastfm).to receive(:request).with('track.removeTag', {
|
195
195
|
:artist => 'foo artist',
|
196
196
|
:track => 'foo track',
|
197
197
|
:tag => 'aaa'
|
198
198
|
}, :post, true, true).and_return(@ok_response)
|
199
199
|
|
200
|
-
@lastfm.track.remove_tag(
|
200
|
+
expect(@lastfm.track.remove_tag(
|
201
201
|
:artist => 'foo artist',
|
202
202
|
:track => 'foo track',
|
203
|
-
:tag => 'aaa').
|
203
|
+
:tag => 'aaa')).to be_truthy
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
207
|
describe '#search' do
|
208
208
|
it 'should search' do
|
209
|
-
@lastfm.
|
209
|
+
expect(@lastfm).to receive(:request).with('track.search', {
|
210
210
|
:artist => nil,
|
211
211
|
:track => 'Believe',
|
212
212
|
:limit => 10,
|
@@ -217,14 +217,14 @@ describe '#track' do
|
|
217
217
|
:track => 'Believe',
|
218
218
|
:limit => 10,
|
219
219
|
:page => 3)
|
220
|
-
tracks['results']['for'].
|
221
|
-
tracks['results']['totalResults'].
|
222
|
-
tracks['results']['trackmatches']['track'].size.
|
223
|
-
tracks['results']['trackmatches']['track'][0]['name'].
|
220
|
+
expect(tracks['results']['for']).to eq('Believe')
|
221
|
+
expect(tracks['results']['totalResults']).to eq('40540')
|
222
|
+
expect(tracks['results']['trackmatches']['track'].size).to eq(2)
|
223
|
+
expect(tracks['results']['trackmatches']['track'][0]['name']).to eq('Make Me Believe')
|
224
224
|
end
|
225
225
|
|
226
226
|
it 'should always return an arrays of tracks' do
|
227
|
-
@lastfm.
|
227
|
+
expect(@lastfm).to receive(:request).with('track.search', {
|
228
228
|
:artist => nil,
|
229
229
|
:track => 'Believe',
|
230
230
|
:limit => 10,
|
@@ -235,14 +235,14 @@ describe '#track' do
|
|
235
235
|
:track => 'Believe',
|
236
236
|
:limit => 10,
|
237
237
|
:page => 3)
|
238
|
-
tracks['results']['for'].
|
239
|
-
tracks['results']['totalResults'].
|
240
|
-
tracks['results']['trackmatches']['track'].size.
|
241
|
-
tracks['results']['trackmatches']['track'][0]['name'].
|
238
|
+
expect(tracks['results']['for']).to eq('Believe')
|
239
|
+
expect(tracks['results']['totalResults']).to eq('40540')
|
240
|
+
expect(tracks['results']['trackmatches']['track'].size).to eq(1)
|
241
|
+
expect(tracks['results']['trackmatches']['track'][0]['name']).to eq('Make Me Believe')
|
242
242
|
end
|
243
243
|
|
244
244
|
it 'should return an empty array if no match found' do
|
245
|
-
@lastfm.
|
245
|
+
expect(@lastfm).to receive(:request).with('track.search', {
|
246
246
|
:artist => nil,
|
247
247
|
:track => 'Believe',
|
248
248
|
:limit => 10,
|
@@ -253,33 +253,33 @@ describe '#track' do
|
|
253
253
|
:track => 'Believe',
|
254
254
|
:limit => 10,
|
255
255
|
:page => 1)
|
256
|
-
tracks['results']['for'].
|
257
|
-
tracks['results']['totalResults'].
|
258
|
-
tracks['results']['trackmatches']['track'].size.
|
256
|
+
expect(tracks['results']['for']).to eq('Believe')
|
257
|
+
expect(tracks['results']['totalResults']).to eq('0')
|
258
|
+
expect(tracks['results']['trackmatches']['track'].size).to eq(0)
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
262
|
describe '#share' do
|
263
263
|
it 'should share' do
|
264
|
-
@lastfm.
|
264
|
+
expect(@lastfm).to receive(:request).with('track.share', {
|
265
265
|
:artist => 'foo artist',
|
266
266
|
:track => 'foo track',
|
267
267
|
:message => 'this is a message',
|
268
268
|
:recipient => 'foo@example.com',
|
269
269
|
}, :post, true, true).and_return(@ok_response)
|
270
270
|
|
271
|
-
@lastfm.track.share(
|
271
|
+
expect(@lastfm.track.share(
|
272
272
|
:artist => 'foo artist',
|
273
273
|
:track => 'foo track',
|
274
274
|
:recipient => 'foo@example.com',
|
275
|
-
:message => 'this is a message').
|
275
|
+
:message => 'this is a message')).to be_truthy
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
279
279
|
describe '#scrobble' do
|
280
280
|
it 'should scrobble' do
|
281
281
|
time = Time.now
|
282
|
-
@lastfm.
|
282
|
+
expect(@lastfm).to receive(:request).with('track.scrobble', {
|
283
283
|
:artist => 'foo artist',
|
284
284
|
:track => 'foo track',
|
285
285
|
:album => 'foo album',
|
@@ -302,7 +302,7 @@ describe '#track' do
|
|
302
302
|
|
303
303
|
describe '#update_now_playing' do
|
304
304
|
it 'should update now playing' do
|
305
|
-
@lastfm.
|
305
|
+
expect(@lastfm).to receive(:request).with('track.updateNowPlaying', {
|
306
306
|
:artist => 'foo artist',
|
307
307
|
:track => 'foo track',
|
308
308
|
:album => 'foo album',
|
@@ -323,14 +323,14 @@ describe '#track' do
|
|
323
323
|
|
324
324
|
describe '#unlove' do
|
325
325
|
it 'should unlove' do
|
326
|
-
@lastfm.
|
326
|
+
expect(@lastfm).to receive(:request).with('track.unlove', {
|
327
327
|
:artist => 'foo artist',
|
328
328
|
:track => 'foo track',
|
329
329
|
}, :post, true, true).and_return(@ok_response)
|
330
330
|
|
331
|
-
@lastfm.track.unlove(
|
331
|
+
expect(@lastfm.track.unlove(
|
332
332
|
:artist => 'foo artist',
|
333
|
-
:track => 'foo track').
|
333
|
+
:track => 'foo track')).to be_truthy
|
334
334
|
end
|
335
335
|
end
|
336
336
|
end
|