lastfm 0.0.1 → 0.1.0
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.
- data/.rspec +2 -0
- data/README.rdoc +4 -0
- data/Rakefile +7 -12
- data/VERSION +1 -1
- data/lastfm.gemspec +29 -9
- data/lib/lastfm.rb +10 -5
- data/lib/lastfm/method_category/artist.rb +9 -0
- data/lib/lastfm/method_category/auth.rb +8 -6
- data/lib/lastfm/method_category/base.rb +58 -0
- data/lib/lastfm/method_category/track.rb +25 -83
- data/lib/lastfm/response.rb +7 -17
- data/lib/lastfm/util.rb +18 -0
- data/spec/fixtures/artist_get_events.xml +57 -0
- data/spec/fixtures/ng.xml +3 -0
- data/spec/fixtures/ok.xml +128 -0
- data/spec/fixtures/track_get_info.xml +111 -0
- data/spec/fixtures/track_get_info_force_array.xml +89 -0
- data/spec/fixtures/track_get_similar.xml +5095 -0
- data/spec/fixtures/track_get_tags.xml +13 -0
- data/spec/fixtures/track_get_top_fans.xml +28 -0
- data/spec/fixtures/track_get_top_tags.xml +15 -0
- data/spec/fixtures/track_search.xml +35 -0
- data/spec/lastfm_spec.rb +137 -57
- data/spec/method_category_spec.rb +1 -1
- data/spec/response_spec.rb +13 -14
- data/spec/spec_helper.rb +12 -6
- metadata +63 -13
- data/lib/lastfm/method_category.rb +0 -26
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<lfm status="ok">
|
3
|
+
<tags artist="Sally Shapiro" track="I'll be by your side">
|
4
|
+
<tag>
|
5
|
+
<name>swedish</name>
|
6
|
+
<url>http://www.last.fm/tag/swedish</url>
|
7
|
+
</tag>
|
8
|
+
<tag>
|
9
|
+
<name>xxx</name>
|
10
|
+
<url>http://www.last.fm/tag/xxx</url>
|
11
|
+
</tag>
|
12
|
+
</tags>
|
13
|
+
</lfm>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<lfm status="ok">
|
3
|
+
<topfans artist="Cher" track="Believe">
|
4
|
+
|
5
|
+
<user>
|
6
|
+
<name>Through0glass</name>
|
7
|
+
<realname></realname>
|
8
|
+
<url>http://www.last.fm/user/Through0glass</url>
|
9
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/29673533.jpg</image>
|
10
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64/29673533.jpg</image>
|
11
|
+
|
12
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/29673533.jpg</image>
|
13
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/252/29673533.jpg</image>
|
14
|
+
<weight>796686</weight>
|
15
|
+
</user>
|
16
|
+
<user>
|
17
|
+
<name>hellobrook</name>
|
18
|
+
<realname>brook</realname>
|
19
|
+
|
20
|
+
<url>http://www.last.fm/user/hellobrook</url>
|
21
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/33834925.jpg</image>
|
22
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64/33834925.jpg</image>
|
23
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/33834925.jpg</image>
|
24
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/252/33834925.jpg</image>
|
25
|
+
<weight>353088</weight>
|
26
|
+
|
27
|
+
</user>
|
28
|
+
</topfans></lfm>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<lfm status="ok">
|
3
|
+
<toptags artist="Radiohead" track="Paranoid Android">
|
4
|
+
<tag>
|
5
|
+
<name>alternative</name>
|
6
|
+
<count>100</count>
|
7
|
+
<url>www.last.fm/tag/alternative</url>
|
8
|
+
</tag>
|
9
|
+
<tag>
|
10
|
+
<name>alternative rock</name>
|
11
|
+
<count>77</count>
|
12
|
+
|
13
|
+
<url>www.last.fm/tag/alternative%20rock</url>
|
14
|
+
</tag>
|
15
|
+
</toptags></lfm>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<lfm status="ok">
|
3
|
+
<results for="Believe" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
4
|
+
<opensearch:Query role="request" searchTerms="Believe" startPage="3" />
|
5
|
+
<opensearch:totalResults>40540</opensearch:totalResults>
|
6
|
+
<opensearch:startIndex>20</opensearch:startIndex>
|
7
|
+
<opensearch:itemsPerPage>10</opensearch:itemsPerPage>
|
8
|
+
<trackmatches>
|
9
|
+
<track>
|
10
|
+
<name>Make Me Believe</name>
|
11
|
+
<artist>Godsmack</artist>
|
12
|
+
|
13
|
+
<url>http://www.last.fm/music/Godsmack/_/Make+Me+Believe</url>
|
14
|
+
<streamable fulltrack="0">1</streamable>
|
15
|
+
<listeners>76858</listeners>
|
16
|
+
<image size="small">http://userserve-ak.last.fm/serve/34s/8674971.jpg</image>
|
17
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64s/8674971.jpg</image>
|
18
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/8674971.jpg</image>
|
19
|
+
|
20
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/300x300/8674971.jpg</image>
|
21
|
+
</track>
|
22
|
+
<track>
|
23
|
+
<name>I Believe in You</name>
|
24
|
+
<artist>Kylie Minogue</artist>
|
25
|
+
<url>http://www.last.fm/music/Kylie+Minogue/_/I+Believe+in+You</url>
|
26
|
+
<streamable fulltrack="0">0</streamable>
|
27
|
+
|
28
|
+
<listeners>74295</listeners>
|
29
|
+
<image size="small">http://userserve-ak.last.fm/serve/34s/8822309.jpg</image>
|
30
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64s/8822309.jpg</image>
|
31
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/8822309.jpg</image>
|
32
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/300x300/8822309.jpg</image>
|
33
|
+
</track>
|
34
|
+
</trackmatches>
|
35
|
+
</results></lfm>
|
data/spec/lastfm_spec.rb
CHANGED
@@ -3,6 +3,16 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe "Lastfm" do
|
4
4
|
before do
|
5
5
|
@lastfm = Lastfm.new('xxx', 'yyy')
|
6
|
+
@response_xml = <<XML
|
7
|
+
<?xml version="1.0" encoding="utf-8"?>
|
8
|
+
<lfm status="ok">
|
9
|
+
<foo>bar</foo></lfm>
|
10
|
+
XML
|
11
|
+
@ok_response = make_response(<<XML)
|
12
|
+
<?xml version="1.0" encoding="utf-8"?>
|
13
|
+
<lfm status="ok">
|
14
|
+
</lfm>
|
15
|
+
XML
|
6
16
|
end
|
7
17
|
|
8
18
|
it 'should have base_uri' do
|
@@ -22,10 +32,9 @@ describe "Lastfm" do
|
|
22
32
|
:foo => 'bar',
|
23
33
|
:method => 'xxx.yyy',
|
24
34
|
:api_key => 'xxx',
|
25
|
-
:format => 'json'
|
26
35
|
}).and_return(mock_response)
|
27
|
-
mock_response.should_receive(:body).and_return(
|
28
|
-
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, false, false)
|
36
|
+
mock_response.should_receive(:body).and_return(@response_xml)
|
37
|
+
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, false, false)
|
29
38
|
end
|
30
39
|
|
31
40
|
it 'should post with signature' do
|
@@ -35,10 +44,9 @@ describe "Lastfm" do
|
|
35
44
|
:method => 'xxx.yyy',
|
36
45
|
:api_key => 'xxx',
|
37
46
|
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyyyy'),
|
38
|
-
:format => 'json'
|
39
47
|
}).and_return(mock_response)
|
40
|
-
mock_response.should_receive(:body).and_return(
|
41
|
-
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, true, false)
|
48
|
+
mock_response.should_receive(:body).and_return(@response_xml)
|
49
|
+
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, true, false)
|
42
50
|
end
|
43
51
|
|
44
52
|
it 'should post with signature and session (request with authentication)' do
|
@@ -50,11 +58,9 @@ describe "Lastfm" do
|
|
50
58
|
:api_key => 'xxx',
|
51
59
|
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyskabcdefyyy'),
|
52
60
|
:sk => 'abcdef',
|
53
|
-
:format => 'json'
|
54
61
|
}).and_return(mock_response)
|
55
|
-
mock_response.should_receive(:body).and_return(
|
56
|
-
|
57
|
-
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, true, true)['bar'].should eql('baz')
|
62
|
+
mock_response.should_receive(:body).and_return(@response_xml)
|
63
|
+
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, true, true)
|
58
64
|
end
|
59
65
|
|
60
66
|
it 'should get' do
|
@@ -63,11 +69,9 @@ describe "Lastfm" do
|
|
63
69
|
:foo => 'bar',
|
64
70
|
:method => 'xxx.yyy',
|
65
71
|
:api_key => 'xxx',
|
66
|
-
:format => 'json'
|
67
72
|
}).and_return(mock_response)
|
68
|
-
mock_response.should_receive(:body).and_return(
|
69
|
-
|
70
|
-
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, false, false)['bar'].should eql('baz')
|
73
|
+
mock_response.should_receive(:body).and_return(@response_xml)
|
74
|
+
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, false, false)
|
71
75
|
end
|
72
76
|
|
73
77
|
it 'should get with signature (request for authentication)' do
|
@@ -77,11 +81,9 @@ describe "Lastfm" do
|
|
77
81
|
:method => 'xxx.yyy',
|
78
82
|
:api_key => 'xxx',
|
79
83
|
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyyyy'),
|
80
|
-
:format => 'json'
|
81
84
|
}).and_return(mock_response)
|
82
|
-
mock_response.should_receive(:body).and_return(
|
83
|
-
|
84
|
-
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, true, false)['bar'].should eql('baz')
|
85
|
+
mock_response.should_receive(:body).and_return(@response_xml)
|
86
|
+
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, true, false)
|
85
87
|
end
|
86
88
|
|
87
89
|
it 'should get with signature and session' do
|
@@ -93,47 +95,59 @@ describe "Lastfm" do
|
|
93
95
|
:api_key => 'xxx',
|
94
96
|
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyskabcdefyyy'),
|
95
97
|
:sk => 'abcdef',
|
96
|
-
:format => 'json'
|
97
98
|
}).and_return(mock_response)
|
98
|
-
mock_response.should_receive(:body).and_return(
|
99
|
-
|
100
|
-
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, true, true)['bar'].should eql('baz')
|
99
|
+
mock_response.should_receive(:body).and_return(@response_xml)
|
100
|
+
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, true, true)
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'should raise an error if an api error is ocuured' do
|
104
104
|
mock_response = mock(HTTParty::Response)
|
105
|
-
mock_response.should_receive(:body).and_return('
|
105
|
+
mock_response.should_receive(:body).and_return(open(fixture('ng.xml')).read)
|
106
106
|
@lastfm.class.should_receive(:post).and_return(mock_response)
|
107
107
|
|
108
108
|
lambda {
|
109
109
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post)
|
110
|
-
}.should raise_error(Lastfm::ApiError, 'Invalid
|
110
|
+
}.should raise_error(Lastfm::ApiError, 'Invalid API key - You must be granted a valid key by last.fm')
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
describe '#auth' do
|
115
115
|
it 'should return an instance of Lastfm::Auth' do
|
116
|
-
@lastfm.auth.should be_an_instance_of(Lastfm::Auth)
|
116
|
+
@lastfm.auth.should be_an_instance_of(Lastfm::MethodCategory::Auth)
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'should get token' do
|
120
120
|
@lastfm.should_receive(:request).
|
121
121
|
with('auth.getToken', {}, :get, true).
|
122
|
-
and_return(
|
122
|
+
and_return(make_response(<<XML))
|
123
|
+
<?xml version="1.0" encoding="utf-8"?>
|
124
|
+
<lfm status="ok">
|
125
|
+
<token>xxxyyyzzz</token></lfm>
|
126
|
+
XML
|
127
|
+
|
123
128
|
@lastfm.auth.get_token.should eql('xxxyyyzzz')
|
124
129
|
end
|
125
130
|
|
126
131
|
it 'should get session' do
|
127
132
|
@lastfm.should_receive(:request).
|
128
133
|
with('auth.getSession', { :token => 'xxxyyyzzz' }, :get, true).
|
129
|
-
and_return(
|
134
|
+
and_return(make_response(<<XML))
|
135
|
+
<?xml version="1.0" encoding="utf-8"?>
|
136
|
+
<lfm status="ok">
|
137
|
+
<session>
|
138
|
+
<name>MyLastFMUsername</name>
|
139
|
+
<key>zzzyyyxxx</key>
|
140
|
+
<subscriber>0</subscriber>
|
141
|
+
</session>
|
142
|
+
</lfm>
|
143
|
+
XML
|
130
144
|
@lastfm.auth.get_session('xxxyyyzzz').should eql('zzzyyyxxx')
|
131
145
|
end
|
132
146
|
end
|
133
147
|
|
134
148
|
describe '#track' do
|
135
149
|
it 'should return an instance of Lastfm::Track' do
|
136
|
-
@lastfm.track.should be_an_instance_of(Lastfm::Track)
|
150
|
+
@lastfm.track.should be_an_instance_of(Lastfm::MethodCategory::Track)
|
137
151
|
end
|
138
152
|
|
139
153
|
it 'should add tags' do
|
@@ -141,73 +155,107 @@ describe "Lastfm" do
|
|
141
155
|
:artist => 'foo artist',
|
142
156
|
:track => 'foo track',
|
143
157
|
:tags => 'aaa,bbb,ccc'
|
144
|
-
}, :post, true, true).and_return(
|
158
|
+
}, :post, true, true).and_return(@ok_response)
|
145
159
|
|
146
|
-
@lastfm.track.add_tags('foo artist', 'foo track', 'aaa,bbb,ccc')
|
160
|
+
@lastfm.track.add_tags('foo artist', 'foo track', 'aaa,bbb,ccc').should be_true
|
147
161
|
end
|
148
162
|
|
149
163
|
it 'should ban' do
|
150
164
|
@lastfm.should_receive(:request).with('track.ban', {
|
151
165
|
:artist => 'foo artist',
|
152
166
|
:track => 'foo track',
|
153
|
-
}, :post, true, true).and_return(
|
167
|
+
}, :post, true, true).and_return(@ok_response)
|
154
168
|
|
155
|
-
@lastfm.track.ban('foo artist', 'foo track')
|
169
|
+
@lastfm.track.ban('foo artist', 'foo track').should be_true
|
156
170
|
end
|
157
171
|
|
158
172
|
it 'should get info' do
|
159
173
|
@lastfm.should_receive(:request).with('track.getInfo', {
|
160
|
-
:artist => '
|
161
|
-
:track => '
|
174
|
+
:artist => 'Cher',
|
175
|
+
:track => 'Believe',
|
162
176
|
:username => 'youpy',
|
163
|
-
}).and_return(
|
177
|
+
}).and_return(make_response('track_get_info'))
|
178
|
+
|
179
|
+
track = @lastfm.track.get_info('Cher', 'Believe', 'youpy')
|
180
|
+
track['name'].should eql('Believe')
|
181
|
+
track['album']['image'].size.should eql(4)
|
182
|
+
track['album']['image'].first['size'].should eql('small')
|
183
|
+
track['album']['image'].first['content'].should eql('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
|
184
|
+
track['toptags']['tag'].size.should eql(5)
|
185
|
+
track['toptags']['tag'].first['name'].should eql('pop')
|
186
|
+
end
|
164
187
|
|
165
|
-
|
188
|
+
it 'should get xml with force array option' do
|
189
|
+
@lastfm.should_receive(:request).with('track.getInfo', {
|
190
|
+
:artist => 'Cher',
|
191
|
+
:track => 'Believe',
|
192
|
+
:username => 'youpy',
|
193
|
+
}).and_return(make_response('track_get_info_force_array'))
|
194
|
+
|
195
|
+
track = @lastfm.track.get_info('Cher', 'Believe', 'youpy')
|
196
|
+
track['album']['image'].size.should eql(1)
|
197
|
+
track['album']['image'].first['size'].should eql('small')
|
198
|
+
track['album']['image'].first['content'].should eql('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
|
199
|
+
track['toptags']['tag'].size.should eql(1)
|
200
|
+
track['toptags']['tag'].first['name'].should eql('pop')
|
166
201
|
end
|
167
202
|
|
168
203
|
it 'should get similar' do
|
169
204
|
@lastfm.should_receive(:request).with('track.getSimilar', {
|
170
|
-
:artist => '
|
171
|
-
:track => '
|
172
|
-
}).and_return(
|
173
|
-
|
174
|
-
@lastfm.track.get_similar('
|
205
|
+
:artist => 'Cher',
|
206
|
+
:track => 'Believe',
|
207
|
+
}).and_return(make_response('track_get_similar'))
|
208
|
+
|
209
|
+
tracks = @lastfm.track.get_similar('Cher', 'Believe')
|
210
|
+
tracks.size.should eql(250)
|
211
|
+
tracks.first['name'].should eql('Strong Enough')
|
212
|
+
tracks.first['image'][1]['content'].should eql('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
|
213
|
+
tracks[1]['image'][0]['content'].should eql('http://userserve-ak.last.fm/serve/34s/8674593.jpg')
|
175
214
|
end
|
176
215
|
|
177
216
|
it 'should get tags' do
|
178
217
|
@lastfm.should_receive(:request).with('track.getTags', {
|
179
218
|
:artist => 'foo artist',
|
180
219
|
:track => 'foo track',
|
181
|
-
}, :get, true, true).and_return(
|
220
|
+
}, :get, true, true).and_return(make_response('track_get_tags'))
|
182
221
|
|
183
|
-
@lastfm.track.get_tags('foo artist', 'foo track')
|
222
|
+
tags = @lastfm.track.get_tags('foo artist', 'foo track')
|
223
|
+
tags.size.should eql(2)
|
224
|
+
tags[0]['name'].should eql('swedish')
|
225
|
+
tags[0]['url'].should eql('http://www.last.fm/tag/swedish')
|
184
226
|
end
|
185
227
|
|
186
228
|
it 'should get top fans' do
|
187
229
|
@lastfm.should_receive(:request).with('track.getTopFans', {
|
188
230
|
:artist => 'foo artist',
|
189
231
|
:track => 'foo track',
|
190
|
-
}).and_return(
|
232
|
+
}).and_return(make_response('track_get_top_fans'))
|
191
233
|
|
192
|
-
@lastfm.track.get_top_fans('foo artist', 'foo track')
|
234
|
+
users = @lastfm.track.get_top_fans('foo artist', 'foo track')
|
235
|
+
users.size.should eql(2)
|
236
|
+
users[0]['name'].should eql('Through0glass')
|
193
237
|
end
|
194
238
|
|
195
239
|
it 'should get top tags' do
|
196
240
|
@lastfm.should_receive(:request).with('track.getTopTags', {
|
197
241
|
:artist => 'foo artist',
|
198
242
|
:track => 'foo track',
|
199
|
-
}).and_return(
|
243
|
+
}).and_return(make_response('track_get_top_tags'))
|
200
244
|
|
201
|
-
@lastfm.track.get_top_tags('foo artist', 'foo track')
|
245
|
+
tags = @lastfm.track.get_top_tags('foo artist', 'foo track')
|
246
|
+
tags.size.should eql(2)
|
247
|
+
tags[0]['name'].should eql('alternative')
|
248
|
+
tags[0]['count'].should eql('100')
|
249
|
+
tags[0]['url'].should eql('www.last.fm/tag/alternative')
|
202
250
|
end
|
203
251
|
|
204
252
|
it 'should love' do
|
205
253
|
@lastfm.should_receive(:request).with('track.love', {
|
206
254
|
:artist => 'foo artist',
|
207
255
|
:track => 'foo track',
|
208
|
-
}, :post, true, true).and_return(
|
256
|
+
}, :post, true, true).and_return(@ok_response)
|
209
257
|
|
210
|
-
@lastfm.track.love('foo artist', 'foo track')
|
258
|
+
@lastfm.track.love('foo artist', 'foo track').should be_true
|
211
259
|
end
|
212
260
|
|
213
261
|
it 'should remove tag' do
|
@@ -215,20 +263,24 @@ describe "Lastfm" do
|
|
215
263
|
:artist => 'foo artist',
|
216
264
|
:track => 'foo track',
|
217
265
|
:tag => 'aaa'
|
218
|
-
}, :post, true, true).and_return(
|
266
|
+
}, :post, true, true).and_return(@ok_response)
|
219
267
|
|
220
|
-
@lastfm.track.remove_tag('foo artist', 'foo track', 'aaa')
|
268
|
+
@lastfm.track.remove_tag('foo artist', 'foo track', 'aaa').should be_true
|
221
269
|
end
|
222
270
|
|
223
271
|
it 'should search' do
|
224
272
|
@lastfm.should_receive(:request).with('track.search', {
|
225
|
-
:artist =>
|
226
|
-
:track => '
|
273
|
+
:artist => nil,
|
274
|
+
:track => 'Believe',
|
227
275
|
:limit => 10,
|
228
276
|
:page => 3,
|
229
|
-
}).and_return(
|
277
|
+
}).and_return(make_response('track_search'))
|
230
278
|
|
231
|
-
@lastfm.track.search('
|
279
|
+
tracks = @lastfm.track.search('Believe', nil, 10, 3)
|
280
|
+
tracks['results']['for'].should eql('Believe')
|
281
|
+
tracks['results']['totalResults'].should eql('40540')
|
282
|
+
tracks['results']['trackmatches']['track'].size.should eql(2)
|
283
|
+
tracks['results']['trackmatches']['track'][0]['name'].should eql('Make Me Believe')
|
232
284
|
end
|
233
285
|
|
234
286
|
it 'should share' do
|
@@ -237,9 +289,37 @@ describe "Lastfm" do
|
|
237
289
|
:track => 'foo track',
|
238
290
|
:message => 'this is a message',
|
239
291
|
:recipient => 'foo@example.com',
|
240
|
-
}, :post, true, true).and_return(
|
292
|
+
}, :post, true, true).and_return(@ok_response)
|
293
|
+
|
294
|
+
@lastfm.track.share('foo artist', 'foo track', 'foo@example.com', 'this is a message').should be_true
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
describe '#artist' do
|
299
|
+
it 'should return an instance of Lastfm::Artist' do
|
300
|
+
@lastfm.artist.should be_an_instance_of(Lastfm::MethodCategory::Artist)
|
301
|
+
end
|
241
302
|
|
242
|
-
|
303
|
+
it 'should get events' do
|
304
|
+
@lastfm.should_receive(:request).with('artist.getEvents', {
|
305
|
+
:artist => 'Cher'
|
306
|
+
}).and_return(make_response('artist_get_events'))
|
307
|
+
|
308
|
+
events = @lastfm.artist.get_events('Cher')
|
309
|
+
events.size.should eql(1)
|
310
|
+
events[0]['title'].should eql('Cher')
|
311
|
+
events[0]['artists'].size.should == 2
|
312
|
+
events[0]['artists']['headliner'].should eql('Cher')
|
313
|
+
events[0]['venue']['name'].should eql('The Colosseum At Caesars Palace')
|
314
|
+
events[0]['venue']['location']['city'].should eql('Las Vegas(, NV)')
|
315
|
+
events[0]['venue']['location']['point']['lat'].should eql("36.116143")
|
316
|
+
events[0]['image'].size.should eql(4)
|
317
|
+
events[0]['image'][0]['size'].should eql('small')
|
318
|
+
events[0]['image'][0]['content'].should eql('http://userserve-ak.last.fm/serve/34/34814037.jpg')
|
319
|
+
events[0]['startDate'].should eql("Sat, 23 Oct 2010 19:30:00")
|
320
|
+
events[0]['tickets']['ticket']['supplier'].should eql("TicketMaster")
|
321
|
+
events[0]['tickets']['ticket']['content'].should eql("http://www.last.fm/affiliate/byid/29/1584537/12/ws.artist.events.b25b959554ed76058ac220b7b2e0a026")
|
322
|
+
events[0]['tags']['tag'].should == ["pop", "dance", "female vocalists", "80s", "cher"]
|
243
323
|
end
|
244
324
|
end
|
245
325
|
end
|
@@ -6,6 +6,6 @@ describe 'Lastfm::MethodCategory' do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'should have instance of Lastfm' do
|
9
|
-
Lastfm::MethodCategory.new(@lastfm).instance_eval { @lastfm }.should equal(@lastfm)
|
9
|
+
Lastfm::MethodCategory::Base.new(@lastfm).instance_eval { @lastfm }.should equal(@lastfm)
|
10
10
|
end
|
11
11
|
end
|