musicbrainz 0.7.7 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/test.yml +26 -0
  3. data/.gitignore +2 -2
  4. data/Gemfile +11 -0
  5. data/Gemfile.lock +54 -0
  6. data/LICENSE +2 -2
  7. data/README.md +21 -10
  8. data/lib/musicbrainz/bindings/artist.rb +0 -1
  9. data/lib/musicbrainz/bindings/artist_search.rb +0 -1
  10. data/lib/musicbrainz/bindings/discid_releases.rb +13 -0
  11. data/lib/musicbrainz/bindings/recording.rb +19 -0
  12. data/lib/musicbrainz/bindings/{track_search.rb → recording_search.rb} +1 -2
  13. data/lib/musicbrainz/bindings/relations.rb +1 -2
  14. data/lib/musicbrainz/bindings/release_group_search.rb +0 -1
  15. data/lib/musicbrainz/client_modules/caching_proxy.rb +27 -13
  16. data/lib/musicbrainz/models/base_model.rb +12 -2
  17. data/lib/musicbrainz/models/recording.rb +20 -0
  18. data/lib/musicbrainz/models/release.rb +8 -1
  19. data/lib/musicbrainz/models/track.rb +0 -4
  20. data/lib/musicbrainz/version.rb +1 -1
  21. data/lib/musicbrainz.rb +4 -1
  22. data/musicbrainz.gemspec +3 -6
  23. data/spec/bindings/recording_search_spec.rb +48 -0
  24. data/spec/bindings/relations_spec.rb +45 -26
  25. data/spec/bindings/release_group_search_spec.rb +24 -6
  26. data/spec/bindings/release_spec.rb +94 -18
  27. data/spec/client_modules/cache_spec.rb +18 -17
  28. data/spec/deprecated/cache_config_spec.rb +4 -6
  29. data/spec/deprecated/proxy_config_spec.rb +4 -6
  30. data/spec/fixtures/artist/find_69b39eab-6577-46a4-a9f5-817839092033.xml +168 -0
  31. data/spec/fixtures/artist/release_groups_69b39eab-6577-46a4-a9f5-817839092033.xml +412 -0
  32. data/spec/fixtures/artist/search_kasabian.xml +104 -0
  33. data/spec/fixtures/recording/find_b3015bab-1540-4d4e-9f30-14872a1525f7.xml +8 -0
  34. data/spec/fixtures/recording/search_bound_for_the_floor_local_h.xml +647 -0
  35. data/spec/fixtures/release/find_2225dd4c-ae9a-403b-8ea0-9e05014c778f.xml +44 -0
  36. data/spec/fixtures/release/find_2225dd4c-ae9a-403b-8ea0-9e05014c778f_tracks.xml +151 -0
  37. data/spec/fixtures/release/find_b94cb547-cf7a-4357-894c-53c3bf33b093.xml +52 -0
  38. data/spec/fixtures/release/find_by_discid_pmzhT6ZlFiwSRCdVwV0eqire5_Y-.xml +141 -0
  39. data/spec/fixtures/release/list_6f33e0f0-cde2-38f9-9aee-2c60af8d1a61.xml +344 -0
  40. data/spec/fixtures/release_group/search_kasabian_empire_album.xml +117 -0
  41. data/spec/models/artist_spec.rb +77 -46
  42. data/spec/models/base_model_spec.rb +50 -22
  43. data/spec/models/recording_spec.rb +42 -0
  44. data/spec/models/release_group_spec.rb +61 -55
  45. data/spec/models/release_spec.rb +63 -28
  46. data/spec/models/track_spec.rb +19 -15
  47. data/spec/spec_helper.rb +7 -7
  48. data/spec/support/mock_helpers.rb +13 -0
  49. metadata +55 -93
  50. data/.rspec +0 -1
  51. data/.travis.yml +0 -4
  52. data/spec/bindings/track_search_spec.rb +0 -17
  53. data/spec/fixtures/artist/search.xml +0 -67
  54. data/spec/fixtures/kasabian.xml +0 -1
  55. data/spec/fixtures/release/list.xml +0 -344
  56. /data/spec/fixtures/release_group/{entity.xml → find_6f33e0f0-cde2-38f9-9aee-2c60af8d1a61.xml} +0 -0
  57. /data/spec/fixtures/release_group/{search.xml → search_kasabian_empire.xml} +0 -0
