nestling 0.1.1 → 0.1.2

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/test/test_artist.rb CHANGED
@@ -3,8 +3,6 @@ require File.join(File.dirname(__FILE__), 'helper')
3
3
  class TestArtist < MiniTest::Unit::TestCase
4
4
  include Nestling
5
5
 
6
- METHODS = Artist::METHODS
7
-
8
6
  def setup
9
7
  @collection_response = <<-EOS
10
8
  {"response": {
@@ -33,10 +31,6 @@ class TestArtist < MiniTest::Unit::TestCase
33
31
  assert_equal "song/", Song::METHOD_PREFIX
34
32
  end
35
33
 
36
- def test_number_of_methods
37
- assert_equal 19, METHODS.length
38
- end
39
-
40
34
  def test_artist_with_id
41
35
  artist = Client.new('foo').artist :id => 'foo'
42
36
  assert_equal 'foo', artist.id
@@ -59,118 +53,764 @@ class TestArtist < MiniTest::Unit::TestCase
59
53
  Client.new('foo').artist(:id => 'baz').blogs
60
54
  end
61
55
 
62
- def test_biographies
63
- assert METHODS[:biographies][:collection]
64
- assert_nil METHODS[:biographies][:key]
65
- assert @artist.respond_to?(:biographies)
56
+ def test_biographies_method
57
+ assert_respond_to @artist, :biographies
66
58
  end
67
-
68
- def test_blogs
69
- assert METHODS[:blogs][:collection]
70
- assert_nil METHODS[:blogs][:key]
71
- assert @artist.respond_to?(:blogs)
59
+
60
+ def test_biographies_returns_collection
61
+ json = <<-EOS
62
+ {"response": {
63
+ "status": {
64
+ "code": "0",
65
+ "message": "Success",
66
+ "version": "4.2"
67
+ },
68
+ "biographies": [{
69
+ "foo": "bar"
70
+ }]
71
+ }}
72
+ EOS
73
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}biographies"
74
+ response = @artist.biographies
75
+ assert_kind_of Nestling::Collection, response
76
+ assert_equal 'bar', response[0][:foo]
72
77
  end
73
-
74
- def test_familiarity
75
- refute METHODS[:familiarity][:collection]
76
- assert_equal "artist", METHODS[:familiarity][:key]
77
- assert @artist.respond_to?(:familiarity)
78
+
79
+ def test_biographies_passes_options
80
+ json = <<-EOS
81
+ {"response": {
82
+ "status": {
83
+ "code": "0",
84
+ "message": "Success",
85
+ "version": "4.2"
86
+ },
87
+ "biographies": [{
88
+ "foo": "bar"
89
+ }]
90
+ }}
91
+ EOS
92
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}biographies", { :foo => :bar, :name => 'bar' }
93
+ @artist.biographies :foo => :bar
78
94
  end
79
-
80
- def test_hotttnesss
81
- refute METHODS[:hotttnesss][:collection]
82
- assert_equal "artist", METHODS[:hotttnesss][:key]
83
- assert @artist.respond_to?(:hotttnesss)
95
+
96
+ def test_blogs_method
97
+ assert_respond_to @artist, :blogs
84
98
  end
85
-
86
- def test_images
87
- assert METHODS[:images][:collection]
88
- assert_nil METHODS[:images][:key]
89
- assert @artist.respond_to?(:images)
99
+
100
+ def test_blogs_returns_collection
101
+ json = <<-EOS
102
+ {"response": {
103
+ "status": {
104
+ "code": "0",
105
+ "message": "Success",
106
+ "version": "4.2"
107
+ },
108
+ "blogs": [{
109
+ "foo": "bar"
110
+ }]
111
+ }}
112
+ EOS
113
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}blogs"
114
+ response = @artist.blogs
115
+ assert_kind_of Nestling::Collection, response
116
+ assert_equal 'bar', response[0][:foo]
90
117
  end
91
-
92
- def test_list_terms
93
- assert METHODS[:list_terms][:collection]
94
- assert_nil METHODS[:list_terms][:key]
95
- assert @artist.respond_to?(:list_terms)
118
+
119
+ def test_blogs_passes_options
120
+ json = <<-EOS
121
+ {"response": {
122
+ "status": {
123
+ "code": "0",
124
+ "message": "Success",
125
+ "version": "4.2"
126
+ },
127
+ "blogs": [{
128
+ "foo": "bar"
129
+ }]
130
+ }}
131
+ EOS
132
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}blogs", { :foo => :bar, :name => 'bar' }
133
+ @artist.blogs :foo => :bar
96
134
  end
