rdio_api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +11 -0
- data/Gemfile +4 -0
- data/Guardfile +20 -0
- data/README.md +115 -0
- data/Rakefile +10 -0
- data/lib/rdio_api/api.rb +81 -0
- data/lib/rdio_api/client.rb +48 -0
- data/lib/rdio_api/version.rb +3 -0
- data/lib/rdio_api.rb +14 -0
- data/rdio_api.gemspec +30 -0
- data/spec/fixtures/addFriend.json +4 -0
- data/spec/fixtures/addToCollection.json +4 -0
- data/spec/fixtures/addToPlaylist.json +4 -0
- data/spec/fixtures/createPlaylist.json +19 -0
- data/spec/fixtures/currentUser.json +14 -0
- data/spec/fixtures/deletePlaylist.json +4 -0
- data/spec/fixtures/findUser.json +14 -0
- data/spec/fixtures/get.json +16 -0
- data/spec/fixtures/getActivityStream.json +18 -0
- data/spec/fixtures/getAlbumsForArtist.json +917 -0
- data/spec/fixtures/getAlbumsForArtistInCollection.json +82 -0
- data/spec/fixtures/getAlbumsInCollection.json +1184 -0
- data/spec/fixtures/getArtistsInCollection.json +37 -0
- data/spec/fixtures/getHeavyRotation.json +394 -0
- data/spec/fixtures/getNewReleases.json +796 -0
- data/spec/fixtures/getObjectFromShortCode.json +33 -0
- data/spec/fixtures/getObjectFromUrl.json +16 -0
- data/spec/fixtures/getPlaybackToken.json +4 -0
- data/spec/fixtures/getPlaylists.json +25 -0
- data/spec/fixtures/getTopCharts.json +181 -0
- data/spec/fixtures/getTracksForAlbumInCollection.json +440 -0
- data/spec/fixtures/getTracksForArtist.json +295 -0
- data/spec/fixtures/getTracksForArtistInCollection.json +34 -0
- data/spec/fixtures/getTracksInCollection.json +121 -0
- data/spec/fixtures/removeFriend.json +4 -0
- data/spec/fixtures/removeFromCollection.json +4 -0
- data/spec/fixtures/removeFromPlaylist.json +4 -0
- data/spec/fixtures/search.json +523 -0
- data/spec/fixtures/searchSuggestions.json +117 -0
- data/spec/fixtures/setAvailableOffline.json +4 -0
- data/spec/fixtures/setPlaylistCollaborating.json +4 -0
- data/spec/fixtures/setPlaylistCollaborationMode.json +4 -0
- data/spec/fixtures/setPlaylistFields.json +4 -0
- data/spec/fixtures/setPlaylistOrder.json +4 -0
- data/spec/fixtures/userFollowers.json +27 -0
- data/spec/fixtures/userFollowing.json +27 -0
- data/spec/helper.rb +26 -0
- data/spec/rdio_api/activity_spec.rb +59 -0
- data/spec/rdio_api/catalog_spec.rb +77 -0
- data/spec/rdio_api/client_spec.rb +18 -0
- data/spec/rdio_api/collection_spec.rb +127 -0
- data/spec/rdio_api/core_spec.rb +59 -0
- data/spec/rdio_api/playback_spec.rb +22 -0
- data/spec/rdio_api/playlists_spec.rb +122 -0
- data/spec/rdio_api/social_spec.rb +92 -0
- metadata +273 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"status" :"ok",
|
3
|
+
"result" : [
|
4
|
+
{
|
5
|
+
"firstName": "Ruby",
|
6
|
+
"baseIcon": "user/no-user-image-square.jpg",
|
7
|
+
"gender": "m",
|
8
|
+
"url": "/people/rubygithubber/",
|
9
|
+
"key": "s12346",
|
10
|
+
"lastName": "Githubber",
|
11
|
+
"libraryVersion": 0,
|
12
|
+
"type": "s",
|
13
|
+
"icon": "http://media.rd.io/user/no-user-image-square.jpg"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"firstName": "Rdio",
|
17
|
+
"baseIcon": "user/no-user-image-square.jpg",
|
18
|
+
"gender": "f",
|
19
|
+
"url": "/people/rdioapi/",
|
20
|
+
"key": "s12347",
|
21
|
+
"lastName": "Api",
|
22
|
+
"libraryVersion": 80,
|
23
|
+
"type": "s",
|
24
|
+
"icon": "http://media.rd.io/user/no-user-image-square.jpg"
|
25
|
+
}
|
26
|
+
]
|
27
|
+
}
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'rdio_api'
|
4
|
+
require 'rspec'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
require 'oauth'
|
7
|
+
|
8
|
+
def stub_post
|
9
|
+
stub_request(:post, "http://api.rdio.com/1/")
|
10
|
+
end
|
11
|
+
|
12
|
+
def fixture_path
|
13
|
+
File.expand_path("../fixtures", __FILE__)
|
14
|
+
end
|
15
|
+
|
16
|
+
def fixture(file)
|
17
|
+
File.new(fixture_path + '/' + file)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_consumer
|
21
|
+
@test_consumer ||= OAuth::Consumer.new("consumer_key", "consumer_secret")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_access_token
|
25
|
+
@test_access_token ||= OAuth::AccessToken.new(test_consumer, "auth_token", "auth_secret")
|
26
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe RdioApi::Client do
|
4
|
+
|
5
|
+
context "when working with the Activity methods" do
|
6
|
+
before do
|
7
|
+
@client = RdioApi.new(:consumer_key => "consumerkey", :consumer_secret => "consumersecret")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "'getActivityStream'" do
|
11
|
+
before do
|
12
|
+
stub_post.with(:body => {:method => 'getActivityStream', :user => "s27093", :scope => "user"}).
|
13
|
+
to_return(:body => fixture("getActivityStream.json"))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have the correct user library version" do
|
17
|
+
results = @client.getActivityStream(:user => "s27093", :scope => "user")
|
18
|
+
results.user.libraryVersion.should eq(110)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "'getHeavyRotation'" do
|
23
|
+
before do
|
24
|
+
stub_post.with(:body => {:method => 'getHeavyRotation', :type => "albums"}).
|
25
|
+
to_return(:body => fixture("getHeavyRotation.json"))
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return all 10 albums" do
|
29
|
+
results = @client.getHeavyRotation(:type => "albums")
|
30
|
+
results.count.should eq(10)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "'getNewReleases'" do
|
35
|
+
before do
|
36
|
+
stub_post.with(:body => {:method => 'getNewReleases', :type => "thisweek"}).
|
37
|
+
to_return(:body => fixture("getNewReleases.json"))
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return the correct name for the first album" do
|
41
|
+
results = @client.getNewReleases(:type => "thisweek")
|
42
|
+
results.first.name.should eq("King (Deluxe Version)")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "'getTopCharts'" do
|
47
|
+
before do
|
48
|
+
stub_post.with(:body => {:method => 'getTopCharts', :type => "Playlist"}).
|
49
|
+
to_return(:body => fixture("getTopCharts.json"))
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return the correct Playlists" do
|
53
|
+
results = @client.getTopCharts(:type => "Playlist")
|
54
|
+
results.count.should eq(11)
|
55
|
+
results.first.name.should eq("Billboard Top 100")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe RdioApi::Client do
|
4
|
+
|
5
|
+
context "when working with the Catalog methods" do
|
6
|
+
before do
|
7
|
+
@client = RdioApi.new(:consumer_key => "consumerkey", :consumer_secret => "consumersecret")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "'getAlbumsForArtist'" do
|
11
|
+
|
12
|
+
context "with artist key passed" do
|
13
|
+
before do
|
14
|
+
stub_post.with(:body => {:method => 'getAlbumsForArtist', :artist => "r20227"}).
|
15
|
+
to_return(:body => fixture("getAlbumsForArtist.json"))
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return Array of Albums" do
|
19
|
+
albums = @client.getAlbumsForArtist(:artist => "r20227")
|
20
|
+
albums.should be_an Array
|
21
|
+
albums.first.name.should eq("My Beautiful Dark Twisted Fantasy")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "'getTracksForArtist'" do
|
27
|
+
|
28
|
+
context "with artist key passed" do
|
29
|
+
before do
|
30
|
+
stub_post.with(:body => {:method => 'getTracksForArtist', :artist => "r311065"}).
|
31
|
+
to_return(:body => fixture("getTracksForArtist.json"))
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return Array of Tracks" do
|
35
|
+
tracks = @client.getTracksForArtist(:artist => "r311065")
|
36
|
+
tracks.should be_an Array
|
37
|
+
tracks.last.duration.should eq(121)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "'search'" do
|
43
|
+
|
44
|
+
context "with query and types passed" do
|
45
|
+
before do
|
46
|
+
stub_post.with(:body => {:method => 'search', :query => "michael giacchino", :types => "album"}).
|
47
|
+
to_return(:body => fixture("search.json"))
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should have correct track count" do
|
51
|
+
results = @client.search(:query => "michael giacchino", :types => "album")
|
52
|
+
results.track_count.should eq(708)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should include correct track for a result" do
|
56
|
+
results = @client.search(:query => "michael giacchino", :types => "album")
|
57
|
+
results.results.first.trackKeys.should include("t9506546")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "'searchSuggestions'" do
|
63
|
+
|
64
|
+
context "with query passed" do
|
65
|
+
before do
|
66
|
+
stub_post.with(:body => {:method => 'searchSuggestions', :query => "yoav"}).
|
67
|
+
to_return(:body => fixture("searchSuggestions.json"))
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should the correct radioKey" do
|
71
|
+
suggestions = @client.searchSuggestions(:query => "yoav")
|
72
|
+
suggestions.first.radioKey.should eq("rr316321")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe RdioApi::Client do
|
4
|
+
|
5
|
+
context "When initializing a new instance" do
|
6
|
+
|
7
|
+
it "should keep oauth token for requests" do
|
8
|
+
@client = RdioApi.new(:access_token => 'rdiooauth')
|
9
|
+
@client.access_token.should eq('rdiooauth')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should keep consumer key/secret for requests" do
|
13
|
+
@client = RdioApi.new(:consumer_key => "consumerkey", :consumer_secret => "consumersecret")
|
14
|
+
@client.consumer_key.should eq("consumerkey")
|
15
|
+
@client.consumer_secret.should eq("consumersecret")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe RdioApi::Client do
|
4
|
+
|
5
|
+
context "when working with the Collection methods" do
|
6
|
+
before do
|
7
|
+
@client = RdioApi.new(:consumer_key => "consumerkey", :consumer_secret => "consumersecret")
|
8
|
+
end
|
9
|
+
|
10
|
+
context "and methods that require authentication " do
|
11
|
+
before do
|
12
|
+
@client.access_token = test_access_token
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "'addToCollection'" do
|
16
|
+
before do
|
17
|
+
stub_post.with(:body => {:method => 'addToCollection', :keys => "t3802391"}).
|
18
|
+
to_return(:body => fixture("addToCollection.json"))
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should add track to Collection" do
|
22
|
+
results = @client.addToCollection(:keys => "t3802391")
|
23
|
+
results.should eq("true")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "'removeFromCollection'" do
|
28
|
+
before do
|
29
|
+
stub_post.with(:body => {:method => 'removeFromCollection', :keys => "t3802391"}).
|
30
|
+
to_return(:body => fixture('removeFromCollection.json'))
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should remove track from Collection" do
|
34
|
+
results = @client.removeFromCollection(:keys => "t3802391")
|
35
|
+
results.should eq("true")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "'setAvailableOffline'" do
|
40
|
+
before do
|
41
|
+
stub_post.with(:body => {:method => 'setAvailableOffline', :keys => "t1945474", :offline => "true"}).
|
42
|
+
to_return(:body => fixture("setAvailableOffline.json"))
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return true with setting track available offline" do
|
46
|
+
results = @client.setAvailableOffline(:keys => "t1945474", :offline => "true")
|
47
|
+
results.should eq("true")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "and methods that do not require authentication" do
|
53
|
+
|
54
|
+
describe "'getAlbumsForArtistInCollection'" do
|
55
|
+
before do
|
56
|
+
stub_post.with(:body => {:method => 'getAlbumsForArtistInCollection', :artist => "r350868"}).
|
57
|
+
to_return(:body => fixture("getAlbumsForArtistInCollection.json"))
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should have the correct first track name" do
|
61
|
+
results = @client.getAlbumsForArtistInCollection(:artist => "r350868")
|
62
|
+
results.first.tracks.first.name.should eq("A Game of Thrones")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "'getAlbumsInCollection'" do
|
67
|
+
before do
|
68
|
+
stub_post.with(:body => {:method => 'getAlbumsInCollection', :user => "s27093"}).
|
69
|
+
to_return(:body => fixture("getAlbumsInCollection.json"))
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have the correct artist name for the last album in collection" do
|
73
|
+
results = @client.getAlbumsInCollection(:user => "s27093")
|
74
|
+
results.last.artist.should eq("Ennio Morricone")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "'getArtistsInCollection'" do
|
79
|
+
before do
|
80
|
+
stub_post.with(:body => {:method => 'getArtistsInCollection', :user => "s27093"}).
|
81
|
+
to_return(:body => fixture("getArtistsInCollection.json"))
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should have the correct artist for the first artist in collection" do
|
85
|
+
results = @client.getArtistsInCollection(:user => "s27093")
|
86
|
+
results.first.name.should eq("Arkngthand")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "'getTracksForAlbumInCollection'" do
|
91
|
+
before do
|
92
|
+
stub_post.with(:body => {:method => 'getTracksForAlbumInCollection', :album => "al216556", :user => "s27093" }).
|
93
|
+
to_return(:body => fixture("getTracksForAlbumInCollection.json"))
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should have the correct short url for the third track in collection" do
|
97
|
+
results = @client.getTracksForAlbumInCollection(:album => "al216556", :user => "s27093")
|
98
|
+
results[2].shortUrl.should eq("http://rd.io/x/QDaXK2t_hQ")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "'getTracksForArtistInCollection'" do
|
103
|
+
before do
|
104
|
+
stub_post.with(:body => {:method => 'getTracksForArtistInCollection', :artist => "r350868"}).
|
105
|
+
to_return(:body => fixture('getTracksForArtistInCollection.json'))
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should have the correct price for track" do
|
109
|
+
results = @client.getTracksForArtistInCollection(:artist => "r350868")
|
110
|
+
results.first.price.should eq("0.99")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "'getTracksInCollection'" do
|
115
|
+
before do
|
116
|
+
stub_post.with(:body => {:method => 'getTracksInCollection', :user => "s27093"}).
|
117
|
+
to_return(:body => fixture('getTracksInCollection.json'))
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should return 4 tracks in the Collection" do
|
121
|
+
results = @client.getTracksInCollection(:user => "s27093")
|
122
|
+
results.count.should eq(4)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe RdioApi::Client do
|
4
|
+
|
5
|
+
context "when working with the Core methods" do
|
6
|
+
before do
|
7
|
+
@client = RdioApi.new(:consumer_key => "consumerkey", :consumer_secret => "consumersecret")
|
8
|
+
end
|
9
|
+
|
10
|
+
context "and methods that do not require authentication" do
|
11
|
+
|
12
|
+
describe "'get'" do
|
13
|
+
|
14
|
+
context "with keys passed" do
|
15
|
+
before do
|
16
|
+
stub_post.with(:body => {:method => 'get', :keys => "r13700"}).
|
17
|
+
to_return(:body => fixture("get.json"))
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have the correct Artist name" do
|
21
|
+
results = @client.get(:keys => "r13700")
|
22
|
+
results.r13700.name.should eq("John Williams")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
context "and methods that require authentication " do
|
30
|
+
before do
|
31
|
+
@client.access_token = test_access_token
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "'getObjectFromShortCode'" do
|
35
|
+
before do
|
36
|
+
stub_post.with(:body => {:method => 'getObjectFromShortCode', :short_code => "QisyLj0"}).
|
37
|
+
to_return(:body => fixture("getObjectFromShortCode.json"))
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have the correct Track name " do
|
41
|
+
results = @client.getObjectFromShortCode(:short_code => "QisyLj0")
|
42
|
+
results.name.should eq("Loud Pipes")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "'getObjectFromUrl'" do
|
47
|
+
before do
|
48
|
+
stub_post.with(:body => {:method => 'getObjectFromUrl', :url => "/artist/James_Horner/" }).
|
49
|
+
to_return(:body => fixture("getObjectFromUrl.json"))
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should have the corrent topSongsKey" do
|
53
|
+
results = @client.getObjectFromUrl(:url => "/artist/James_Horner/")
|
54
|
+
results.topSongsKey.should eq("tr35187")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe RdioApi::Client do
|
4
|
+
|
5
|
+
context "when working with the Playback methods" do
|
6
|
+
before do
|
7
|
+
@client = RdioApi.new(:consumer_key => "consumerkey", :consumer_secret => "consumersecret")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "'getPlaybackToken'" do
|
11
|
+
before do
|
12
|
+
stub_post.with(:body => {:method => 'getPlaybackToken'}).
|
13
|
+
to_return(:body => fixture("getPlaybackToken.json"))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return a Playback Token" do
|
17
|
+
results = @client.getPlaybackToken
|
18
|
+
results.should eq("flkasdjFA5lkdjf90asdfli2l9cnlkasdj9")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe RdioApi::Client do
|
4
|
+
|
5
|
+
context "when working with the Playlist methods" do
|
6
|
+
before do
|
7
|
+
@client = RdioApi.new(:consumer_key => "consumerkey",
|
8
|
+
:consumer_secret => "consumersecret",
|
9
|
+
:access_token => test_access_token)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "'createPlaylist'" do
|
13
|
+
before do
|
14
|
+
stub_post.with(:body => {:method => 'createPlaylist', :name => "RubyGem",
|
15
|
+
:description => "Testing", :track => "t1945474, t3483614"}).
|
16
|
+
to_return(:body => fixture("createPlaylist.json"))
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should create the playlist and have the correct name" do
|
20
|
+
results = @client.createPlaylist(:name => "RubyGem", :description => "Testing", :track => "t1945474, t3483614")
|
21
|
+
results.name.should eq("RubyGem")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "'addToPlaylist'" do
|
26
|
+
before do
|
27
|
+
stub_post.with(:body => {:method => 'addToPlaylist', :playlist => "p200057", :tracks => "t1945475"}).
|
28
|
+
to_return(:body => fixture("addToPlaylist.json"))
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should add to track to playlist" do
|
32
|
+
results = @client.addToPlaylist(:playlist => "p200057", :tracks => "t1945475")
|
33
|
+
results.should eq("true")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "'getPlaylists'" do
|
38
|
+
before do
|
39
|
+
stub_post.with(:body => {:method => 'getPlaylists'}).to_return(:body => fixture("getPlaylists.json"))
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return the playlist created in 'createPlaylist'" do
|
43
|
+
results = @client.getPlaylists
|
44
|
+
results.owned.first.name.should eq("RubyGem")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "'setPlaylistCollaborating'" do
|
49
|
+
before do
|
50
|
+
stub_post.with(:body => {:method => 'setPlaylistCollaborating', :playlist => "p200057", :collaborating => "false"}).
|
51
|
+
to_return(:body => fixture("setPlaylistCollaborating.json"))
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return true(collaborating should be false)" do
|
55
|
+
results = @client.setPlaylistCollaborating(:playlist => "p200057", :collaborating => "false")
|
56
|
+
results.should eq("true")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "'setPlaylistCollaborationMode'" do
|
61
|
+
before do
|
62
|
+
stub_post.with(:body => {:method => 'setPlaylistCollaborationMode', :playlist => "p200057", :mode => "2"}).
|
63
|
+
to_return(:body => fixture("setPlaylistCollaborationMode.json"))
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should set collaboration mode to playlist followers and return true" do
|
67
|
+
results = @client.setPlaylistCollaborationMode(:playlist => "p200057", :mode => "2")
|
68
|
+
results.should eq("true")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "'setPlaylistFields'" do
|
73
|
+
before do
|
74
|
+
stub_post.with(:body => {:method => 'setPlaylistFields', :playlist => "p200057",
|
75
|
+
:name => "RdioApi RubyGem", :description => "A Test Playlist"}).
|
76
|
+
to_return(:body => fixture("setPlaylistFields.json"))
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should change Playlist fields" do
|
80
|
+
results = @client.setPlaylistFields(:playlist => "p200057", :name => "RdioApi RubyGem", :description => "A Test Playlist")
|
81
|
+
results.should eq("true")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "'setPlaylistOrder'" do
|
86
|
+
before do
|
87
|
+
stub_post.with(:body => {:method => 'setPlaylistOrder', :playlist => "p200057", :track => "t3483614, t1945474, t1945475"}).
|
88
|
+
to_return(:body => fixture("setPlaylistOrder.json"))
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should set new Playlist order " do
|
92
|
+
results = @client.setPlaylistOrder(:playlist => "p200057", :track => "t3483614, t1945474, t1945475")
|
93
|
+
results.should eq("true")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "'removeFromPlaylist'" do
|
98
|
+
before do
|
99
|
+
stub_post.with(:body => {:method => 'removeFromPlaylist', :playlist => "p200057", :index => "2",
|
100
|
+
:count => "1", :tracks => "t1945475"}).
|
101
|
+
to_return(:body => fixture("removeFromPlaylist.json"))
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should remove track from Playlist" do
|
105
|
+
results = @client.removeFromPlaylist(:playlist => "p200057", :index => "2", :count => "1", :tracks => "t1945475")
|
106
|
+
results.should eq("true")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "'deletePlaylist'" do
|
111
|
+
before do
|
112
|
+
stub_post.with(:body => {:method => 'deletePlaylist', :playlist => "p200057"}).
|
113
|
+
to_return(:body => fixture("deletePlaylist.json"))
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should delete the playlist" do
|
117
|
+
results = @client.deletePlaylist(:playlist => "p200057")
|
118
|
+
results.should eq("true")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe RdioApi::Client do
|
4
|
+
|
5
|
+
context "when working with the Social methods" do
|
6
|
+
before do
|
7
|
+
@client = RdioApi.new(:consumer_key => "consumerkey", :consumer_secret => "consumersecret")
|
8
|
+
end
|
9
|
+
|
10
|
+
context "and methods that require authentication " do
|
11
|
+
before do
|
12
|
+
@client.access_token = test_access_token
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "'addFriend'" do
|
16
|
+
before do
|
17
|
+
stub_post.with(:body => {:method => 'addFriend', :user => "s12345"}).
|
18
|
+
to_return(:body => fixture("addFriend.json"))
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should add Friend" do
|
22
|
+
results = @client.addFriend(:user => "s12345")
|
23
|
+
results.should eq("true")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "'removeFriend'" do
|
28
|
+
before do
|
29
|
+
stub_post.with(:body => {:method => 'removeFriend', :user => "s12345"}).
|
30
|
+
to_return(:body => fixture("removeFriend.json"))
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should remove Friend" do
|
34
|
+
results = @client.removeFriend(:user => "s12345")
|
35
|
+
results.should eq("true")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "'currentUser'" do
|
40
|
+
before do
|
41
|
+
stub_post.with(:body => {:method => 'currentUser'}).to_return(:body => fixture("currentUser.json"))
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should have the current First Name" do
|
45
|
+
results = @client.currentUser
|
46
|
+
results.firstName.should eq("Anil")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "and methods that do not require authentication" do
|
52
|
+
|
53
|
+
describe "'findUser'" do
|
54
|
+
before do
|
55
|
+
stub_post.with(:body => {:method => 'findUser', :vanityName => "anilv"}).
|
56
|
+
to_return(:body => fixture("findUser.json"))
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have the correct firt name" do
|
60
|
+
results = @client.findUser(:vanityName => "anilv")
|
61
|
+
results.firstName.should eq("Anil")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "'userFollowers'" do
|
66
|
+
before do
|
67
|
+
stub_post.with(:body => {:method => 'userFollowers', :user => "s12345"}).
|
68
|
+
to_return(:body => fixture("userFollowers.json"))
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should have the correct Name for the first follower" do
|
72
|
+
results = @client.userFollowers(:user => "s12345")
|
73
|
+
results.count.should eq(2)
|
74
|
+
(results.first.firstName + " " + results.first.lastName).should eq("Ruby Githubber")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "'userFollowing'" do
|
79
|
+
before do
|
80
|
+
stub_post.with(:body => {:method => 'userFollowing', :user => "s12345"}).
|
81
|
+
to_return(:body => fixture("userFollowing.json"))
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should have the correct Name for the last follower" do
|
85
|
+
results = @client.userFollowing(:user => "s12345")
|
86
|
+
results.count.should eq(2)
|
87
|
+
(results.last.firstName + " " + results.last.lastName).should eq("Rdio Api")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|