@@ -0,0 +1,344 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#">
3
+ <release-list count="8">
4
+ <release id="123eff45-b875-4aab-b659-fb6996691db6">
5
+ <title>Empire</title>
6
+ <status>Official</status>
7
+ <quality>normal</quality>
8
+ <packaging>Jewel Case</packaging>
9
+ <text-representation>
10
+ <language>eng</language>
11
+ <script>Latn</script>
12
+ </text-representation>
13
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
14
+ <title>Empire</title>
15
+ <first-release-date>2006-08-28</first-release-date>
16
+ <primary-type>Album</primary-type>
17
+ </release-group>
18
+ <date>2006</date>
19
+ <country>XE</country>
20
+ <release-event-list count="1">
21
+ <release-event>
22
+ <date>2006</date>
23
+ <area id="89a675c2-3e37-3518-b83c-418bad59a85a">
24
+ <name>Europe</name>
25
+ <sort-name>Europe</sort-name>
26
+ <iso-3166-1-code-list>
27
+ <iso-3166-1-code>XE</iso-3166-1-code>
28
+ </iso-3166-1-code-list>
29
+ </area>
30
+ </release-event>
31
+ </release-event-list>
32
+ <barcode>828768934227</barcode>
33
+ <cover-art-archive>
34
+ <artwork>false</artwork>
35
+ <count>0</count>
36
+ <front>false</front>
37
+ <back>false</back>
38
+ </cover-art-archive>
39
+ <medium-list count="1">
40
+ <medium>
41
+ <position>1</position>
42
+ <format>CD</format>
43
+ <track-list count="11" />
44
+ </medium>
45
+ </medium-list>
46
+ </release>
47
+ <release id="2225dd4c-ae9a-403b-8ea0-9e05014c778f">
48
+ <title>Empire</title>
49
+ <status>Official</status>
50
+ <quality>normal</quality>
51
+ <text-representation>
52
+ <language>eng</language>
53
+ <script>Latn</script>
54
+ </text-representation>
55
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
56
+ <title>Empire</title>
57
+ <first-release-date>2006-08-28</first-release-date>
58
+ <primary-type>Album</primary-type>
59
+ </release-group>
60
+ <date>2006-08-28</date>
61
+ <country>GB</country>
62
+ <release-event-list count="1">
63
+ <release-event>
64
+ <date>2006-08-28</date>
65
+ <area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
66
+ <name>United Kingdom</name>
67
+ <sort-name>United Kingdom</sort-name>
68
+ <iso-3166-1-code-list>
69
+ <iso-3166-1-code>GB</iso-3166-1-code>
70
+ </iso-3166-1-code-list>
71
+ </area>
72
+ </release-event>
73
+ </release-event-list>
74
+ <asin>B000H49P28</asin>
75
+ <cover-art-archive>
76
+ <artwork>false</artwork>
77
+ <count>0</count>
78
+ <front>false</front>
79
+ <back>false</back>
80
+ </cover-art-archive>
81
+ <medium-list count="1">
82
+ <medium>
83
+ <position>1</position>
84
+ <track-list count="11" />
85
+ </medium>
86
+ </medium-list>
87
+ </release>
88
+ <release id="2bc94ddc-b872-3b7f-b0a7-98a4fffbe5ba">
89
+ <title>Empire</title>
90
+ <status>Official</status>
91
+ <quality>normal</quality>
92
+ <text-representation>
93
+ <language>eng</language>
94
+ <script>Latn</script>
95
+ </text-representation>
96
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
97
+ <title>Empire</title>
98
+ <first-release-date>2006-08-28</first-release-date>
99
+ <primary-type>Album</primary-type>
100
+ </release-group>
101
+ <date>2006-09-19</date>
102
+ <country>US</country>
103
+ <release-event-list count="1">
104
+ <release-event>
105
+ <date>2006-09-19</date>
106
+ <area id="489ce91b-6658-3307-9877-795b68554c98">
107
+ <name>United States</name>
108
+ <sort-name>United States</sort-name>
109
+ <iso-3166-1-code-list>
110
+ <iso-3166-1-code>US</iso-3166-1-code>
111
+ </iso-3166-1-code-list>
112
+ </area>
113
+ </release-event>
114
+ </release-event-list>
115
+ <barcode>828768832325</barcode>
116
+ <asin>B000HEVYQS</asin>
117
+ <cover-art-archive>
118
+ <artwork>false</artwork>
119
+ <count>0</count>
120
+ <front>false</front>
121
+ <back>false</back>
122
+ </cover-art-archive>
123
+ <medium-list count="1">
124
+ <medium>
125
+ <position>1</position>
126
+ <format>CD</format>
127
+ <track-list count="11" />
128
+ </medium>
129
+ </medium-list>
130
+ </release>
131
+ <release id="2c8dcfc6-4afe-4b33-abc7-dff1bb4c5386">
132
+ <title>Empire</title>
133
+ <status>Official</status>
134
+ <quality>normal</quality>
135
+ <text-representation>
136
+ <language>eng</language>
137
+ <script>Latn</script>
138
+ </text-representation>
139
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
140
+ <title>Empire</title>
141
+ <first-release-date>2006-08-28</first-release-date>
142
+ <primary-type>Album</primary-type>
143
+ </release-group>
144
+ <date>2006-09-22</date>
145
+ <country>XW</country>
146
+ <release-event-list count="1">
147
+ <release-event>
148
+ <date>2006-09-22</date>
149
+ <area id="525d4e18-3d00-31b9-a58b-a146a916de8f">
150
+ <name>[Worldwide]</name>
151
+ <sort-name>[Worldwide]</sort-name>
152
+ <iso-3166-1-code-list>
153
+ <iso-3166-1-code>XW</iso-3166-1-code>
154
+ </iso-3166-1-code-list>
155
+ </area>
156
+ </release-event>
157
+ </release-event-list>
158
+ <cover-art-archive>
159
+ <artwork>false</artwork>
160
+ <count>0</count>
161
+ <front>false</front>
162
+ <back>false</back>
163
+ </cover-art-archive>
164
+ <medium-list count="1">
165
+ <medium>
166
+ <position>1</position>
167
+ <format>Digital Media</format>
168
+ <track-list count="12" />
169
+ </medium>
170
+ </medium-list>
171
+ </release>
172
+ <release id="30d5e730-ce0a-464d-93e1-7d76e4bb3e31">
173
+ <title>Empire</title>
174
+ <status>Official</status>
175
+ <quality>normal</quality>
176
+ <text-representation>
177
+ <language>eng</language>
178
+ <script>Latn</script>
179
+ </text-representation>
180
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
181
+ <title>Empire</title>
182
+ <first-release-date>2006-08-28</first-release-date>
183
+ <primary-type>Album</primary-type>
184
+ </release-group>
185
+ <date>2006-08-28</date>
186
+ <country>GB</country>
187
+ <release-event-list count="1">
188
+ <release-event>
189
+ <date>2006-08-28</date>
190
+ <area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
191
+ <name>United Kingdom</name>
192
+ <sort-name>United Kingdom</sort-name>
193
+ <iso-3166-1-code-list>
194
+ <iso-3166-1-code>GB</iso-3166-1-code>
195
+ </iso-3166-1-code-list>
196
+ </area>
197
+ </release-event>
198
+ </release-event-list>
199
+ <barcode>828768849927</barcode>
200
+ <asin>B000H49P28</asin>
201
+ <cover-art-archive>
202
+ <artwork>false</artwork>
203
+ <count>0</count>
204
+ <front>false</front>
205
+ <back>false</back>
206
+ </cover-art-archive>
207
+ <medium-list count="1">
208
+ <medium>
209
+ <position>1</position>
210
+ <format>CD</format>
211
+ <track-list count="11" />
212
+ </medium>
213
+ </medium-list>
214
+ </release>
215
+ <release id="36ee86ab-0450-4d8f-a970-183c11f210c1">
216
+ <title>Empire</title>
217
+ <status>Official</status>
218
+ <quality>normal</quality>
219
+ <packaging>Jewel Case</packaging>
220
+ <text-representation>
221
+ <language>eng</language>
222
+ <script>Latn</script>
223
+ </text-representation>
224
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
225
+ <title>Empire</title>
226
+ <first-release-date>2006-08-28</first-release-date>
227
+ <primary-type>Album</primary-type>
228
+ </release-group>
229
+ <date>2006</date>
230
+ <country>GB</country>
231
+ <release-event-list count="1">
232
+ <release-event>
233
+ <date>2006</date>
234
+ <area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
235
+ <name>United Kingdom</name>
236
+ <sort-name>United Kingdom</sort-name>
237
+ <iso-3166-1-code-list>
238
+ <iso-3166-1-code>GB</iso-3166-1-code>
239
+ </iso-3166-1-code-list>
240
+ </area>
241
+ </release-event>
242
+ </release-event-list>
243
+ <barcode>828768934227</barcode>
244
+ <cover-art-archive>
245
+ <artwork>false</artwork>
246
+ <count>0</count>
247
+ <front>false</front>
248
+ <back>false</back>
249
+ </cover-art-archive>
250
+ <medium-list count="1">
251
+ <medium>
252
+ <position>1</position>
253
+ <format>CD</format>
254
+ <track-list count="11" />
255
+ </medium>
256
+ </medium-list>
257
+ </release>
258
+ <release id="9f068ed6-9f69-4a60-bf5a-0931176a9aba">
259
+ <title>Empire</title>
260
+ <status>Official</status>
261
+ <quality>normal</quality>
262
+ <text-representation>
263
+ <language>eng</language>
264
+ <script>Latn</script>
265
+ </text-representation>
266
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
267
+ <title>Empire</title>
268
+ <first-release-date>2006-08-28</first-release-date>
269
+ <primary-type>Album</primary-type>
270
+ </release-group>
271
+ <date>2006-12-20</date>
272
+ <country>JP</country>
273
+ <release-event-list count="1">
274
+ <release-event>
275
+ <date>2006-12-20</date>
276
+ <area id="2db42837-c832-3c27-b4a3-08198f75693c">
277
+ <name>Japan</name>
278
+ <sort-name>Japan</sort-name>
279
+ <iso-3166-1-code-list>
280
+ <iso-3166-1-code>JP</iso-3166-1-code>
281
+ </iso-3166-1-code-list>
282
+ </area>
283
+ </release-event>
284
+ </release-event-list>
285
+ <barcode>4988017645901</barcode>
286
+ <asin>B000K2QL9W</asin>
287
+ <cover-art-archive>
288
+ <artwork>false</artwork>
289
+ <count>0</count>
290
+ <front>false</front>
291
+ <back>false</back>
292
+ </cover-art-archive>
293
+ <medium-list count="1">
294
+ <medium>
295
+ <position>1</position>
296
+ <format>CD</format>
297
+ <track-list count="16" />
298
+ </medium>
299
+ </medium-list>
300
+ </release>
301
+ <release id="dd34af03-37ab-460a-b20a-54629336d81a">
302
+ <title>Empire</title>
303
+ <status>Official</status>
304
+ <quality>normal</quality>
305
+ <packaging>Jewel Case</packaging>
306
+ <text-representation>
307
+ <language>eng</language>
308
+ <script>Latn</script>
309
+ </text-representation>
310
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
311
+ <title>Empire</title>
312
+ <first-release-date>2006-08-28</first-release-date>
313
+ <primary-type>Album</primary-type>
314
+ </release-group>
315
+ <date>2006-12-18</date>
316
+ <country>GB</country>
317
+ <release-event-list count="1">
318
+ <release-event>
319
+ <date>2006-12-18</date>
320
+ <area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
321
+ <name>United Kingdom</name>
322
+ <sort-name>United Kingdom</sort-name>
323
+ <iso-3166-1-code-list>
324
+ <iso-3166-1-code>GB</iso-3166-1-code>
325
+ </iso-3166-1-code-list>
326
+ </area>
327
+ </release-event>
328
+ </release-event-list>
329
+ <cover-art-archive>
330
+ <artwork>true</artwork>
331
+ <count>1</count>
332
+ <front>true</front>
333
+ <back>false</back>
334
+ </cover-art-archive>
335
+ <medium-list count="1">
336
+ <medium>
337
+ <position>1</position>
338
+ <format>Digital Media</format>
339
+ <track-list count="16" />
340
+ </medium>
341
+ </medium-list>
342
+ </release>
343
+ </release-list>
344
+ </metadata>
@@ -0,0 +1,117 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <metadata created="2024-03-20T21:10:40.204Z" xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ns2="http://musicbrainz.org/ns/ext#-2.0">
3
+ <release-group-list count="2" offset="0">
4
+ <release-group id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61" ns2:score="100" type="Album" type-id="f529b476-6e62-324f-b0aa-1f3e33d313fc">
5
+ <title>Empire</title>
6
+ <first-release-date>2006-08-25</first-release-date>
7
+ <primary-type id="f529b476-6e62-324f-b0aa-1f3e33d313fc">Album</primary-type>
8
+ <artist-credit>
9
+ <name-credit>
10
+ <name>Kasabian</name>
11
+ <artist id="69b39eab-6577-46a4-a9f5-817839092033">
12
+ <name>Kasabian</name>
13
+ <sort-name>Kasabian</sort-name>
14
+ </artist>
15
+ </name-credit>
16
+ </artist-credit>
17
+ <release-list count="14">
18
+ <release id="1f5bb929-fd6a-43a2-b4ab-90a9344d528a">
19
+ <title>Empire</title>
20
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
21
+ </release>
22
+ <release id="2daac42a-ed43-49cd-aa92-1c42206d3258">
23
+ <title>Empire</title>
24
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
25
+ </release>
26
+ <release id="2bc94ddc-b872-3b7f-b0a7-98a4fffbe5ba">
27
+ <title>Empire</title>
28
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
29
+ </release>
30
+ <release id="bc5979d9-6f3a-4fdd-9cb2-07e883baa140">
31
+ <title>Empire</title>
32
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
33
+ </release>
34
+ <release id="097ac0ff-6d56-4e66-932f-99f3b4c390d0">
35
+ <title>Empire</title>
36
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
37
+ </release>
38
+ <release id="36ee86ab-0450-4d8f-a970-183c11f210c1">
39
+ <title>Empire</title>
40
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
41
+ </release>
42
+ <release id="2225dd4c-ae9a-403b-8ea0-9e05014c778f">
43
+ <title>Empire</title>
44
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
45
+ </release>
46
+ <release id="30d5e730-ce0a-464d-93e1-7d76e4bb3e31">
47
+ <title>Empire</title>
48
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
49
+ </release>
50
+ <release id="2c8dcfc6-4afe-4b33-abc7-dff1bb4c5386">
51
+ <title>Empire</title>
52
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
53
+ </release>
54
+ <release id="9f068ed6-9f69-4a60-bf5a-0931176a9aba">
55
+ <title>Empire</title>
56
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
57
+ </release>
58
+ <release id="dd34af03-37ab-460a-b20a-54629336d81a">
59
+ <title>Empire</title>
60
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
61
+ </release>
62
+ <release id="123eff45-b875-4aab-b659-fb6996691db6">
63
+ <title>Empire</title>
64
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
65
+ </release>
66
+ <release id="c90a61c7-b25b-4aa9-bd8e-d036283fd1c0">
67
+ <title>Empire</title>
68
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
69
+ </release>
70
+ <release id="0efa3c56-8836-49a5-8aa2-ba00d26dbb68">
71
+ <title>Empire</title>
72
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
73
+ </release>
74
+ </release-list>
75
+ <tag-list>
76
+ <tag count="5">
77
+ <name>rock</name>
78
+ </tag>
79
+ <tag count="7">
80
+ <name>alternative rock</name>
81
+ </tag>
82
+ <tag count="2">
83
+ <name>indie rock</name>
84
+ </tag>
85
+ <tag count="1">
86
+ <name>indie</name>
87
+ </tag>
88
+ <tag count="1">
89
+ <name>rock and indie</name>
90
+ </tag>
91
+ </tag-list>
92
+ </release-group>
93
+ <release-group id="6a21325a-8401-459d-891d-9d21aad2754c" ns2:score="79" type="Compilation" type-id="dd2a21e1-0c00-3729-a7a0-de60b84eb5d1">
94
+ <title>Empire / West Ryder Pauper Lunatic Asylum</title>
95
+ <first-release-date>2011</first-release-date>
96
+ <primary-type id="f529b476-6e62-324f-b0aa-1f3e33d313fc">Album</primary-type>
97
+ <secondary-type-list>
98
+ <secondary-type id="dd2a21e1-0c00-3729-a7a0-de60b84eb5d1">Compilation</secondary-type>
99
+ </secondary-type-list>
100
+ <artist-credit>
101
+ <name-credit>
102
+ <name>Kasabian</name>
103
+ <artist id="69b39eab-6577-46a4-a9f5-817839092033">
104
+ <name>Kasabian</name>
105
+ <sort-name>Kasabian</sort-name>
106
+ </artist>
107
+ </name-credit>
108
+ </artist-credit>
109
+ <release-list count="1">
110
+ <release id="d28ae1f2-cbbc-454c-a0d5-e08576c2567c">
111
+ <title>Empire / West Ryder Pauper Lunatic Asylum</title>
112
+ <status id="4e304316-386d-3409-af2e-78857eec5cfe">Official</status>
113
+ </release>
114
+ </release-list>
115
+ </release-group>
116
+ </release-group-list>
117
+ </metadata>
@@ -1,59 +1,90 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
1
  require "spec_helper"