97
-
98
- def test_news
99
- assert METHODS[:news][:collection]
100
- assert_nil METHODS[:news][:key]
101
- assert @artist.respond_to?(:news)
135
+
136
+ def test_familiarity_method
137
+ assert_respond_to @artist, :familiarity
102
138
  end
103
-
104
- def test_profile
105
- refute METHODS[:profile][:collection]
106
- assert_equal "artist", METHODS[:profile][:key]
107
- assert @artist.respond_to?(:profile)
139
+
140
+ def test_familiarity_returns_hash
141
+ json = <<-EOS
142
+ {"response": {
143
+ "status": {
144
+ "code": "0",
145
+ "message": "Success",
146
+ "version": "4.2"
147
+ },
148
+ "artist": {
149
+ "foo": "bar"
150
+ }
151
+ }}
152
+ EOS
153
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}familiarity"
154
+ response = @artist.familiarity
155
+ assert_kind_of Nestling::Hash, response
156
+ assert_equal 'bar', response[:foo]
108
157
  end
109
-
110
- def test_reviews
111
- assert METHODS[:reviews][:collection]
112
- assert_nil METHODS[:reviews][:key]
113
- assert @artist.respond_to?(:reviews)
158
+
159
+ def test_familiarity_passes_options
160
+ json = <<-EOS
161
+ {"response": {
162
+ "status": {
163
+ "code": "0",
164
+ "message": "Success",
165
+ "version": "4.2"
166
+ },
167
+ "artist": {
168
+ "foo": "bar"
169
+ }
170
+ }}
171
+ EOS
172
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}familiarity", { :foo => :bar, :name => 'bar' }
173
+ @artist.familiarity :foo => :bar
114
174
  end
115
-
116
- def test_search
117
- assert METHODS[:search][:collection]
118
- assert_equal "artists", METHODS[:search][:key]
119
- assert @artist.respond_to?(:search)
175
+
176
+ def test_hotttnesss_method
177
+ assert_respond_to @artist, :hotttnesss
120
178
  end
121
-
122
- def test_extract
123
- assert METHODS[:extract][:collection]
124
- assert_equal "artist", METHODS[:extract][:key]
125
- assert @artist.respond_to?(:extract)
179
+
180
+ def test_hotttnesss_returns_hash
181
+ json = <<-EOS
182
+ {"response": {
183
+ "status": {
184
+ "code": "0",
185
+ "message": "Success",
186
+ "version": "4.2"
187
+ },
188
+ "artist": {
189
+ "foo": "bar"
190
+ }
191
+ }}
192
+ EOS
193
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}hotttnesss"
194
+ response = @artist.hotttnesss
195
+ assert_kind_of Nestling::Hash, response
196
+ assert_equal 'bar', response[:foo]
126
197
  end
127
-
128
- def test_songs
129
- assert METHODS[:songs][:collection]
130
- assert_nil METHODS[:songs][:key]
131
- assert @artist.respond_to?(:songs)
198
+
199
+ def test_hotttnesss_passes_options
200
+ json = <<-EOS
201
+ {"response": {
202
+ "status": {
203
+ "code": "0",
204
+ "message": "Success",
205
+ "version": "4.2"
206
+ },
207
+ "artist": {
208
+ "foo": "bar"
209
+ }
210
+ }}
211
+ EOS
212
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}hotttnesss", { :foo => :bar, :name => 'bar' }
213
+ @artist.hotttnesss :foo => :bar
132
214
  end
133
-
134
- def test_similar
135
- assert METHODS[:similar][:collection]
136
- assert_equal "artists", METHODS[:similar][:key]
137
- assert @artist.respond_to?(:similar)
215
+
216
+ def test_images_method
217
+ assert_respond_to @artist, :images
138
218
  end
139
-
140
- def test_suggest
141
- assert METHODS[:suggest][:collection]
142
- assert_equal "artists", METHODS[:suggest][:key]
143
- assert @artist.respond_to?(:suggest)
219
+
220
+ def test_images_returns_collection
221
+ json = <<-EOS
222
+ {"response": {
223
+ "status": {
224
+ "code": "0",
225
+ "message": "Success",
226
+ "version": "4.2"
227
+ },
228
+ "images": [{
229
+ "foo": "bar"
230
+ }]
231
+ }}
232
+ EOS
233
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}images"
234
+ response = @artist.images
235
+ assert_kind_of Nestling::Collection, response
236
+ assert_equal 'bar', response[0][:foo]
144
237
  end
