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,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,49 +103,50 @@ 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
|
+
:limit => nil
|
118
119
|
}).and_return(make_response('track_get_similar'))
|
119
120
|
|
120
121
|
tracks = @lastfm.track.get_similar(
|
121
122
|
:artist => 'Cher',
|
122
123
|
:track => 'Believe')
|
123
|
-
tracks.size.
|
124
|
-
tracks.first['name'].
|
125
|
-
tracks.first['image'][1]['content'].
|
126
|
-
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')
|
127
128
|
end
|
128
129
|
end
|
129
130
|
|
130
131
|
describe '#get_tags' do
|
131
132
|
it 'should get tags' do
|
132
|
-
@lastfm.
|
133
|
+
expect(@lastfm).to receive(:request).with('track.getTags', {
|
133
134
|
:artist => 'foo artist',
|
134
135
|
:track => 'foo track',
|
135
|
-
}
|
136
|
+
}).and_return(make_response('track_get_tags'))
|
136
137
|
|
137
138
|
tags = @lastfm.track.get_tags(
|
138
139
|
:artist => 'foo artist',
|
139
140
|
:track => 'foo track')
|
140
|
-
tags.size.
|
141
|
-
tags[0]['name'].
|
142
|
-
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')
|
143
144
|
end
|
144
145
|
end
|
145
146
|
|
146
147
|
describe '#get_top_fans' do
|
147
148
|
it 'should get top fans' do
|
148
|
-
@lastfm.
|
149
|
+
expect(@lastfm).to receive(:request).with('track.getTopFans', {
|
149
150
|
:artist => 'foo artist',
|
150
151
|
:track => 'foo track',
|
151
152
|
}).and_return(make_response('track_get_top_fans'))
|
@@ -153,14 +154,14 @@ describe '#track' do
|
|
153
154
|
users = @lastfm.track.get_top_fans(
|
154
155
|
:artist => 'foo artist',
|
155
156
|
:track => 'foo track')
|
156
|
-
users.size.
|
157
|
-
users[0]['name'].
|
157
|
+
expect(users.size).to eq(2)
|
158
|
+
expect(users[0]['name']).to eq('Through0glass')
|
158
159
|
end
|
159
160
|
end
|
160
161
|
|
161
162
|
describe '#get_top_tags' do
|
162
163
|
it 'should get top tags' do
|
163
|
-
@lastfm.
|
164
|
+
expect(@lastfm).to receive(:request).with('track.getTopTags', {
|
164
165
|
:artist => 'foo artist',
|
165
166
|
:track => 'foo track',
|
166
167
|
}).and_return(make_response('track_get_top_tags'))
|
@@ -168,44 +169,44 @@ describe '#track' do
|
|
168
169
|
tags = @lastfm.track.get_top_tags(
|
169
170
|
:artist => 'foo artist',
|
170
171
|
:track => 'foo track')
|
171
|
-
tags.size.
|
172
|
-
tags[0]['name'].
|
173
|
-
tags[0]['count'].
|
174
|
-
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')
|
175
176
|
end
|
176
177
|
end
|
177
178
|
|
178
179
|
describe '#love' do
|
179
180
|
it 'should love' do
|
180
|
-
@lastfm.
|
181
|
+
expect(@lastfm).to receive(:request).with('track.love', {
|
181
182
|
:artist => 'foo artist',
|
182
183
|
:track => 'foo track',
|
183
184
|
}, :post, true, true).and_return(@ok_response)
|
184
185
|
|
185
|
-
@lastfm.track.love(
|
186
|
+
expect(@lastfm.track.love(
|
186
187
|
:artist => 'foo artist',
|
187
|
-
:track => 'foo track').
|
188
|
+
:track => 'foo track')).to be_truthy
|
188
189
|
end
|
189
190
|
end
|
190
191
|
|
191
192
|
describe '#remove_tag' do
|
192
193
|
it 'should remove tag' do
|
193
|
-
@lastfm.
|
194
|
+
expect(@lastfm).to receive(:request).with('track.removeTag', {
|
194
195
|
:artist => 'foo artist',
|
195
196
|
:track => 'foo track',
|
196
197
|
:tag => 'aaa'
|
197
198
|
}, :post, true, true).and_return(@ok_response)
|
198
199
|
|
199
|
-
@lastfm.track.remove_tag(
|
200
|
+
expect(@lastfm.track.remove_tag(
|
200
201
|
:artist => 'foo artist',
|
201
202
|
:track => 'foo track',
|
202
|
-
:tag => 'aaa').
|
203
|
+
:tag => 'aaa')).to be_truthy
|
203
204
|
end
|
204
205
|
end
|
205
206
|
|
206
207
|
describe '#search' do
|
207
208
|
it 'should search' do
|
208
|
-
@lastfm.
|
209
|
+
expect(@lastfm).to receive(:request).with('track.search', {
|
209
210
|
:artist => nil,
|
210
211
|
:track => 'Believe',
|
211
212
|
:limit => 10,
|
@@ -216,14 +217,14 @@ describe '#track' do
|
|
216
217
|
:track => 'Believe',
|
217
218
|
:limit => 10,
|
218
219
|
:page => 3)
|
219
|
-
tracks['results']['for'].
|
220
|
-
tracks['results']['totalResults'].
|
221
|
-
tracks['results']['trackmatches']['track'].size.
|
222
|
-
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')
|
223
224
|
end
|
224
225
|
|
225
226
|
it 'should always return an arrays of tracks' do
|
226
|
-
@lastfm.
|
227
|
+
expect(@lastfm).to receive(:request).with('track.search', {
|
227
228
|
:artist => nil,
|
228
229
|
:track => 'Believe',
|
229
230
|
:limit => 10,
|
@@ -234,34 +235,51 @@ describe '#track' do
|
|
234
235
|
:track => 'Believe',
|
235
236
|
:limit => 10,
|
236
237
|
:page => 3)
|
237
|
-
tracks['results']['for'].
|
238
|
-
tracks['results']['totalResults'].
|
239
|
-
tracks['results']['trackmatches']['track'].size.
|
240
|
-
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
|
+
end
|
243
|
+
|
244
|
+
it 'should return an empty array if no match found' do
|
245
|
+
expect(@lastfm).to receive(:request).with('track.search', {
|
246
|
+
:artist => nil,
|
247
|
+
:track => 'Believe',
|
248
|
+
:limit => 10,
|
249
|
+
:page => 1,
|
250
|
+
}).and_return(make_response('track_search_no_match'))
|
251
|
+
|
252
|
+
tracks = @lastfm.track.search(
|
253
|
+
:track => 'Believe',
|
254
|
+
:limit => 10,
|
255
|
+
:page => 1)
|
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)
|
241
259
|
end
|
242
260
|
end
|
243
261
|
|
244
262
|
describe '#share' do
|
245
263
|
it 'should share' do
|
246
|
-
@lastfm.
|
264
|
+
expect(@lastfm).to receive(:request).with('track.share', {
|
247
265
|
:artist => 'foo artist',
|
248
266
|
:track => 'foo track',
|
249
267
|
:message => 'this is a message',
|
250
268
|
:recipient => 'foo@example.com',
|
251
269
|
}, :post, true, true).and_return(@ok_response)
|
252
270
|
|
253
|
-
@lastfm.track.share(
|
271
|
+
expect(@lastfm.track.share(
|
254
272
|
:artist => 'foo artist',
|
255
273
|
:track => 'foo track',
|
256
274
|
:recipient => 'foo@example.com',
|
257
|
-
:message => 'this is a message').
|
275
|
+
:message => 'this is a message')).to be_truthy
|
258
276
|
end
|
259
277
|
end
|
260
278
|
|
261
279
|
describe '#scrobble' do
|
262
280
|
it 'should scrobble' do
|
263
281
|
time = Time.now
|
264
|
-
@lastfm.
|
282
|
+
expect(@lastfm).to receive(:request).with('track.scrobble', {
|
265
283
|
:artist => 'foo artist',
|
266
284
|
:track => 'foo track',
|
267
285
|
:album => 'foo album',
|
@@ -284,7 +302,7 @@ describe '#track' do
|
|
284
302
|
|
285
303
|
describe '#update_now_playing' do
|
286
304
|
it 'should update now playing' do
|
287
|
-
@lastfm.
|
305
|
+
expect(@lastfm).to receive(:request).with('track.updateNowPlaying', {
|
288
306
|
:artist => 'foo artist',
|
289
307
|
:track => 'foo track',
|
290
308
|
:album => 'foo album',
|
@@ -305,14 +323,14 @@ describe '#track' do
|
|
305
323
|
|
306
324
|
describe '#unlove' do
|
307
325
|
it 'should unlove' do
|
308
|
-
@lastfm.
|
326
|
+
expect(@lastfm).to receive(:request).with('track.unlove', {
|
309
327
|
:artist => 'foo artist',
|
310
328
|
:track => 'foo track',
|
311
329
|
}, :post, true, true).and_return(@ok_response)
|
312
330
|
|
313
|
-
@lastfm.track.unlove(
|
331
|
+
expect(@lastfm.track.unlove(
|
314
332
|
:artist => 'foo artist',
|
315
|
-
:track => 'foo track').
|
333
|
+
:track => 'foo track')).to be_truthy
|
316
334
|
end
|
317
335
|
end
|
318
336
|
end
|