4
2
 
5
3
  describe MusicBrainz::Artist do
6
- it "gets no exception while loading artist info" do
7
- lambda {
8
- MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033')
9
- }.should_not raise_error(Exception)
10
- end
4
+ describe '.search' do
5
+ before(:each) {
6
+ mock url: 'http://musicbrainz.org/ws/2/artist?query=artist:"Kasabian"&limit=10',
7
+ fixture: 'artist/search_kasabian.xml'
8
+ }
9
+ let(:matches) {
10
+ MusicBrainz::Artist.search('Kasabian')
11
+ }
11
12
 
12
- it "gets correct instance" do
13
- artist = MusicBrainz::Artist.find_by_name('Kasabian')
14
- artist.should be_an_instance_of(MusicBrainz::Artist)
15
- end
13
+ it "searches artist by name" do
14
+ expect(matches).to_not be_empty
15
+ expect(matches.first[:name]).to eq("Kasabian")
16
+ end
16
17
 
17
- it "searches artist by name" do
18
- matches = MusicBrainz::Artist.search('Kasabian')
19
- matches.length.should be > 0
20
- matches.first[:name].should == "Kasabian"
18
+ it "should return search results in the right order and pass back the correct score" do
19
+ expect(matches.length).to be >= 2
20
+ expect(matches[0][:score]).to eq 100
21
+ expect(matches[0][:id]).to eq "69b39eab-6577-46a4-a9f5-817839092033"
22
+ expect(matches[1][:score]).to eq 73
23
+ expect(matches[1][:id]).to eq "d76aed40-1332-44db-9b19-aee7ec17464b"
24
+ end
21
25
  end
