ronnie 0.7.6

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 (79) hide show
  1. data/.gitignore +22 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +22 -0
  6. data/README.md +163 -0
  7. data/Rakefile +23 -0
  8. data/lib/faraday/response/raise_dio_error.rb +46 -0
  9. data/lib/ronnie/authentication.rb +33 -0
  10. data/lib/ronnie/client/albums.rb +50 -0
  11. data/lib/ronnie/client/artists.rb +23 -0
  12. data/lib/ronnie/client/collections/albums.rb +9 -0
  13. data/lib/ronnie/client/collections/artists.rb +9 -0
  14. data/lib/ronnie/client/collections.rb +85 -0
  15. data/lib/ronnie/client/playlists.rb +159 -0
  16. data/lib/ronnie/client/tracks.rb +32 -0
  17. data/lib/ronnie/client/users.rb +93 -0
  18. data/lib/ronnie/client.rb +39 -0
  19. data/lib/ronnie/configuration.rb +71 -0
  20. data/lib/ronnie/connection.rb +24 -0
  21. data/lib/ronnie/error.rb +34 -0
  22. data/lib/ronnie/request.rb +17 -0
  23. data/lib/ronnie/version.rb +3 -0
  24. data/lib/ronnie.rb +27 -0
  25. data/ronnie.gemspec +35 -0
  26. data/spec/faraday/response_spec.rb +0 -0
  27. data/spec/fixtures/cassettes/Ronnie_Client_Users/_add_playlists_to_collection/Add_Playlists_to_Collection/.yml +55 -0
  28. data/spec/fixtures/cassettes/Ronnie_Client_Users/_add_track_to_playlist/Add_Track_to_Playlist/.yml +61 -0
  29. data/spec/fixtures/cassettes/Ronnie_Client_Users/_add_tracks_to_collection/Add_Tracks_to_Collection/.yml +55 -0
  30. data/spec/fixtures/cassettes/Ronnie_Client_Users/_add_tracks_to_playlist/Add_Tracks_to_Playlist/.yml +61 -0
  31. data/spec/fixtures/cassettes/Ronnie_Client_Users/_album/Retrieve_Album/.yml +64 -0
  32. data/spec/fixtures/cassettes/Ronnie_Client_Users/_create_playlist/Create_a_Playlist/.yml +61 -0
  33. data/spec/fixtures/cassettes/Ronnie_Client_Users/_delete_playlist/Delete_a_Playlist/.yml +55 -0
  34. data/spec/fixtures/cassettes/Ronnie_Client_Users/_disable_collaboration/Disable_Collaboration/.yml +55 -0
  35. data/spec/fixtures/cassettes/Ronnie_Client_Users/_enable_public_collaboration/Enable_Public_Collaboration/.yml +55 -0
  36. data/spec/fixtures/cassettes/Ronnie_Client_Users/_enable_restricted_collaboration/Enable_Restricted_Collaboration/.yml +55 -0
  37. data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_albums_by_artist/Find_Albums_by_Artist/.yml +260 -0
  38. data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_albums_by_label/Find_Albums_by_Label/.yml +245 -0
  39. data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_albums_by_upc/Find_Albums_by_UPC/.yml +55 -0
  40. data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_artists_by_label/Find_Artists_by_Label/.yml +96 -0
  41. data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_tracks_by_artist/Find_Tracks_by_Artist/.yml +156 -0
  42. data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_tracks_by_isrc/Find_Tracks_by_ISRC/.yml +145 -0
  43. data/spec/fixtures/cassettes/Ronnie_Client_Users/_find_user/Find_User_by_E-mail_Address/.yml +58 -0
  44. data/spec/fixtures/cassettes/Ronnie_Client_Users/_follow/Follow_a_User/.yml +55 -0
  45. data/spec/fixtures/cassettes/Ronnie_Client_Users/_followers/Retrieve_Followers_of_Authorized_User/.yml +144 -0
  46. data/spec/fixtures/cassettes/Ronnie_Client_Users/_followers/Retrieve_Followers_of_a_User/.yml +58 -0
  47. data/spec/fixtures/cassettes/Ronnie_Client_Users/_following/Retrieve_Users_Following_Another_User/.yml +69 -0
  48. data/spec/fixtures/cassettes/Ronnie_Client_Users/_following/Retrieve_Users_Following_Authorized_User/.yml +144 -0
  49. data/spec/fixtures/cassettes/Ronnie_Client_Users/_follows_/Authorized_User_is_Following_a_User/.yml +144 -0
  50. data/spec/fixtures/cassettes/Ronnie_Client_Users/_playlist/Retrieve_Playlist/.yml +61 -0
  51. data/spec/fixtures/cassettes/Ronnie_Client_Users/_playlists/Retrieve_Playlists_by_Authorized_User/.yml +282 -0
  52. data/spec/fixtures/cassettes/Ronnie_Client_Users/_playlists/Retrieve_Playlists_by_User/.yml +67 -0
  53. data/spec/fixtures/cassettes/Ronnie_Client_Users/_playlists/Retrieve_Playlists_by_a_User/.yml +67 -0
  54. data/spec/fixtures/cassettes/Ronnie_Client_Users/_remove_playlists_from_collection/Remove_Playlists_from_Collection/.yml +55 -0
  55. data/spec/fixtures/cassettes/Ronnie_Client_Users/_remove_tracks_from_collection/Remove_Tracks_from_Collection/.yml +55 -0
  56. data/spec/fixtures/cassettes/Ronnie_Client_Users/_remove_tracks_from_playlist/Remove_Tracks_from_Playlist/.yml +61 -0
  57. data/spec/fixtures/cassettes/Ronnie_Client_Users/_search_albums/Search_Albums/.yml +95 -0
  58. data/spec/fixtures/cassettes/Ronnie_Client_Users/_search_artists/Search_Artists/.yml +66 -0
  59. data/spec/fixtures/cassettes/Ronnie_Client_Users/_search_playlists/Search_Playlists/.yml +110 -0
  60. data/spec/fixtures/cassettes/Ronnie_Client_Users/_search_tracks/Search_Tracks/.yml +65 -0
  61. data/spec/fixtures/cassettes/Ronnie_Client_Users/_search_users/Search_Users/.yml +64 -0
  62. data/spec/fixtures/cassettes/Ronnie_Client_Users/_sync_playlists/Sync_Playlists/.yml +55 -0
  63. data/spec/fixtures/cassettes/Ronnie_Client_Users/_sync_tracks/Sync_Tracks/.yml +55 -0
  64. data/spec/fixtures/cassettes/Ronnie_Client_Users/_unfollow/Unfollow_a_User/.yml +55 -0
  65. data/spec/fixtures/cassettes/Ronnie_Client_Users/_unsync_playlists/Unsync_Playlists/.yml +55 -0
  66. data/spec/fixtures/cassettes/Ronnie_Client_Users/_unsync_tracks/Unsync_Tracks/.yml +55 -0
  67. data/spec/fixtures/cassettes/Ronnie_Client_Users/_update_playlist/Update_Playlist/.yml +55 -0
  68. data/spec/fixtures/cassettes/Ronnie_Client_Users/_user/Retrieve_Authorized_User/.yml +58 -0
  69. data/spec/fixtures/cassettes/Ronnie_Client_Users/_user/Retrieve_User/.yml +58 -0
  70. data/spec/ronnie/client/albums_spec.rb +52 -0
  71. data/spec/ronnie/client/artists_spec.rb +28 -0
  72. data/spec/ronnie/client/collections_spec.rb +76 -0
  73. data/spec/ronnie/client/playlists_spec.rb +120 -0
  74. data/spec/ronnie/client/tracks_spec.rb +38 -0
  75. data/spec/ronnie/client/users_spec.rb +94 -0
  76. data/spec/ronnie/client_spec.rb +23 -0
  77. data/spec/ronnie_spec.rb +20 -0
  78. data/spec/spec_helper.rb +19 -0
  79. metadata +401 -0
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.rdio.com/1/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: method=setAvailableOffline&keys=t15940486&offline=false
9
+ headers:
10
+ Authorization:
11
+ - OAuth oauth_consumer_key="ub9ebmvf7aee3pxcms9e5mh3", oauth_nonce="4262e005a788c75768343939b0a2f7ec",
12
+ oauth_signature="Kxi9uOKEJs1LLzWg0WAQdrIhR%2Fo%3D", oauth_signature_method="HMAC-SHA1",
13
+ oauth_timestamp="1350949219", oauth_token="ute6gf7jk4y5734hx42uxspfnhdkt42qt8habah6tkyvx4ay2xvhpt5faa2ddqc6",
14
+ oauth_version="1.0"
15
+ Content-Type:
16
+ - application/x-www-form-urlencoded
17
+ Accept:
18
+ - ! '*/*'
19
+ User-Agent:
20
+ - Ruby
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: OK
25
+ headers:
26
+ X-Mashery-Responder:
27
+ - mashery-web3-lax.mashery.com
28
+ Content-Type:
29
+ - application/json
30
+ Connection:
31
+ - keep-alive
32
+ Content-Language:
33
+ - en
34
+ Vary:
35
+ - Accept-Language, Cookie
36
+ Cache-Control:
37
+ - no-cache
38
+ Access-Control-Allow-Origin:
39
+ - ! '*'
40
+ X-Version:
41
+ - '720'
42
+ Accept-Ranges:
43
+ - bytes
44
+ Content-Length:
45
+ - '32'
46
+ Date:
47
+ - Mon, 22 Oct 2012 23:40:11 GMT
48
+ Server:
49
+ - Mashery Proxy
50
+ body:
51
+ encoding: US-ASCII
52
+ string: ! '{"status": "ok", "result": true}'
53
+ http_version:
54
+ recorded_at: Mon, 22 Oct 2012 23:40:19 GMT
55
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.rdio.com/1/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: method=setPlaylistFields&playlist=p1429320&name=updated+name&description=updated+description
9
+ headers:
10
+ Authorization:
11
+ - OAuth oauth_consumer_key="ub9ebmvf7aee3pxcms9e5mh3", oauth_nonce="c6ffeab740fe1194f4eab79d9eba661e",
12
+ oauth_signature="la%2Fwgp9OZ21hK8Ojv0ZxFhMgeFE%3D", oauth_signature_method="HMAC-SHA1",
13
+ oauth_timestamp="1350897369", oauth_token="ute6gf7jk4y5734hx42uxspfnhdkt42qt8habah6tkyvx4ay2xvhpt5faa2ddqc6",
14
+ oauth_version="1.0"
15
+ Content-Type:
16
+ - application/x-www-form-urlencoded
17
+ Accept:
18
+ - ! '*/*'
19
+ User-Agent:
20
+ - Ruby
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: OK
25
+ headers:
26
+ X-Mashery-Responder:
27
+ - mashery-web4-lax.mashery.com
28
+ Content-Type:
29
+ - application/json
30
+ Connection:
31
+ - keep-alive
32
+ Content-Language:
33
+ - en
34
+ Vary:
35
+ - Accept-Language, Cookie
36
+ Cache-Control:
37
+ - no-cache
38
+ Access-Control-Allow-Origin:
39
+ - ! '*'
40
+ X-Version:
41
+ - '720'
42
+ Accept-Ranges:
43
+ - bytes
44
+ Content-Length:
45
+ - '32'
46
+ Date:
47
+ - Mon, 22 Oct 2012 09:16:04 GMT
48
+ Server:
49
+ - Mashery Proxy
50
+ body:
51
+ encoding: US-ASCII
52
+ string: ! '{"status": "ok", "result": true}'
53
+ http_version:
54
+ recorded_at: Mon, 22 Oct 2012 09:16:10 GMT
55
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,58 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.rdio.com/1/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: method=currentUser
9
+ headers:
10
+ Authorization:
11
+ - OAuth oauth_consumer_key="ub9ebmvf7aee3pxcms9e5mh3", oauth_nonce="058f9687fa82d584ebaa8a1a6a8f3178",
12
+ oauth_signature="e8eIzwJXBeGgsGZ9FAner2tFaxc%3D", oauth_signature_method="HMAC-SHA1",
13
+ oauth_timestamp="1350881436", oauth_token="ute6gf7jk4y5734hx42uxspfnhdkt42qt8habah6tkyvx4ay2xvhpt5faa2ddqc6",
14
+ oauth_version="1.0"
15
+ Content-Type:
16
+ - application/x-www-form-urlencoded
17
+ Accept:
18
+ - ! '*/*'
19
+ User-Agent:
20
+ - Ruby
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: OK
25
+ headers:
26
+ X-Mashery-Responder:
27
+ - mashery-web4-lax.mashery.com
28
+ Content-Type:
29
+ - application/json
30
+ Connection:
31
+ - keep-alive
32
+ Content-Language:
33
+ - en
34
+ Vary:
35
+ - Accept-Language, Cookie
36
+ Cache-Control:
37
+ - no-cache
38
+ Access-Control-Allow-Origin:
39
+ - ! '*'
40
+ X-Version:
41
+ - '720'
42
+ Accept-Ranges:
43
+ - bytes
44
+ Content-Length:
45
+ - '330'
46
+ Date:
47
+ - Mon, 22 Oct 2012 04:50:30 GMT
48
+ Server:
49
+ - Mashery Proxy
50
+ body:
51
+ encoding: US-ASCII
52
+ string: ! '{"status": "ok", "result": {"firstName": "Allen", "baseIcon": "user/3/2/8/000000000001b823/1/square-100.jpg",
53
+ "gender": "m", "url": "/people/allengoodman/", "key": "s112675", "lastName":
54
+ "Goodman", "libraryVersion": 280, "isProtected": false, "type": "s", "icon":
55
+ "http://cdn3.rd.io/user/3/2/8/000000000001b823/1/square-100.jpg"}}'
56
+ http_version:
57
+ recorded_at: Mon, 22 Oct 2012 04:50:36 GMT
58
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,58 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.rdio.com/1/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: method=get&keys=s2913931
9
+ headers:
10
+ Authorization:
11
+ - OAuth oauth_consumer_key="ub9ebmvf7aee3pxcms9e5mh3", oauth_nonce="ed10631f209e412b1f03eaaf0fd97cbc",
12
+ oauth_signature="a25b87T0s9YM0risIYeBmbraFK8%3D", oauth_signature_method="HMAC-SHA1",
13
+ oauth_timestamp="1350881436", oauth_token="ute6gf7jk4y5734hx42uxspfnhdkt42qt8habah6tkyvx4ay2xvhpt5faa2ddqc6",
14
+ oauth_version="1.0"
15
+ Content-Type:
16
+ - application/x-www-form-urlencoded
17
+ Accept:
18
+ - ! '*/*'
19
+ User-Agent:
20
+ - Ruby
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: OK
25
+ headers:
26
+ X-Mashery-Responder:
27
+ - mashery-web3-lax.mashery.com
28
+ Content-Type:
29
+ - application/json
30
+ Connection:
31
+ - keep-alive
32
+ Content-Language:
33
+ - en
34
+ Vary:
35
+ - Accept-Language, Cookie
36
+ Cache-Control:
37
+ - no-cache
38
+ Access-Control-Allow-Origin:
39
+ - ! '*'
40
+ X-Version:
41
+ - '720'
42
+ Accept-Ranges:
43
+ - bytes
44
+ Content-Length:
45
+ - '310'
46
+ Date:
47
+ - Mon, 22 Oct 2012 04:50:31 GMT
48
+ Server:
49
+ - Mashery Proxy
50
+ body:
51
+ encoding: US-ASCII
52
+ string: ! '{"status": "ok", "result": {"s2913931": {"firstName": "Jill", "baseIcon":
53
+ "user/no-user-image-square.jpg", "gender": "f", "url": "/people/JillSPeters/",
54
+ "key": "s2913931", "lastName": "Peters", "libraryVersion": 64, "isProtected":
55
+ null, "type": "s", "icon": "http://cdn3.rd.io/user/no-user-image-square.jpg"}}}'
56
+ http_version:
57
+ recorded_at: Mon, 22 Oct 2012 04:50:36 GMT
58
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,52 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Ronnie::Client::Users do
5
+ before do
6
+ @client = Ronnie::Client.new consumer_key: ENV['CONSUMER_KEY'],
7
+ consumer_secret: ENV['CONSUMER_SECRET']
8
+
9
+ @client.token = ENV['OAUTH_TOKEN']
10
+ @client.token_secret = ENV['OAUTH_TOKEN_SECRET']
11
+ end
12
+
13
+ describe '.album', :vcr do
14
+ context 'Retrieve Album' do
15
+ let(:album) { @client.album('a610550') }
16
+
17
+ it { expect(album['a610550'].name).to eq('Heaven Or Las Vegas') }
18
+ end
19
+ end
20
+
21
+ describe '.find_albums_by_artist', :vcr do
22
+ context 'Find Albums by Artist' do
23
+ let(:albums) { @client.find_albums_by_artist('r235282') }
24
+
25
+ it { expect(albums.first.name).to eq('Heaven Or Las Vegas') }
26
+ end
27
+ end
28
+
29
+ describe '.find_albums_by_label', :vcr do
30
+ context 'Find Albums by Label' do
31
+ let(:albums) { @client.find_albums_by_label('l2270') }
32
+
33
+ it { expect(albums.first.name).to eq('Odd Blood') }
34
+ end
35
+ end
36
+
37
+ # describe '.find_albums_by_upc', :vcr do
38
+ # context 'Find Albums by UPC' do
39
+ # let(:albums) { @client.find_albums_by_upc('652637001228') }
40
+
41
+ # it { expect(albums.first.name).to eq('Heaven Or Las Vegas') }
42
+ # end
43
+ # end
44
+
45
+ describe '.search_albums', :vcr do
46
+ context 'Search Albums' do
47
+ let(:albums) { @client.search_albums('Clear Moon') }
48
+
49
+ it { expect(albums[:results].first.name).to eq('Clear Moon') }
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Ronnie::Client::Users do
5
+ before do
6
+ @client = Ronnie::Client.new consumer_key: ENV['CONSUMER_KEY'],
7
+ consumer_secret: ENV['CONSUMER_SECRET']
8
+
9
+ @client.token = ENV['OAUTH_TOKEN']
10
+ @client.token_secret = ENV['OAUTH_TOKEN_SECRET']
11
+ end
12
+
13
+ describe '.find_artists_by_label', :vcr do
14
+ context 'Find Artists by Label' do
15
+ let(:artists) { @client.find_artists_by_label('l2270') }
16
+
17
+ it { expect(artists.first.name).to eq('Yeasayer') }
18
+ end
19
+ end
20
+
21
+ describe '.search_artists', :vcr do
22
+ context 'Search Artists' do
23
+ let(:artists) { @client.search_artists('Mount Eerie') }
24
+
25
+ it { expect(artists[:results].first.name).to eq('Mount Eerie') }
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,76 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Ronnie::Client::Users do
5
+ before do
6
+ @client = Ronnie::Client.new consumer_key: ENV['CONSUMER_KEY'],
7
+ consumer_secret: ENV['CONSUMER_SECRET']
8
+
9
+ @client.token = ENV['OAUTH_TOKEN']
10
+ @client.token_secret = ENV['OAUTH_TOKEN_SECRET']
11
+ end
12
+
13
+ describe '.add_playlists_to_collection', :vcr do
14
+ context 'Add Playlists to Collection' do
15
+ let(:collection) {@client.add_playlists_to_collection(['p1429320'])}
16
+
17
+ it { expect(collection).to eq(true) }
18
+ end
19
+ end
20
+
21
+ describe '.add_tracks_to_collection', :vcr do
22
+ context 'Add Tracks to Collection' do
23
+ let(:collection) {@client.add_tracks_to_collection(['t15940486'])}
24
+
25
+ it { expect(collection).to eq(true) }
26
+ end
27
+ end
28
+
29
+ describe '.remove_playlists_from_collection', :vcr do
30
+ context 'Remove Playlists from Collection' do
31
+ let(:collection) {@client.remove_playlists_from_collection(['p1429320'])}
32
+
33
+ it { expect(collection).to eq(true) }
34
+ end
35
+ end
36
+
37
+ describe '.remove_tracks_from_collection', :vcr do
38
+ context 'Remove Tracks from Collection' do
39
+ let(:collection) {@client.remove_tracks_from_collection(['t15940486'])}
40
+
41
+ it { expect(collection).to eq(true) }
42
+ end
43
+ end
44
+
45
+ describe '.sync_playlists', :vcr do
46
+ context 'Sync Playlists' do
47
+ let(:collection) {@client.sync_playlists(['p1429320'])}
48
+
49
+ it { expect(collection).to eq(true) }
50
+ end
51
+ end
52
+
53
+ describe '.sync_tracks', :vcr do
54
+ context 'Sync Tracks' do
55
+ let(:collection) {@client.sync_tracks(['t15940486'])}
56
+
57
+ it { expect(collection).to eq(true) }
58
+ end
59
+ end
60
+
61
+ describe '.unsync_playlists', :vcr do
62
+ context 'Unsync Playlists' do
63
+ let(:collection) {@client.unsync_playlists(['p1429320'])}
64
+
65
+ it { expect(collection).to eq(true) }
66
+ end
67
+ end
68
+
69
+ describe '.unsync_tracks', :vcr do
70
+ context 'Unsync Tracks' do
71
+ let(:collection) {@client.unsync_playlists(['t15940486'])}
72
+
73
+ it { expect(collection).to eq(true) }
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,120 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Ronnie::Client::Users do
5
+ before do
6
+ @client = Ronnie::Client.new consumer_key: ENV['CONSUMER_KEY'],
7
+ consumer_secret: ENV['CONSUMER_SECRET']
8
+
9
+ @client.token = ENV['OAUTH_TOKEN']
10
+ @client.token_secret = ENV['OAUTH_TOKEN_SECRET']
11
+ end
12
+
13
+ describe '.playlists', :vcr do
14
+ context 'Retrieve Playlists by a User' do
15
+ let(:playlists) { @client.playlists('s1678190') }
16
+
17
+ it { expect(playlists[:collab].first.owner).to eq('Allen Goodman') }
18
+ end
19
+
20
+ context 'Retrieve Playlists by Authorized User' do
21
+ let(:playlists) { @client.playlists }
22
+
23
+ it { expect(playlists[:owned].last.name).to eq('Last Train') }
24
+ end
25
+ end
26
+
27
+ describe '.search_playlists', :vcr do
28
+ context 'Search Playlists' do
29
+ let(:playlists) { @client.search_playlists('AirR&B&B') }
30
+
31
+ it { expect(playlists[:results].first[:key]).to eq('p882620') }
32
+ end
33
+ end
34
+
35
+ describe '.playlist', :vcr do
36
+ context 'Retrieve Playlist' do
37
+ let(:playlist) { @client.playlist('p87188') }
38
+
39
+ it { expect(playlist['p87188'].name).to eq('Families in Torment') }
40
+ end
41
+ end
42
+
43
+ describe '.update_playlist', :vcr do
44
+ context 'Update Playlist' do
45
+ let(:playlist) {
46
+ @client.update_playlist(
47
+ 'p1429320', 'updated name', 'updated description'
48
+ )
49
+ }
50
+
51
+ it { expect(playlist).to eq(true) }
52
+ end
53
+ end
54
+
55
+ describe '.add_tracks_to_playlist', :vcr do
56
+ context 'Add Tracks to Playlist' do
57
+ let(:playlist) {
58
+ @client.add_tracks_to_playlist(['t15940486'], 'p1429320')
59
+ }
60
+
61
+ it { expect(playlist[:key]).to eq('p1429320') }
62
+ end
63
+ end
64
+
65
+ describe '.remove_tracks_from_playlist', :vcr do
66
+ context 'Remove Tracks from Playlist' do
67
+ let(:playlist) {
68
+ @client.remove_tracks_from_playlist(
69
+ ['t15940486'], 0, 1, 'p1429320'
70
+ )
71
+ }
72
+
73
+ it { expect(playlist[:key]).to eq('p1429320') }
74
+ end
75
+ end
76
+
77
+ describe '.enable_public_collaboration', :vcr do
78
+ context 'Enable Public Collaboration' do
79
+ let (:playlist) { @client.enable_public_collaboration('p1429320') }
80
+
81
+ it { expect(playlist).to eq(true) }
82
+ end
83
+ end
84
+
85
+ describe '.enable_restricted_collaboration', :vcr do
86
+ context 'Enable Restricted Collaboration' do
87
+ let (:playlist) { @client.enable_restricted_collaboration('p1429320') }
88
+
89
+ it { expect(playlist).to eq(true) }
90
+ end
91
+ end
92
+
93
+ describe '.disable_collaboration', :vcr do
94
+ context 'Disable Collaboration' do
95
+ let (:playlist) { @client.disable_collaboration('p1429320') }
96
+
97
+ it { expect(playlist).to eq(true) }
98
+ end
99
+ end
100
+
101
+ describe '.create_playlist', :vcr do
102
+ context 'Create a Playlist' do
103
+ let(:playlist) {
104
+ @client.create_playlist(
105
+ 'example name', 'example description', ['t20680151', 't20680150']
106
+ )
107
+ }
108
+
109
+ it { expect(playlist.name).to eq('example name') }
110
+ end
111
+ end
112
+
113
+ describe '.delete_playlist', :vcr do
114
+ context 'Delete a Playlist' do
115
+ let(:playlist) { @client.delete_playlist('p1431248') }
116
+
117
+ it { expect(playlist).to eq(true) }
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Ronnie::Client::Users do
5
+ before do
6
+ @client = Ronnie::Client.new consumer_key: ENV['CONSUMER_KEY'],
7
+ consumer_secret: ENV['CONSUMER_SECRET']
8
+
9
+ @client.token = ENV['OAUTH_TOKEN']
10
+ @client.token_secret = ENV['OAUTH_TOKEN_SECRET']
11
+ end
12
+
13
+ describe '.find_tracks_by_artist', :vcr do
14
+ context 'Find Tracks by Artist' do
15
+ let(:tracks) { @client.find_tracks_by_artist('r235282') }
16
+
17
+ it { expect(tracks.first.name).to eq('Cherry-coloured Funk') }
18
+ end
19
+ end
20
+
21
+ describe '.find_tracks_by_isrc', :vcr do
22
+ context 'Find Tracks by ISRC' do
23
+ let(:tracks) { @client.find_tracks_by_isrc('GBAYE0200771') }
24
+
25
+ it { expect(tracks.first.name).to eq('Clocks') }
26
+ end
27
+ end
28
+
29
+ describe '.search_tracks', :vcr do
30
+ context 'Search Tracks' do
31
+ let(:tracks) { @client.search_tracks('Through The Trees pt. 2') }
32
+
33
+ it do
34
+ expect(tracks[:results].first.name).to eq('Through The Trees pt. 2')
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,94 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Ronnie::Client::Users do
5
+ before do
6
+ @client = Ronnie::Client.new consumer_key: ENV['CONSUMER_KEY'],
7
+ consumer_secret: ENV['CONSUMER_SECRET']
8
+
9
+ @client.token = ENV['OAUTH_TOKEN']
10
+ @client.token_secret = ENV['OAUTH_TOKEN_SECRET']
11
+ end
12
+
13
+ describe '.user', :vcr do
14
+ context 'Retrieve User' do
15
+ let(:user) { @client.user('s2913931') }
16
+
17
+ it { expect(user['s2913931'].firstName).to eq('Jill') }
18
+ end
19
+
20
+ context 'Retrieve Authorized User' do
21
+ let(:user) { @client.user }
22
+
23
+ it { expect(user.firstName).to eq('Allen') }
24
+ end
25
+ end
26
+
27
+ describe '.find_user', :vcr do
28
+ context 'Find User by E-mail Address' do
29
+ let(:user) { @client.find_user('allen.goodman@me.com') }
30
+
31
+ it { expect(user.firstName).to eq('Allen') }
32
+ end
33
+ end
34
+
35
+ describe '.search_users', :vcr do
36
+ context 'Search Users' do
37
+ let(:users) { @client.search_users('Allen Goodman') }
38
+
39
+ it { expect(users[:results].last[:key]).to eq('s112675') }
40
+ end
41
+ end
42
+
43
+ describe ".followers", :vcr do
44
+ context 'Retrieve Followers of a User' do
45
+ let(:followers) { @client.followers('s2913931') }
46
+
47
+ it { expect(followers.first.firstName).to eq('Jay') }
48
+ end
49
+
50
+ context 'Retrieve Followers of Authorized User' do
51
+ let(:followers) { @client.followers }
52
+
53
+ it { expect(followers.first.firstName).to eq('Jill') }
54
+ end
55
+ end
56
+
57
+ describe '.following', :vcr do
58
+ context 'Retrieve Users Following Another User' do
59
+ let(:following) { @client.following('s2913931') }
60
+
61
+ it { expect(following.first.firstName).to eq('The A.V.') }
62
+ end
63
+
64
+ context 'Retrieve Users Following Authorized User' do
65
+ let(:following) { @client.following }
66
+
67
+ it { expect(following.first.firstName).to eq('Dan') }
68
+ end
69
+ end
70
+
71
+ describe '.follows?', :vcr do
72
+ context 'Authorized User is Following a User' do
73
+ let(:follows) { @client.follows?('s2684102') }
74
+
75
+ it { expect(follows).to eq(true) }
76
+ end
77
+ end
78
+
79
+ describe '.follow', :vcr do
80
+ context 'Follow a User' do
81
+ let(:follow) { @client.follow('s2913931') }
82
+
83
+ it { expect(follow).to be_true }
84
+ end
85
+ end
86
+
87
+ describe '.unfollow', :vcr do
88
+ let(:unfollow) { @client.unfollow('s2913931') }
89
+
90
+ context 'Unfollow a User' do
91
+ it { expect(unfollow).to be_true }
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ronnie::Client do
4
+ describe '.api_endpoint' do
5
+ after(:each) do
6
+ Ronnie.reset
7
+ end
8
+
9
+ it 'defaults to http://api.rdio.com/' do
10
+ client = Ronnie::Client.new
11
+
12
+ expect(client.api_endpoint).to eq('http://api.rdio.com/')
13
+ end
14
+
15
+ it 'is configurable' do
16
+ Ronnie.api_endpoint = 'http://localhost/'
17
+
18
+ client = Ronnie::Client.new
19
+
20
+ expect(client.api_endpoint).to eq('http://localhost/')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Ronnie do
5
+ after do
6
+ Ronnie.reset
7
+ end
8
+
9
+ describe '.respond_to?' do
10
+ it 'is true if method exists' do
11
+ expect(Ronnie.respond_to?(:new, true)).to be_true
12
+ end
13
+ end
14
+
15
+ describe '.new' do
16
+ it 'is a Ronnie::Client' do
17
+ expect(Ronnie.new).to be_a Ronnie::Client
18
+ end
19
+ end
20
+ end