145
-
146
- def test_terms
147
- assert METHODS[:terms][:collection]
148
- assert_nil METHODS[:terms][:key]
149
- assert @artist.respond_to?(:terms)
238
+
239
+ def test_images_passes_options
240
+ json = <<-EOS
241
+ {"response": {
242
+ "status": {
243
+ "code": "0",
244
+ "message": "Success",
245
+ "version": "4.2"
246
+ },
247
+ "images": [{
248
+ "foo": "bar"
249
+ }]
250
+ }}
251
+ EOS
252
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}images", { :foo => :bar, :name => 'bar' }
253
+ @artist.images :foo => :bar
150
254
  end
151
-
152
- def test_top_hottt
153
- assert METHODS[:top_hottt][:collection]
154
- assert_equal "artists", METHODS[:top_hottt][:key]
155
- assert @artist.respond_to?(:top_hottt)
255
+
256
+ def test_list_terms_method
257
+ assert_respond_to @artist, :list_terms
156
258
  end
157
-
158
- def test_top_terms
159
- assert METHODS[:top_terms][:collection]
160
- assert_equal "terms", METHODS[:top_terms][:key]
161
- assert @artist.respond_to?(:top_terms)
259
+
260
+ def test_list_terms_returns_collection
261
+ json = <<-EOS
262
+ {"response": {
263
+ "status": {
264
+ "code": "0",
265
+ "message": "Success",
266
+ "version": "4.2"
267
+ },
268
+ "list_terms": [{
269
+ "foo": "bar"
270
+ }]
271
+ }}
272
+ EOS
273
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}list_terms"
274
+ response = @artist.list_terms
275
+ assert_kind_of Nestling::Collection, response
276
+ assert_equal 'bar', response[0][:foo]
162
277
  end
163
-
164
- def test_urls
165
- refute METHODS[:urls][:collection]
166
- assert_nil METHODS[:urls][:key]
167
- assert @artist.respond_to?(:urls)
278
+
279
+ def test_list_terms_passes_options
280
+ json = <<-EOS
281
+ {"response": {
282
+ "status": {
283
+ "code": "0",
284
+ "message": "Success",
285
+ "version": "4.2"
286
+ },
287
+ "list_terms": [{
288
+ "foo": "bar"
289
+ }]
290
+ }}
291
+ EOS
292
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}list_terms", { :foo => :bar, :name => 'bar' }
293
+ @artist.list_terms :foo => :bar
168
294
  end