22
26
 
23
- it "should return search results in the right order and pass back the correct score" do
24
- response = File.open(File.join(File.dirname(__FILE__), "../fixtures/artist/search.xml")).read
25
- MusicBrainz::Client.any_instance.stub(:get_contents).with('http://musicbrainz.org/ws/2/artist?query=artist:"Chris+Martin"&limit=10').
26
- and_return({ status: 200, body: response})
27
-
28
- matches = MusicBrainz::Artist.search('Chris Martin')
29
-
30
- matches[0][:score].should == 100
31
- matches[0][:id].should == "90fff570-a4ef-4cd4-ba21-e00c7261b05a"
32
- matches[1][:score].should == 100
33
- matches[1][:id].should == "b732a912-af95-472c-be52-b14610734c64"
34
- end
27
+ describe '.find' do
28
+ before(:each) {
29
+ mock url: 'http://musicbrainz.org/ws/2/artist/69b39eab-6577-46a4-a9f5-817839092033?inc=url-rels',
30
+ fixture: 'artist/find_69b39eab-6577-46a4-a9f5-817839092033.xml'
31
+ }
32
+ let(:artist) {
33
+ MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033')
34
+ }
35
35
 
36
- it "gets correct result by name" do
37
- artist = MusicBrainz::Artist.find_by_name('Kasabian')
38
- artist.id.should == "69b39eab-6577-46a4-a9f5-817839092033"
36
+ it "gets no exception while loading artist info" do
37
+ expect{ artist }.to_not raise_error(Exception)
38
+ expect(artist.id).to eq '69b39eab-6577-46a4-a9f5-817839092033'
39
+ expect(artist.name).to eq 'Kasabian'
40
+ end
39
41
  end
