echowrap 0.0.1

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.
Files changed (159) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +16 -0
  3. data/Gemfile +13 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +111 -0
  6. data/Rakefile +1 -0
  7. data/echowrap.gemspec +24 -0
  8. data/lib/echowrap/analysis.rb +39 -0
  9. data/lib/echowrap/api/artist.rb +387 -0
  10. data/lib/echowrap/api/oauth.rb +25 -0
  11. data/lib/echowrap/api/playlist.rb +248 -0
  12. data/lib/echowrap/api/sandbox.rb +45 -0
  13. data/lib/echowrap/api/song.rb +111 -0
  14. data/lib/echowrap/api/taste_profile.rb +296 -0
  15. data/lib/echowrap/api/track.rb +64 -0
  16. data/lib/echowrap/api/utils.rb +57 -0
  17. data/lib/echowrap/artist.rb +73 -0
  18. data/lib/echowrap/asset.rb +12 -0
  19. data/lib/echowrap/audio_summary.rb +15 -0
  20. data/lib/echowrap/base.rb +88 -0
  21. data/lib/echowrap/biography.rb +13 -0
  22. data/lib/echowrap/blog.rb +8 -0
  23. data/lib/echowrap/call_list.rb +8 -0
  24. data/lib/echowrap/category_map.rb +8 -0
  25. data/lib/echowrap/client.rb +80 -0
  26. data/lib/echowrap/configurable.rb +84 -0
  27. data/lib/echowrap/default.rb +88 -0
  28. data/lib/echowrap/doc_counts.rb +8 -0
  29. data/lib/echowrap/echonest_id.rb +8 -0
  30. data/lib/echowrap/error/bad_gateway.rb +11 -0
  31. data/lib/echowrap/error/bad_request.rb +10 -0
  32. data/lib/echowrap/error/client_error.rb +35 -0
  33. data/lib/echowrap/error/configuration_error.rb +8 -0
  34. data/lib/echowrap/error/forbidden.rb +10 -0
  35. data/lib/echowrap/error/gateway_timeout.rb +11 -0
  36. data/lib/echowrap/error/internal_server_error.rb +11 -0
  37. data/lib/echowrap/error/not_acceptable.rb +10 -0
  38. data/lib/echowrap/error/not_found.rb +10 -0
  39. data/lib/echowrap/error/server_error.rb +28 -0
  40. data/lib/echowrap/error/service_unavailable.rb +11 -0
  41. data/lib/echowrap/error/too_many_requests.rb +12 -0
  42. data/lib/echowrap/error/unauthorized.rb +10 -0
  43. data/lib/echowrap/error/unprocessable_entity.rb +10 -0
  44. data/lib/echowrap/error.rb +32 -0
  45. data/lib/echowrap/familiarity.rb +8 -0
  46. data/lib/echowrap/feed.rb +14 -0
  47. data/lib/echowrap/foreign_id.rb +10 -0
  48. data/lib/echowrap/genre.rb +8 -0
  49. data/lib/echowrap/hotttnesss.rb +8 -0
  50. data/lib/echowrap/image.rb +15 -0
  51. data/lib/echowrap/item.rb +95 -0
  52. data/lib/echowrap/item_request.rb +8 -0
  53. data/lib/echowrap/keyvalues.rb +8 -0
  54. data/lib/echowrap/license.rb +10 -0
  55. data/lib/echowrap/location.rb +8 -0
  56. data/lib/echowrap/meta.rb +9 -0
  57. data/lib/echowrap/news_article.rb +8 -0
  58. data/lib/echowrap/options.rb +10 -0
  59. data/lib/echowrap/playlist.rb +47 -0
  60. data/lib/echowrap/prediction.rb +7 -0
  61. data/lib/echowrap/rate_limit.rb +47 -0
  62. data/lib/echowrap/reference.rb +8 -0
  63. data/lib/echowrap/request/multipart_with_file.rb +36 -0
  64. data/lib/echowrap/response/parse_json.rb +25 -0
  65. data/lib/echowrap/response/raise_error.rb +31 -0
  66. data/lib/echowrap/review.rb +8 -0
  67. data/lib/echowrap/rule.rb +8 -0
  68. data/lib/echowrap/sandbox.rb +11 -0
  69. data/lib/echowrap/seeds.rb +9 -0
  70. data/lib/echowrap/sequenced_data/bar.rb +4 -0
  71. data/lib/echowrap/sequenced_data/beat.rb +4 -0
  72. data/lib/echowrap/sequenced_data/section.rb +6 -0
  73. data/lib/echowrap/sequenced_data/segment.rb +4 -0
  74. data/lib/echowrap/sequenced_data/tatum.rb +4 -0
  75. data/lib/echowrap/sequenced_data.rb +12 -0
  76. data/lib/echowrap/song.rb +24 -0
  77. data/lib/echowrap/status.rb +12 -0
  78. data/lib/echowrap/taste_profile.rb +28 -0
  79. data/lib/echowrap/term.rb +8 -0
  80. data/lib/echowrap/track.rb +21 -0
  81. data/lib/echowrap/update_info.rb +8 -0
  82. data/lib/echowrap/urls.rb +9 -0
  83. data/lib/echowrap/version.rb +18 -0
  84. data/lib/echowrap/video.rb +7 -0
  85. data/lib/echowrap/years_active.rb +8 -0
  86. data/lib/echowrap.rb +78 -0
  87. data/spec/echonest/api/artist_spec.rb +901 -0
  88. data/spec/echonest/api/oauth_spec.rb +29 -0
  89. data/spec/echonest/api/playlist_spec.rb +274 -0
  90. data/spec/echonest/api/sandbox_spec.rb +67 -0
  91. data/spec/echonest/api/song_spec.rb +326 -0
  92. data/spec/echonest/api/taste_profile_spec.rb +403 -0
  93. data/spec/echonest/api/track_spec.rb +167 -0
  94. data/spec/echonest/base_spec.rb +119 -0
  95. data/spec/echonest/client_spec.rb +174 -0
  96. data/spec/echonest/error_spec.rb +20 -0
  97. data/spec/echonest/rate_limit_spec.rb +76 -0
  98. data/spec/echonest_spec.rb +65 -0
  99. data/spec/fixtures/artist/biographies.json +1 -0
  100. data/spec/fixtures/artist/blogs.json +1 -0
  101. data/spec/fixtures/artist/extract.json +1 -0
  102. data/spec/fixtures/artist/familiarity.json +1 -0
  103. data/spec/fixtures/artist/hotttnesss.json +1 -0
  104. data/spec/fixtures/artist/images.json +1 -0
  105. data/spec/fixtures/artist/list_genres.json +1 -0
  106. data/spec/fixtures/artist/list_terms.json +1 -0
  107. data/spec/fixtures/artist/news.json +1 -0
  108. data/spec/fixtures/artist/profile.json +1 -0
  109. data/spec/fixtures/artist/reviews.json +1 -0
  110. data/spec/fixtures/artist/search.json +1 -0
  111. data/spec/fixtures/artist/similar.json +1 -0
  112. data/spec/fixtures/artist/songs.json +1 -0
  113. data/spec/fixtures/artist/suggest.json +1 -0
  114. data/spec/fixtures/artist/terms.json +1 -0
  115. data/spec/fixtures/artist/top_hottt.json +1 -0
  116. data/spec/fixtures/artist/top_terms.json +1 -0
  117. data/spec/fixtures/artist/twitter.json +1 -0
  118. data/spec/fixtures/artist/urls.json +1 -0
  119. data/spec/fixtures/artist/video.json +1 -0
  120. data/spec/fixtures/billie_jean_fingerprint.txt +1 -0
  121. data/spec/fixtures/billie_jean_query.json +16 -0
  122. data/spec/fixtures/oauth/timestamp.json +1 -0
  123. data/spec/fixtures/playlist/basic.json +1 -0
  124. data/spec/fixtures/playlist/dynamic/create.json +1 -0
  125. data/spec/fixtures/playlist/dynamic/delete.json +1 -0
  126. data/spec/fixtures/playlist/dynamic/feedback.json +1 -0
  127. data/spec/fixtures/playlist/dynamic/info.json +1 -0
  128. data/spec/fixtures/playlist/dynamic/next.json +1 -0
  129. data/spec/fixtures/playlist/dynamic/restart.json +1 -0
  130. data/spec/fixtures/playlist/dynamic/steer.json +1 -0
  131. data/spec/fixtures/playlist/static.json +1 -0
  132. data/spec/fixtures/sandbox/access.json +19 -0
  133. data/spec/fixtures/sandbox/list.json +1 -0
  134. data/spec/fixtures/song/identify.json +19 -0
  135. data/spec/fixtures/song/profile.json +1 -0
  136. data/spec/fixtures/song/search.json +1 -0
  137. data/spec/fixtures/taste_profile/ban.json +9 -0
  138. data/spec/fixtures/taste_profile/create.json +1 -0
  139. data/spec/fixtures/taste_profile/delete.json +11 -0
  140. data/spec/fixtures/taste_profile/favorite.json +9 -0
  141. data/spec/fixtures/taste_profile/feed.json +1 -0
  142. data/spec/fixtures/taste_profile/keyvalues.json +4 -0
  143. data/spec/fixtures/taste_profile/list.json +1 -0
  144. data/spec/fixtures/taste_profile/play.json +9 -0
  145. data/spec/fixtures/taste_profile/predict.json +1 -0
  146. data/spec/fixtures/taste_profile/profile.json +1 -0
  147. data/spec/fixtures/taste_profile/rate.json +9 -0
  148. data/spec/fixtures/taste_profile/read.json +1 -0
  149. data/spec/fixtures/taste_profile/similar.json +14 -0
  150. data/spec/fixtures/taste_profile/skip.json +9 -0
  151. data/spec/fixtures/taste_profile/status.json +2 -0
  152. data/spec/fixtures/taste_profile/update.json +10 -0
  153. data/spec/fixtures/taste_profile/update_request_data.json +4 -0
  154. data/spec/fixtures/technolol-music.mp3 +0 -0
  155. data/spec/fixtures/track/analysis.json +3 -0
  156. data/spec/fixtures/track/profile.json +35 -0
  157. data/spec/fixtures/track/upload.json +21 -0
  158. data/spec/helper.rb +50 -0
  159. metadata +323 -0