169
-
170
- def test_video
171
- assert METHODS[:video][:collection]
172
- assert_nil METHODS[:video][:key]
173
- assert @artist.respond_to?(:video)
295
+
296
+ def test_news_method
297
+ assert_respond_to @artist, :news
298
+ end
299
+
300
+ def test_news_returns_collection
301
+ json = <<-EOS
302
+ {"response": {
303
+ "status": {
304
+ "code": "0",
305
+ "message": "Success",
306
+ "version": "4.2"
307
+ },
308
+ "news": [{
309
+ "foo": "bar"
310
+ }]
311
+ }}
312
+ EOS
313
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}news"
314
+ response = @artist.news
315
+ assert_kind_of Nestling::Collection, response
316
+ assert_equal 'bar', response[0][:foo]
317
+ end
318
+
319
+ def test_news_passes_options
320
+ json = <<-EOS
321
+ {"response": {
322
+ "status": {
323
+ "code": "0",
324
+ "message": "Success",
325
+ "version": "4.2"
326
+ },
327
+ "news": [{
328
+ "foo": "bar"
329
+ }]
330
+ }}
331
+ EOS
332
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}news", { :foo => :bar, :name => 'bar' }
333
+ @artist.news :foo => :bar
334
+ end
335
+
336
+ def test_profile_method
337
+ assert_respond_to @artist, :profile
338
+ end
339
+
340
+ def test_profile_returns_hash
341
+ json = <<-EOS
342
+ {"response": {
343
+ "status": {
344
+ "code": "0",
345
+ "message": "Success",
346
+ "version": "4.2"
347
+ },
348
+ "artist": {
349
+ "foo": "bar"
350
+ }
351
+ }}
352
+ EOS
353
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}profile"
354
+ response = @artist.profile
355
+ assert_kind_of Nestling::Hash, response
356
+ assert_equal 'bar', response[:foo]
357
+ end
358
+
359
+ def test_profile_passes_options
360
+ json = <<-EOS
361
+ {"response": {
362
+ "status": {
363
+ "code": "0",
364
+ "message": "Success",
365
+ "version": "4.2"
366
+ },
367
+ "artist": {
368
+ "foo": "bar"
369
+ }
370
+ }}
371
+ EOS
372
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}profile", { :foo => :bar, :name => 'bar' }
373
+ @artist.profile :foo => :bar
374
+ end
375
+
376
+ def test_reviews_method
377
+ assert_respond_to @artist, :reviews
378
+ end
379
+
380
+ def test_reviews_returns_collection
381
+ json = <<-EOS
382
+ {"response": {
383
+ "status": {
384
+ "code": "0",
385
+ "message": "Success",
386
+ "version": "4.2"
387
+ },
388
+ "reviews": [{
389
+ "foo": "bar"
390
+ }]
391
+ }}
392
+ EOS
393
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}reviews"
394
+ response = @artist.reviews
395
+ assert_kind_of Nestling::Collection, response
396
+ assert_equal 'bar', response[0][:foo]
397
+ end
398
+
399
+ def test_reviews_passes_options
400
+ json = <<-EOS
401
+ {"response": {
402
+ "status": {
403
+ "code": "0",
404
+ "message": "Success",
405
+ "version": "4.2"
406
+ },
407
+ "reviews": [{
408
+ "foo": "bar"
409
+ }]
410
+ }}
411
+ EOS
412
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}reviews", { :foo => :bar, :name => 'bar' }
413
+ @artist.reviews :foo => :bar
414
+ end
415
+
416
+ def test_search_method
417
+ assert_respond_to @artist, :search
418
+ end
419
+
420
+ def test_search_returns_collection
421
+ json = <<-EOS
422
+ {"response": {
423
+ "status": {
424
+ "code": "0",
425
+ "message": "Success",
426
+ "version": "4.2"
427
+ },
428
+ "artists": [{
429
+ "foo": "bar"
430
+ }]
431
+ }}
432
+ EOS
433
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}search"
434
+ response = @artist.search
435
+ assert_kind_of Nestling::Collection, response
436
+ assert_equal 'bar', response[0][:foo]
437
+ end
438
+
439
+ def test_search_passes_options
440
+ json = <<-EOS
441
+ {"response": {
442
+ "status": {
443
+ "code": "0",
444
+ "message": "Success",
445
+ "version": "4.2"
446
+ },
447
+ "artists": [{
448
+ "foo": "bar"
449
+ }]
450
+ }}
451
+ EOS
452
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}search", { :foo => :bar, :name => 'bar' }
453
+ @artist.search :foo => :bar
454
+ end
455
+
456
+ def test_extract_method
457
+ assert_respond_to @artist, :extract
458
+ end
459
+
460
+ def test_extract_returns_collection
461
+ json = <<-EOS
462
+ {"response": {
463
+ "status": {
464
+ "code": "0",
465
+ "message": "Success",
466
+ "version": "4.2"
467
+ },
468
+ "artist": [{
469
+ "foo": "bar"
470
+ }]
471
+ }}
472
+ EOS
473
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}extract"
474
+ response = @artist.extract
475
+ assert_kind_of Nestling::Collection, response
476
+ assert_equal 'bar', response[0][:foo]
477
+ end
478
+
479
+ def test_extract_passes_options
480
+ json = <<-EOS
481
+ {"response": {
482
+ "status": {
483
+ "code": "0",
484
+ "message": "Success",
485
+ "version": "4.2"
486
+ },
487
+ "artist": [{
488
+ "foo": "bar"
489
+ }]
490
+ }}
491
+ EOS
492
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}extract", { :foo => :bar, :name => 'bar' }
493
+ @artist.extract :foo => :bar
494
+ end
495
+
496
+ def test_songs_method
497
+ assert_respond_to @artist, :songs
498
+ end
499
+
500
+ def test_songs_returns_collection
501
+ json = <<-EOS
502
+ {"response": {
503
+ "status": {
504
+ "code": "0",
505
+ "message": "Success",
506
+ "version": "4.2"
507
+ },
508
+ "songs": [{
509
+ "foo": "bar"
510
+ }]
511
+ }}
512
+ EOS
513
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}songs"
514
+ response = @artist.songs
515
+ assert_kind_of Nestling::Collection, response
516
+ assert_equal 'bar', response[0][:foo]
517
+ end
518
+
519
+ def test_songs_passes_options
520
+ json = <<-EOS
521
+ {"response": {
522
+ "status": {
523
+ "code": "0",
524
+ "message": "Success",
525
+ "version": "4.2"
526
+ },
527
+ "songs": [{
528
+ "foo": "bar"
529
+ }]
530
+ }}
531
+ EOS
532
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}songs", { :foo => :bar, :name => 'bar' }
533
+ @artist.songs :foo => :bar
534
+ end
535
+
536
+ def test_similar_method
537
+ assert_respond_to @artist, :similar
538
+ end
539
+
540
+ def test_similar_returns_collection
541
+ json = <<-EOS
542
+ {"response": {
543
+ "status": {
544
+ "code": "0",
545
+ "message": "Success",
546
+ "version": "4.2"
547
+ },
548
+ "artists": [{
549
+ "foo": "bar"
550
+ }]
551
+ }}
552
+ EOS
553
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}similar"
554
+ response = @artist.similar
555
+ assert_kind_of Nestling::Collection, response
556
+ assert_equal 'bar', response[0][:foo]
557
+ end
558
+
559
+ def test_similar_passes_options
560
+ json = <<-EOS
561
+ {"response": {
562
+ "status": {
563
+ "code": "0",
564
+ "message": "Success",
565
+ "version": "4.2"
566
+ },
567
+ "artists": [{
568
+ "foo": "bar"
569
+ }]
570
+ }}
571
+ EOS
572
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}similar", { :foo => :bar, :name => 'bar' }
573
+ @artist.similar :foo => :bar
574
+ end
575
+
576
+ def test_suggest_method
577
+ assert_respond_to @artist, :suggest
578
+ end
579
+
580
+ def test_suggest_returns_collection
581
+ json = <<-EOS
582
+ {"response": {
583
+ "status": {
584
+ "code": "0",
585
+ "message": "Success",
586
+ "version": "4.2"
587
+ },
588
+ "artists": [{
589
+ "foo": "bar"
590
+ }]
591
+ }}
592
+ EOS
593
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}suggest"
594
+ response = @artist.suggest
595
+ assert_kind_of Nestling::Collection, response
596
+ assert_equal 'bar', response[0][:foo]
597
+ end
598
+
599
+ def test_suggest_passes_options
600
+ json = <<-EOS
601
+ {"response": {
602
+ "status": {
603
+ "code": "0",
604
+ "message": "Success",
605
+ "version": "4.2"
606
+ },
607
+ "artists": [{
608
+ "foo": "bar"
609
+ }]
610
+ }}
611
+ EOS
612
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}suggest", { :foo => :bar, :name => 'bar' }
613
+ @artist.suggest :foo => :bar
614
+ end
615
+
616
+ def test_terms_method
617
+ assert_respond_to @artist, :terms
618
+ end
619
+
620
+ def test_terms_returns_collection
621
+ json = <<-EOS
622
+ {"response": {
623
+ "status": {
624
+ "code": "0",
625
+ "message": "Success",
626
+ "version": "4.2"
627
+ },
628
+ "terms": [{
629
+ "foo": "bar"
630
+ }]
631
+ }}
632
+ EOS
633
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}terms"
634
+ response = @artist.terms
635
+ assert_kind_of Nestling::Collection, response
636
+ assert_equal 'bar', response[0][:foo]
637
+ end
638
+
639
+ def test_terms_passes_options
640
+ json = <<-EOS
641
+ {"response": {
642
+ "status": {
643
+ "code": "0",
644
+ "message": "Success",
645
+ "version": "4.2"
646
+ },
647
+ "terms": [{
648
+ "foo": "bar"
649
+ }]
650
+ }}
651
+ EOS
652
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}terms", { :foo => :bar, :name => 'bar' }
653
+ @artist.terms :foo => :bar
654
+ end
655
+
656
+ def test_top_hottt_method
657
+ assert_respond_to @artist, :top_hottt
658
+ end
659
+
660
+ def test_top_hottt_returns_collection
661
+ json = <<-EOS
662
+ {"response": {
663
+ "status": {
664
+ "code": "0",
665
+ "message": "Success",
666
+ "version": "4.2"
667
+ },
668
+ "artists": [{
669
+ "foo": "bar"
670
+ }]
671
+ }}
672
+ EOS
673
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}top_hottt"
674
+ response = @artist.top_hottt
675
+ assert_kind_of Nestling::Collection, response
676
+ assert_equal 'bar', response[0][:foo]
677
+ end
678
+
679
+ def test_top_hottt_passes_options
680
+ json = <<-EOS
681
+ {"response": {
682
+ "status": {
683
+ "code": "0",
684
+ "message": "Success",
685
+ "version": "4.2"
686
+ },
687
+ "artists": [{
688
+ "foo": "bar"
689
+ }]
690
+ }}
691
+ EOS
692
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}top_hottt", { :foo => :bar, :name => 'bar' }
693
+ @artist.top_hottt :foo => :bar
694
+ end
695
+
696
+ def test_top_terms_method
697
+ assert_respond_to @artist, :top_terms
698
+ end
699
+
700
+ def test_top_terms_returns_collection
701
+ json = <<-EOS
702
+ {"response": {
703
+ "status": {
704
+ "code": "0",
705
+ "message": "Success",
706
+ "version": "4.2"
707
+ },
708
+ "terms": [{
709
+ "foo": "bar"
710
+ }]
711
+ }}
712
+ EOS
713
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}top_terms"
714
+ response = @artist.top_terms
715
+ assert_kind_of Nestling::Collection, response
716
+ assert_equal 'bar', response[0][:foo]
717
+ end
718
+
719
+ def test_top_terms_passes_options
720
+ json = <<-EOS
721
+ {"response": {
722
+ "status": {
723
+ "code": "0",
724
+ "message": "Success",
725
+ "version": "4.2"
726
+ },
727
+ "terms": [{
728
+ "foo": "bar"
729
+ }]
730
+ }}
731
+ EOS
732
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}top_terms", { :foo => :bar, :name => 'bar' }
733
+ @artist.top_terms :foo => :bar
734
+ end
735
+
736
+ def test_urls_method
737
+ assert_respond_to @artist, :urls
738
+ end
739
+
740
+ def test_urls_returns_hash
741
+ json = <<-EOS
742
+ {"response": {
743
+ "status": {
744
+ "code": "0",
745
+ "message": "Success",
746
+ "version": "4.2"
747
+ },
748
+ "urls": {
749
+ "foo": "bar"
750
+ }
751
+ }}
752
+ EOS
753
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}urls"
754
+ response = @artist.urls
755
+ assert_kind_of Nestling::Hash, response
756
+ assert_equal 'bar', response[:foo]
757
+ end
758
+
759
+ def test_urls_passes_options
760
+ json = <<-EOS
761
+ {"response": {
762
+ "status": {
763
+ "code": "0",
764
+ "message": "Success",
765
+ "version": "4.2"
766
+ },
767
+ "urls": {
768
+ "foo": "bar"
769
+ }
770
+ }}
771
+ EOS
772
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}urls", { :foo => :bar, :name => 'bar' }
773
+ @artist.urls :foo => :bar
774
+ end
775
+
776
+ def test_video_method
777
+ assert_respond_to @artist, :video
778
+ end
779
+
780
+ def test_video_returns_collection
781
+ json = <<-EOS
782
+ {"response": {
783
+ "status": {
784
+ "code": "0",
785
+ "message": "Success",
786
+ "version": "4.2"
787
+ },
788
+ "video": [{
789
+ "foo": "bar"
790
+ }]
791
+ }}
792
+ EOS
793
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}video"
794
+ response = @artist.video
795
+ assert_kind_of Nestling::Collection, response
796
+ assert_equal 'bar', response[0][:foo]
797
+ end
798
+
799
+ def test_video_passes_options
800
+ json = <<-EOS
801
+ {"response": {
802
+ "status": {
803
+ "code": "0",
804
+ "message": "Success",
805
+ "version": "4.2"
806
+ },
807
+ "video": [{
808
+ "foo": "bar"
809
+ }]
810
+ }}
811
+ EOS
812
+ expect_request json, "#{Nestling::Artist::METHOD_PREFIX}video", { :foo => :bar, :name => 'bar' }
813
+ @artist.video :foo => :bar
174
814
  end
175
815
  end
176
816