40
42
 
41
- it "gets correct artist data" do
42
- artist = MusicBrainz::Artist.find_by_name('Kasabian')
43
- artist.id.should == "69b39eab-6577-46a4-a9f5-817839092033"
44
- artist.type.should == "Group"
45
- artist.name.should == "Kasabian"
46
- artist.country.should == "GB"
47
- artist.date_begin.year.should == 1999
48
- end
43
+ describe '.find_by_name' do
44
+ before(:each) {
45
+ mock url: 'http://musicbrainz.org/ws/2/artist?query=artist:"Kasabian"&limit=10',
46
+ fixture: 'artist/search_kasabian.xml'
47
+ mock url: 'http://musicbrainz.org/ws/2/artist/69b39eab-6577-46a4-a9f5-817839092033?inc=url-rels',
48
+ fixture: 'artist/find_69b39eab-6577-46a4-a9f5-817839092033.xml'
49
+ }
50
+ let(:artist) {
51
+ MusicBrainz::Artist.find_by_name('Kasabian')
52
+ }
53
+
54
+ it "gets correct instance" do
55
+ expect(artist).to be_instance_of(MusicBrainz::Artist)
56
+ end
57
+
58
+ it "gets correct result by name" do
59
+ expect(artist.id).to eq "69b39eab-6577-46a4-a9f5-817839092033"
60
+ end
61
+
62
+ it "gets correct artist data" do
63
+ expect(artist.id).to eq "69b39eab-6577-46a4-a9f5-817839092033"
64
+ expect(artist.type).to eq "Group"
65
+ expect(artist.name).to eq "Kasabian"
66
+ expect(artist.country).to eq "GB"
67
+ expect(artist.date_begin.year).to eq 1997
68
+ end
69
+
70
+ describe '#release_groups' do
71
+ before(:each) {
72
+ mock url: 'http://musicbrainz.org/ws/2/release-group?artist=69b39eab-6577-46a4-a9f5-817839092033&inc=url-rels',
73
+ fixture: 'artist/release_groups_69b39eab-6577-46a4-a9f5-817839092033.xml'
74
+ }
75
+ let(:release_groups) {
76
+ artist.release_groups
77
+ }
49
78
 