@@ -0,0 +1,901 @@
1
+ require 'helper'
2
+
3
+ describe Echowrap::API::Artist do
4
+
5
+ before do
6
+ @client = new_test_client
7
+ end
8
+
9
+ describe '#artist_biographies' do
10
+ before do
11
+ stub_get("/api/v4/artist/biographies").
12
+ with(:query => {:id => 'ARH6W4X1187B99274F'}).
13
+ to_return(:body => fixture("artist/biographies.json"),
14
+ :headers => {:content_type => "application/json; charset=utf-8"})
15
+ end
16
+
17
+ it "requests the correct resource" do
18
+ @client.artist_biographies(:id => 'ARH6W4X1187B99274F')
19
+ expect(a_get("/api/v4/artist/biographies").
20
+ with(:query => {:id => 'ARH6W4X1187B99274F'})).
21
+ to have_been_made
22
+ end
23
+
24
+ it "returns biographies" do
25
+ biographies = @client.artist_biographies(:id => 'ARH6W4X1187B99274F')
26
+ expect(biographies).to be_an Array
27
+ expect(biographies.first.site).to eq 'last.fm'
28
+ expect(biographies.first.license.attribution).to eq 'Last.fm'
29
+ end
30
+ end
31
+
32
+ describe '#artist_blogs' do
33
+ before do
34
+ stub_get("/api/v4/artist/blogs").
35
+ with(:query => {:id => 'ARH6W4X1187B99274F'}).
36
+ to_return(:body => fixture("artist/blogs.json"),
37
+ :headers => {:content_type => "application/json; charset=utf-8"})
38
+ end
39
+
40
+ it "requests the correct resource" do
41
+ @client.artist_blogs(:id => 'ARH6W4X1187B99274F')
42
+ expect(a_get("/api/v4/artist/blogs").
43
+ with(:query => {:id => 'ARH6W4X1187B99274F'})).
44
+ to have_been_made
45
+ end
46
+
47
+ it "returns blogs" do
48
+ blogs = @client.artist_blogs(:id => 'ARH6W4X1187B99274F')
49
+ expect(blogs).to be_an Array
50
+ expect(blogs.first.id).to eq '30fc8108d77316c6789140bef92ecc09'
51
+ end
52
+ end
53
+
54
+ describe "#artist_extract" do
55
+
56
+ before do
57
+ stub_get("/api/v4/artist/extract").
58
+ with(:query => {
59
+ :results => 1,
60
+ :text => 'Siriusmo is my favorite, but I also like hrvatski'}).
61
+ to_return(:body => fixture("artist/extract.json"),
62
+ :headers => {:content_type => "application/json; charset=utf-8"})
63
+ end
64
+
65
+ it "requests the correct resource" do
66
+ @client.artist_extract(:results => 1,
67
+ :text => 'Siriusmo is my favorite, but I also like hrvatski')
68
+ expect(a_get("/api/v4/artist/extract")
69
+ .with(:query => {:results => 1,
70
+ :text => 'Siriusmo is my favorite, but I also like hrvatski'}))
71
+ .to have_been_made
72
+ end
73
+
74
+ it "returns artists" do
75
+ artists = @client.artist_extract(:results => 1,
76
+ :text => 'Siriusmo is my favorite, but I also like hrvatski')
77
+ expect(artists).to be_an Array
78
+ expect(artists.first.name).to eq "Siriusmo"
79
+ end
80
+
81
+ end
82
+
83
+ describe '#artist_familiarity' do
84
+ before do
85
+ stub_get("/api/v4/artist/familiarity").
86
+ with(:query => {:id => 'ARH6W4X1187B99274F'}).
87
+ to_return(:body => fixture("artist/familiarity.json"),
88
+ :headers => {:content_type => "application/json; charset=utf-8"})
89
+ end
90
+
91
+ it "requests the correct resource" do
92
+ @client.artist_familiarity(:id => 'ARH6W4X1187B99274F')
93
+ expect(a_get("/api/v4/artist/familiarity").
94
+ with(:query => {:id => 'ARH6W4X1187B99274F'})).
95
+ to have_been_made
96
+ end
97
+
98
+ it "returns familiarity" do
99
+ familiarity = @client.artist_familiarity(:id => 'ARH6W4X1187B99274F')
100
+ expect(familiarity).to be_an Echowrap::Familiarity
101
+ expect(familiarity.id).to eq 'ARH6W4X1187B99274F'
102
+ end
103
+ end
104
+
105
+ describe '#artist_hotttnesss' do
106
+ before do
107
+ stub_get("/api/v4/artist/hotttnesss").
108
+ with(:query => {:id => 'ARH6W4X1187B99274F'}).
109
+ to_return(:body => fixture("artist/hotttnesss.json"),
110
+ :headers => {:content_type => "application/json; charset=utf-8"})
111
+ end
112
+
113
+ it "requests the correct resource" do
114
+ @client.artist_hotttnesss(:id => 'ARH6W4X1187B99274F')
115
+ expect(a_get("/api/v4/artist/hotttnesss").
116
+ with(:query => {:id => 'ARH6W4X1187B99274F'})).
117
+ to have_been_made
118
+ end
119
+
120
+ it "returns hotttnesss" do
121
+ hotttnesss = @client.artist_hotttnesss(:id => 'ARH6W4X1187B99274F')
122
+ expect(hotttnesss).to be_an Echowrap::Hotttnesss
123
+ expect(hotttnesss.id).to eq 'ARH6W4X1187B99274F'
124
+ end
125
+ end
126
+
127
+ describe '#artist_images' do
128
+ before do
129
+ stub_get("/api/v4/artist/images").
130
+ with(:query => {:id => 'ARH6W4X1187B99274F'}).
131
+ to_return(:body => fixture("artist/images.json"),
132
+ :headers => {:content_type => "application/json; charset=utf-8"})
133
+ end
134
+
135
+ it "requests the correct resource" do
136
+ @client.artist_images(:id => 'ARH6W4X1187B99274F')
137
+ expect(a_get("/api/v4/artist/images").
138
+ with(:query => {:id => 'ARH6W4X1187B99274F'})).
139
+ to have_been_made
140
+ end
141
+
142
+ it "returns images" do
143
+ images = @client.artist_images(:id => 'ARH6W4X1187B99274F')
144
+ expect(images).to be_an Array
145
+ expect(images.first.url).to eq 'http://userserve-ak.last.fm/serve/_/102639.jpg'
146
+ expect(images.first.license.attribution).to eq 'last.fm'
147
+ end
148
+ end
149
+
150
+ describe '#artist_list_genres' do
151
+ before do
152
+ stub_get("/api/v4/artist/list_genres").
153
+ to_return(:body => fixture("artist/list_genres.json"),
154
+ :headers => {:content_type => "application/json; charset=utf-8"})
155
+ end
156
+
157
+ it "requests the correct resource" do
158
+ @client.artist_list_genres
159
+ expect(a_get("/api/v4/artist/list_genres")).to have_been_made
160
+ end
161
+
162
+ it "returns genres" do
163
+ genres = @client.artist_list_genres
164
+ expect(genres).to be_an Array
165
+ expect(genres.first.name).to eq 'a cappella'
166
+ end
167
+ end
168
+
169
+ describe '#artist_list_terms' do
170
+ before do
171
+ stub_get("/api/v4/artist/list_terms").
172
+ to_return(:body => fixture("artist/list_terms.json"),
173
+ :headers => {:content_type => "application/json; charset=utf-8"})
174
+ end
175
+
176
+ it "requests the correct resource" do
177
+ @client.artist_list_terms
178
+ expect(a_get("/api/v4/artist/list_terms")).to have_been_made
179
+ end
180
+
181
+ it "returns terms" do
182
+ terms = @client.artist_list_terms
183
+ expect(terms).to be_an Array
184
+ expect(terms.first.name).to eq '00s'
185
+ end
186
+ end
187
+
188
+ describe '#artist_news' do
189
+ before do
190
+ stub_get("/api/v4/artist/news").
191
+ with(:query => {:id => 'ARH6W4X1187B99274F'}).
192
+ to_return(:body => fixture("artist/news.json"),
193
+ :headers => {:content_type => "application/json; charset=utf-8"})
194
+ end
195
+
196
+ it "requests the correct resource" do
197
+ @client.artist_news(:id => 'ARH6W4X1187B99274F')
198
+ expect(a_get("/api/v4/artist/news").
199
+ with(:query => {:id => 'ARH6W4X1187B99274F'})).
200
+ to have_been_made
201
+ end
202
+
203
+ it "returns news" do
204
+ news = @client.artist_news(:id => 'ARH6W4X1187B99274F')
205
+ expect(news).to be_an Array
206
+ expect(news.first.id).to eq '29c1699c8464426781f3e012d29fc1f6'
207
+ end
208
+ end
209
+
210
+ describe '#artist_profile' do
211
+ before do
212
+ stub_get("/api/v4/artist/profile").
213
+ with(:query => {:id => 'ARH6W4X1187B99274F',
214
+ :bucket => ['artist_location',
215
+ 'biographies',
216
+ 'blogs',
217
+ 'doc_counts',
218
+ 'familiarity',
219
+ 'hotttnesss',
220
+ 'images',
221
+ 'news',
222
+ 'songs',
223
+ 'reviews',
224
+ 'terms',
225
+ 'urls',
226
+ 'video',
227
+ 'years_active',
228
+ 'id:musicbrainz']}).
229
+ to_return(:body => fixture("artist/profile.json"),
230
+ :headers => {:content_type => "application/json; charset=utf-8"})
231
+ end
232
+
233
+ it "requests the correct resource" do
234
+ @client.artist_profile(:id => 'ARH6W4X1187B99274F',
235
+ :bucket => ['artist_location',
236
+ 'biographies',
237
+ 'blogs',
238
+ 'doc_counts',
239
+ 'familiarity',
240
+ 'hotttnesss',
241
+ 'images',
242
+ 'news',
243
+ 'songs',
244
+ 'reviews',
245
+ 'terms',
246
+ 'urls',
247
+ 'video',
248
+ 'years_active',
249
+ 'id:musicbrainz'])
250
+ expect(a_get("/api/v4/artist/profile").
251
+ with(:query => {:id => 'ARH6W4X1187B99274F',
252
+ :bucket => ['artist_location',
253
+ 'biographies',
254
+ 'blogs',
255
+ 'doc_counts',
256
+ 'familiarity',
257
+ 'hotttnesss',
258
+ 'images',
259
+ 'news',
260
+ 'songs',
261
+ 'reviews',
262
+ 'terms',
263
+ 'urls',
264
+ 'video',
265
+ 'years_active',
266
+ 'id:musicbrainz']})).
267
+ to have_been_made
268
+ end
269
+
270
+ it "returns an artist" do
271
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
272
+ :bucket => ['artist_location',
273
+ 'biographies',
274
+ 'blogs',
275
+ 'doc_counts',
276
+ 'familiarity',
277
+ 'hotttnesss',
278
+ 'images',
279
+ 'news',
280
+ 'songs',
281
+ 'reviews',
282
+ 'terms',
283
+ 'urls',
284
+ 'video',
285
+ 'years_active',
286
+ 'id:musicbrainz'])
287
+ expect(artist).to be_a Echowrap::Artist
288
+ expect(artist.id).to eq 'ARH6W4X1187B99274F'
289
+ end
290
+
291
+ it 'returns an artist with biographies' do
292
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
293
+ :bucket => ['artist_location',
294
+ 'biographies',
295
+ 'blogs',
296
+ 'doc_counts',
297
+ 'familiarity',
298
+ 'hotttnesss',
299
+ 'images',
300
+ 'news',
301
+ 'songs',
302
+ 'reviews',
303
+ 'terms',
304
+ 'urls',
305
+ 'video',
306
+ 'years_active',
307
+ 'id:musicbrainz'])
308
+ expect(artist.biographies).to be_an Array
309
+ expect(artist.biographies.first.site).to eq 'trouserpress'
310
+ end
311
+
312
+ it 'returns an artist with blogs' do
313
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
314
+ :bucket => ['artist_location',
315
+ 'biographies',
316
+ 'blogs',
317
+ 'doc_counts',
318
+ 'familiarity',
319
+ 'hotttnesss',
320
+ 'images',
321
+ 'news',
322
+ 'songs',
323
+ 'reviews',
324
+ 'terms',
325
+ 'urls',
326
+ 'video',
327
+ 'years_active',
328
+ 'id:musicbrainz'])
329
+ expect(artist.blogs).to be_an Array
330
+ expect(artist.blogs.first.id).to eq '24bfd596c968ccee4069f2b21817d692'
331
+ end
332
+
333
+ it 'returns an artist with a doc counts' do
334
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
335
+ :bucket => ['artist_location',
336
+ 'biographies',
337
+ 'blogs',
338
+ 'doc_counts',
339
+ 'familiarity',
340
+ 'hotttnesss',
341
+ 'images',
342
+ 'news',
343
+ 'songs',
344
+ 'reviews',
345
+ 'terms',
346
+ 'urls',
347
+ 'video',
348
+ 'years_active',
349
+ 'id:musicbrainz'])
350
+ expect(artist.doc_counts).to be_an Echowrap::DocCounts
351
+ expect(artist.doc_counts.songs).to eq 333
352
+ end
353
+
354
+ it 'returns an artist with familiarity' do
355
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
356
+ :bucket => ['artist_location',
357
+ 'biographies',
358
+ 'blogs',
359
+ 'doc_counts',
360
+ 'familiarity',
361
+ 'hotttnesss',
362
+ 'images',
363
+ 'news',
364
+ 'songs',
365
+ 'reviews',
366
+ 'terms',
367
+ 'urls',
368
+ 'video',
369
+ 'years_active',
370
+ 'id:musicbrainz'])
371
+ expect(artist.familiarity).to be_an Float
372
+ expect(artist.familiarity).to eq 0.897745
373
+ end
374
+
375
+ it 'returns an artist with hotttnesss' do
376
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
377
+ :bucket => ['artist_location',
378
+ 'biographies',
379
+ 'blogs',
380
+ 'doc_counts',
381
+ 'familiarity',
382
+ 'hotttnesss',
383
+ 'images',
384
+ 'news',
385
+ 'songs',
386
+ 'reviews',
387
+ 'terms',
388
+ 'urls',
389
+ 'video',
390
+ 'years_active',
391
+ 'id:musicbrainz'])
392
+ expect(artist.hotttnesss).to be_an Float
393
+ expect(artist.hotttnesss).to eq 0.64754
394
+ end
395
+
396
+ it 'returns an artist with images' do
397
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
398
+ :bucket => ['artist_location',
399
+ 'biographies',
400
+ 'blogs',
401
+ 'doc_counts',
402
+ 'familiarity',
403
+ 'hotttnesss',
404
+ 'images',
405
+ 'news',
406
+ 'songs',
407
+ 'reviews',
408
+ 'terms',
409
+ 'urls',
410
+ 'video',
411
+ 'years_active',
412
+ 'id:musicbrainz'])
413
+ expect(artist.images).to be_an Array
414
+ expect(artist.images.first.url).to eq 'http://userserve-ak.last.fm/serve/_/102639.jpg'
415
+ end
416
+
417
+ it 'returns an artist with a location' do
418
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
419
+ :bucket => ['artist_location',
420
+ 'biographies',
421
+ 'blogs',
422
+ 'doc_counts',
423
+ 'familiarity',
424
+ 'hotttnesss',
425
+ 'images',
426
+ 'news',
427
+ 'songs',
428
+ 'reviews',
429
+ 'terms',
430
+ 'urls',
431
+ 'video',
432
+ 'years_active',
433
+ 'id:musicbrainz'])
434
+ expect(artist.location).to be_an Echowrap::Location
435
+ expect(artist.location.location).to eq 'Abingdon, England, GB'
436
+ end
437
+
438
+ it 'returns an artist with news' do
439
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
440
+ :bucket => ['artist_location',
441
+ 'biographies',
442
+ 'blogs',
443
+ 'doc_counts',
444
+ 'familiarity',
445
+ 'hotttnesss',
446
+ 'images',
447
+ 'news',
448
+ 'songs',
449
+ 'reviews',
450
+ 'terms',
451
+ 'urls',
452
+ 'video',
453
+ 'years_active',
454
+ 'id:musicbrainz'])
455
+ expect(artist.news).to be_an Array
456
+ expect(artist.news.first.id).to eq 'c72241d996fa856b38d88acd4cedec18'
457
+ end
458
+
459
+ it 'returns an artist with reviews' do
460
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
461
+ :bucket => ['artist_location',
462
+ 'biographies',
463
+ 'blogs',
464
+ 'doc_counts',
465
+ 'familiarity',
466
+ 'hotttnesss',
467
+ 'images',
468
+ 'news',
469
+ 'songs',
470
+ 'reviews',
471
+ 'terms',
472
+ 'urls',
473
+ 'video',
474
+ 'years_active',
475
+ 'id:musicbrainz'])
476
+ expect(artist.reviews).to be_an Array
477
+ expect(artist.reviews.first.id).to eq '3f9fca724678df56f34845365110c511'
478
+ end
479
+
480
+ it 'returns an artist with songs' do
481
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
482
+ :bucket => ['artist_location',
483
+ 'biographies',
484
+ 'blogs',
485
+ 'doc_counts',
486
+ 'familiarity',
487
+ 'hotttnesss',
488
+ 'images',
489
+ 'news',
490
+ 'songs',
491
+ 'reviews',
492
+ 'terms',
493
+ 'urls',
494
+ 'video',
495
+ 'years_active',
496
+ 'id:musicbrainz'])
497
+ expect(artist.songs).to be_an Array
498
+ expect(artist.songs.first.id).to eq 'SOAROML1316771494B'
499
+ end
500
+
501
+
502
+ it 'returns an artist with terms' do
503
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
504
+ :bucket => ['artist_location',
505
+ 'biographies',
506
+ 'blogs',
507
+ 'doc_counts',
508
+ 'familiarity',
509
+ 'hotttnesss',
510
+ 'images',
511
+ 'news',
512
+ 'songs',
513
+ 'reviews',
514
+ 'terms',
515
+ 'urls',
516
+ 'video',
517
+ 'years_active',
518
+ 'id:musicbrainz'])
519
+ expect(artist.terms).to be_an Array
520
+ expect(artist.terms.first.name).to eq 'rock'
521
+ end
522
+
523
+ it 'returns an artist with urls' do
524
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
525
+ :bucket => ['artist_location',
526
+ 'biographies',
527
+ 'blogs',
528
+ 'doc_counts',
529
+ 'familiarity',
530
+ 'hotttnesss',
531
+ 'images',
532
+ 'news',
533
+ 'songs',
534
+ 'reviews',
535
+ 'terms',
536
+ 'urls',
537
+ 'video',
538
+ 'years_active',
539
+ 'id:musicbrainz'])
540
+ expect(artist.urls).to be_an Echowrap::Urls
541
+ expect(artist.urls.official_url).to eq 'http://radiohead.com'
542
+ end
543
+
544
+ it 'returns an artist with video' do
545
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
546
+ :bucket => ['artist_location',
547
+ 'biographies',
548
+ 'blogs',
549
+ 'doc_counts',
550
+ 'familiarity',
551
+ 'hotttnesss',
552
+ 'images',
553
+ 'news',
554
+ 'songs',
555
+ 'reviews',
556
+ 'terms',
557
+ 'urls',
558
+ 'video',
559
+ 'years_active',
560
+ 'id:musicbrainz'])
561
+ expect(artist.video).to be_an Array
562
+ expect(artist.video.first.id).to eq '36f2c2daf09feb738980d4783dc0a3b1'
563
+ end
564
+
565
+ it 'returns an artist with foreign_ids' do
566
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
567
+ :bucket => ['artist_location',
568
+ 'biographies',
569
+ 'blogs',
570
+ 'doc_counts',
571
+ 'familiarity',
572
+ 'hotttnesss',
573
+ 'images',
574
+ 'news',
575
+ 'songs',
576
+ 'reviews',
577
+ 'terms',
578
+ 'urls',
579
+ 'video',
580
+ 'years_active',
581
+ 'id:musicbrainz'])
582
+ expect(artist.foreign_ids).to be_an Array
583
+ expect(artist.foreign_ids.first.foreign_id).to eq 'musicbrainz:artist:a74b1b7f-71a5-4011-9441-d0b5e4122711'
584
+ end
585
+
586
+ it 'returns an artist with years active' do
587
+ artist = @client.artist_profile(:id => 'ARH6W4X1187B99274F',
588
+ :bucket => ['artist_location',
589
+ 'biographies',
590
+ 'blogs',
591
+ 'doc_counts',
592
+ 'familiarity',
593
+ 'hotttnesss',
594
+ 'images',
595
+ 'news',
596
+ 'songs',
597
+ 'reviews',
598
+ 'terms',
599
+ 'urls',
600
+ 'video',
601
+ 'years_active',
602
+ 'id:musicbrainz'])
603
+ expect(artist.years_active).to be_an Array
604
+ expect(artist.years_active.first.start).to eq 1985
605
+ end
606
+
607
+ end
608
+
609
+ describe '#artist_reviews' do
610
+ before do
611
+ stub_get("/api/v4/artist/reviews").
612
+ with(:query => {:id => 'ARH6W4X1187B99274F'}).
613
+ to_return(:body => fixture("artist/reviews.json"),
614
+ :headers => {:content_type => "application/json; charset=utf-8"})
615
+ end
616
+
617
+ it "requests the correct resource" do
618
+ @client.artist_reviews(:id => 'ARH6W4X1187B99274F')
619
+ expect(a_get("/api/v4/artist/reviews").
620
+ with(:query => {:id => 'ARH6W4X1187B99274F'})).
621
+ to have_been_made
622
+ end
623
+
624
+ it "returns reviews" do
625
+ reviews = @client.artist_reviews(:id => 'ARH6W4X1187B99274F')
626
+ expect(reviews).to be_an Array
627
+ expect(reviews.first.id).to eq '3f9fca724678df56f34845365110c511'
628
+ end
629
+ end
630
+
631
+ describe "#artist_search" do
632
+
633
+ before do
634
+ stub_get("/api/v4/artist/search").
635
+ with(:query => {
636
+ :results => 1,
637
+ :name => 'radiohead'}).
638
+ to_return(:body => fixture("artist/search.json"),
639
+ :headers => {:content_type => "application/json; charset=utf-8"})
640
+ end
641
+
642
+ it "requests the correct resource" do
643
+ @client.artist_search(:results => 1,
644
+ :name => 'radiohead')
645
+ expect(a_get("/api/v4/artist/search")
646
+ .with(:query => {:results => 1,
647
+ :name => 'radiohead'}))
648
+ .to have_been_made
649
+ end
650
+
651
+ it "returns artists" do
652
+ artists = @client.artist_search(:results => 1,
653
+ :name => 'radiohead')
654
+ expect(artists).to be_an Array
655
+ expect(artists.first.name).to eq "Radiohead"
656
+ end
657
+
658
+ end
659
+
660
+ describe '#artist_songs' do
661
+ before do
662
+ stub_get("/api/v4/artist/songs").
663
+ with(:query => {:id => 'ARH6W4X1187B99274F'}).
664
+ to_return(:body => fixture("artist/songs.json"),
665
+ :headers => {:content_type => "application/json; charset=utf-8"})
666
+ end
667
+
668
+ it "requests the correct resource" do
669
+ @client.artist_songs(:id => 'ARH6W4X1187B99274F')
670
+ expect(a_get("/api/v4/artist/songs").
671
+ with(:query => {:id => 'ARH6W4X1187B99274F'})).
672
+ to have_been_made
673
+ end
674
+
675
+ it "returns songs" do
676
+ songs = @client.artist_songs(:id => 'ARH6W4X1187B99274F')
677
+ expect(songs).to be_an Array
678
+ expect(songs.first.title).to eq 'Give Up The Ghost (Brokenchord RMX)'
679
+ end
680
+ end
681
+
682
+ describe "#artist_similar" do
683
+
684
+ before do
685
+ stub_get("/api/v4/artist/similar").
686
+ with(:query => {
687
+ :results => 1,
688
+ :name => 'radiohead'}).
689
+ to_return(:body => fixture("artist/similar.json"),
690
+ :headers => {:content_type => "application/json; charset=utf-8"})
691
+ end
692
+
693
+ it "requests the correct resource" do
694
+ @client.artist_similar(:results => 1,
695
+ :name => 'radiohead')
696
+ expect(a_get("/api/v4/artist/similar")
697
+ .with(:query => {:results => 1,
698
+ :name => 'radiohead'}))
699
+ .to have_been_made
700
+ end
701
+
702
+ it "returns artists" do
703
+ artists = @client.artist_similar(:results => 1,
704
+ :name => 'radiohead')
705
+ expect(artists).to be_an Array
706
+ expect(artists.first.name).to eq "Thom Yorke"
707
+ end
708
+
709
+ end
710
+
711
+ describe "#artist_suggest" do
712
+
713
+ before do
714
+ stub_get("/api/v4/artist/suggest").
715
+ with(:query => {
716
+ :results => 1,
717
+ :name => 'radioh'}).
718
+ to_return(:body => fixture("artist/suggest.json"),
719
+ :headers => {:content_type => "application/json; charset=utf-8"})
720
+ end
721
+
722
+ it "requests the correct resource" do
723
+ @client.artist_suggest(:results => 1,
724
+ :name => 'radioh')
725
+ expect(a_get("/api/v4/artist/suggest")
726
+ .with(:query => {:results => 1,
727
+ :name => 'radioh'}))
728
+ .to have_been_made
729
+ end
730
+
731
+ it "returns artists" do
732
+ artists = @client.artist_suggest(:results => 1,
733
+ :name => 'radioh')
734
+ expect(artists).to be_an Array
735
+ expect(artists.first.name).to eq "Radiohead"
736
+ end
737
+
738
+ end
739
+
740
+ describe "#artist_terms" do
741
+
742
+ before do
743
+ stub_get("/api/v4/artist/terms").
744
+ with(:query => {
745
+ :results => 1,
746
+ :name => 'radiohead'}).
747
+ to_return(:body => fixture("artist/terms.json"),
748
+ :headers => {:content_type => "application/json; charset=utf-8"})
749
+ end
750
+
751
+ it "requests the correct resource" do
752
+ @client.artist_terms(:results => 1,
753
+ :name => 'radiohead')
754
+ expect(a_get("/api/v4/artist/terms")
755
+ .with(:query => {:results => 1,
756
+ :name => 'radiohead'}))
757
+ .to have_been_made
758
+ end
759
+
760
+ it "returns artists" do
761
+ terms = @client.artist_terms(:results => 1,
762
+ :name => 'radiohead')
763
+ expect(terms).to be_an Array
764
+ expect(terms.first.name).to eq "rock"
765
+ end
766
+
767
+ end
768
+
769
+ describe "#artist_top_hottt" do
770
+
771
+ before do
772
+ stub_get("/api/v4/artist/top_hottt").
773
+ with(:query => {
774
+ :results => 1,
775
+ :genre => 'dance'}).
776
+ to_return(:body => fixture("artist/top_hottt.json"),
777
+ :headers => {:content_type => "application/json; charset=utf-8"})
778
+ end
779
+
780
+ it "requests the correct resource" do
781
+ @client.artist_top_hottt(:results => 1,
782
+ :genre => 'dance')
783
+ expect(a_get("/api/v4/artist/top_hottt")
784
+ .with(:query => {:results => 1,
785
+ :genre => 'dance'}))
786
+ .to have_been_made
787
+ end
788
+
789
+ it "returns artists" do
790
+ artists = @client.artist_top_hottt(:results => 1,
791
+ :genre => 'dance')
792
+ expect(artists).to be_an Array
793
+ expect(artists.first.name).to eq "Justin Timberlake"
794
+ end
795
+
796
+ end
797
+
798
+ describe "#artist_top_terms" do
799
+
800
+ before do
801
+ stub_get("/api/v4/artist/top_terms").
802
+ with(:query => {
803
+ :results => 100}).
804
+ to_return(:body => fixture("artist/top_terms.json"),
805
+ :headers => {:content_type => "application/json; charset=utf-8"})
806
+ end
807
+
808
+ it "requests the correct resource" do
809
+ @client.artist_top_terms(:results => 100)
810
+ expect(a_get("/api/v4/artist/top_terms")
811
+ .with(:query => {:results => 100}))
812
+ .to have_been_made
813
+ end
814
+
815
+ it "returns terms" do
816
+ terms = @client.artist_top_terms(:results => 100)
817
+ expect(terms).to be_an Array
818
+ expect(terms.first.name).to eq "rock"
819
+ end
820
+
821
+ end
822
+
823
+ describe "#artist_twitter" do
824
+
825
+ before do
826
+ stub_get("/api/v4/artist/twitter").
827
+ with(:query => {
828
+ :results => 1,
829
+ :name => 'radiohead'}).
830
+ to_return(:body => fixture("artist/twitter.json"),
831
+ :headers => {:content_type => "application/json; charset=utf-8"})
832
+ end
833
+
834
+ it "requests the correct resource" do
835
+ @client.artist_twitter(:results => 1,
836
+ :name => 'radiohead')
837
+ expect(a_get("/api/v4/artist/twitter")
838
+ .with(:query => {:results => 1,
839
+ :name => 'radiohead'}))
840
+ .to have_been_made
841
+ end
842
+
843
+ it "returns an artist" do
844
+ artist = @client.artist_twitter(:results => 1,
845
+ :name => 'radiohead')
846
+ expect(artist).to be_an Echowrap::Artist
847
+ expect(artist.twitter).to eq "radiohead"
848
+ end
849
+
850
+ end
851
+
852
+ describe "#artist_urls" do
853
+
854
+ before do
855
+ stub_get("/api/v4/artist/urls").
856
+ with(:query => {
857
+ :name => 'radiohead'}).
858
+ to_return(:body => fixture("artist/urls.json"),
859
+ :headers => {:content_type => "application/json; charset=utf-8"})
860
+ end
861
+
862
+ it "requests the correct resource" do
863
+ @client.artist_urls(:name => 'radiohead')
864
+ expect(a_get("/api/v4/artist/urls")
865
+ .with(:query => {
866
+ :name => 'radiohead'}))
867
+ .to have_been_made
868
+ end
869
+
870
+ it "returns urls" do
871
+ urls = @client.artist_urls(
872
+ :name => 'radiohead')
873
+ expect(urls).to be_an Echowrap::Urls
874
+ expect(urls.lastfm_url).to eq "http://www.last.fm/music/Radiohead"
875
+ end
876
+
877
+ end
878
+
879
+ describe '#artist_video' do
880
+ before do
881
+ stub_get("/api/v4/artist/video").
882
+ with(:query => {:id => 'ARH6W4X1187B99274F'}).
883
+ to_return(:body => fixture("artist/video.json"),
884
+ :headers => {:content_type => "application/json; charset=utf-8"})
885
+ end
886
+
887
+ it "requests the correct resource" do
888
+ @client.artist_video(:id => 'ARH6W4X1187B99274F')
889
+ expect(a_get("/api/v4/artist/video").
890
+ with(:query => {:id => 'ARH6W4X1187B99274F'})).
891
+ to have_been_made
892
+ end
893
+
894
+ it "returns video" do
895
+ video= @client.artist_video(:id => 'ARH6W4X1187B99274F')
896
+ expect(video).to be_an Array
897
+ expect(video.first.title).to eq 'Radiohead - Inside My Head (with lyrics)'
898
+ end
899
+ end
900
+ end
901
+