50
- it "gets correct artist's release groups" do
51
- release_groups = MusicBrainz::Artist.find_by_name('Kasabian').release_groups
52
- release_groups.length.should be >= 16
53
- release_groups.first.id.should == "533cbc5f-ec7e-32ab-95f3-8d1f804a5176"
54
- release_groups.first.type.should == "Single"
55
- release_groups.first.title.should == "Club Foot"
56
- release_groups.first.first_release_date.should == Date.new(2004, 5, 10)
57
- release_groups.first.urls[:discogs].should == 'http://www.discogs.com/master/125150'
79
+ it "gets correct artist's release groups" do
80
+ release_groups = MusicBrainz::Artist.find_by_name('Kasabian').release_groups
81
+ expect(release_groups.length).to be >= 16
82
+ expect(release_groups.first.id).to eq "5547285f-578f-3236-85aa-b65cc0923b58"
83
+ expect(release_groups.first.type).to eq "Single"
84
+ expect(release_groups.first.title).to eq "Reason Is Treason"
85
+ expect(release_groups.first.first_release_date).to eq Date.new(2004, 2, 23)
86
+ expect(release_groups.first.urls[:discogs]).to eq 'https://www.discogs.com/master/125172'
87
+ end
88
+ end
58
89
  end
59
90
  end