red_haze 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. data/.gitignore +7 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/Rakefile +1 -0
  5. data/config.template.yml +4 -0
  6. data/lib/red_haze/activity.rb +5 -0
  7. data/lib/red_haze/client.rb +58 -0
  8. data/lib/red_haze/collection.rb +16 -0
  9. data/lib/red_haze/comment.rb +6 -0
  10. data/lib/red_haze/group.rb +28 -0
  11. data/lib/red_haze/helpers/resource.rb +91 -0
  12. data/lib/red_haze/helpers.rb +8 -0
  13. data/lib/red_haze/me.rb +66 -0
  14. data/lib/red_haze/playlist.rb +6 -0
  15. data/lib/red_haze/request.rb +22 -0
  16. data/lib/red_haze/track.rb +23 -0
  17. data/lib/red_haze/user.rb +35 -0
  18. data/lib/red_haze/version.rb +3 -0
  19. data/lib/red_haze.rb +28 -0
  20. data/red_haze.gemspec +28 -0
  21. data/spec/fixtures/vcr_cassettes/collection_next.yml +348 -0
  22. data/spec/fixtures/vcr_cassettes/comment_sync.yml +56 -0
  23. data/spec/fixtures/vcr_cassettes/group_contributors.yml +55 -0
  24. data/spec/fixtures/vcr_cassettes/group_members.yml +55 -0
  25. data/spec/fixtures/vcr_cassettes/group_moderators.yml +55 -0
  26. data/spec/fixtures/vcr_cassettes/group_sync.yml +55 -0
  27. data/spec/fixtures/vcr_cassettes/group_users.yml +55 -0
  28. data/spec/fixtures/vcr_cassettes/me.yml +55 -0
  29. data/spec/fixtures/vcr_cassettes/me_activities.yml +429 -0
  30. data/spec/fixtures/vcr_cassettes/me_activities_limit.yml +127 -0
  31. data/spec/fixtures/vcr_cassettes/playlist.yml +60 -0
  32. data/spec/fixtures/vcr_cassettes/track_comments.yml +79 -0
  33. data/spec/fixtures/vcr_cassettes/track_favorite_get.yml +50 -0
  34. data/spec/fixtures/vcr_cassettes/track_favorite_put.yml +50 -0
  35. data/spec/fixtures/vcr_cassettes/track_favoriters.yml +172 -0
  36. data/spec/fixtures/vcr_cassettes/track_sync.yml +82 -0
  37. data/spec/fixtures/vcr_cassettes/track_unfavorite_put.yml +50 -0
  38. data/spec/fixtures/vcr_cassettes/user_comments.yml +89 -0
  39. data/spec/fixtures/vcr_cassettes/user_favorites.yml +479 -0
  40. data/spec/fixtures/vcr_cassettes/user_follow_put.yml +65 -0
  41. data/spec/fixtures/vcr_cassettes/user_followers.yml +431 -0
  42. data/spec/fixtures/vcr_cassettes/user_follows_.yml +104 -0
  43. data/spec/fixtures/vcr_cassettes/user_follows_get.yml +50 -0
  44. data/spec/fixtures/vcr_cassettes/user_groups.yml +66 -0
  45. data/spec/fixtures/vcr_cassettes/user_playlists.yml +482 -0
  46. data/spec/fixtures/vcr_cassettes/user_sync.yml +57 -0
  47. data/spec/fixtures/vcr_cassettes/user_unfollow_put.yml +54 -0
  48. data/spec/lib/red_haze/activity_spec.rb +18 -0
  49. data/spec/lib/red_haze/client_spec.rb +43 -0
  50. data/spec/lib/red_haze/collection_spec.rb +26 -0
  51. data/spec/lib/red_haze/comment_spec.rb +30 -0
  52. data/spec/lib/red_haze/group_spec.rb +57 -0
  53. data/spec/lib/red_haze/me_spec.rb +117 -0
  54. data/spec/lib/red_haze/playlist_spec.rb +41 -0
  55. data/spec/lib/red_haze/request_spec.rb +17 -0
  56. data/spec/lib/red_haze/track_spec.rb +96 -0
  57. data/spec/lib/red_haze/user_spec.rb +110 -0
  58. data/spec/lib/red_haze_spec.rb +13 -0
  59. data/spec/spec_helper.rb +45 -0
  60. metadata +212 -0
@@ -0,0 +1,57 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.soundcloud.com/users/2879548?client_id=<CLIENT_ID>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Fri, 29 Jun 2012 15:40:50 GMT
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Connection:
24
+ - keep-alive
25
+ X-Runtime:
26
+ - '20'
27
+ Etag:
28
+ - ! '"978a91aca31d51b1abda82e9b0a07791"'
29
+ Cache-Control:
30
+ - private, max-age=0, must-revalidate
31
+ Access-Control-Allow-Methods:
32
+ - GET, PUT, POST, DELETE
33
+ Access-Control-Allow-Headers:
34
+ - Accept, Authorization, Content-Type, Origin
35
+ Access-Control-Allow-Origin:
36
+ - ! '*'
37
+ X-Cacheable:
38
+ - NO:Cache-Control=max-age=0
39
+ Content-Length:
40
+ - '639'
41
+ X-Varnish:
42
+ - '3859846790'
43
+ Age:
44
+ - '0'
45
+ Via:
46
+ - 1.1 varnish
47
+ X-Cache:
48
+ - MISS
49
+ body:
50
+ encoding: US-ASCII
51
+ string: ! '{"id":2879548,"kind":"user","permalink":"jstnw","username":"jstreet","uri":"http://api.soundcloud.com/users/2879548","permalink_url":"http://soundcloud.com/jstnw","avatar_url":"http://i1.sndcdn.com/avatars-000006763043-urg7lt-large.jpg?96679da","country":"United
52
+ States","full_name":"Justin Street","city":"San Francisco","description":"I''m
53
+ a Business Developer on SoundCloud''s API Team. ","discogs_name":null,"myspace_name":null,"website":"http://justin.st","website_title":"the
54
+ personal blog of Justin W. Street","online":true,"track_count":43,"playlist_count":5,"public_favorites_count":393,"followers_count":493,"followings_count":444}'
55
+ http_version:
56
+ recorded_at: Fri, 29 Jun 2012 15:40:53 GMT
57
+ recorded_with: VCR 2.2.0
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://api.soundcloud.com/me/followings/19813607?oauth_token=<ACCESS_TOKEN>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Sat, 14 Jul 2012 23:59:13 GMT
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Connection:
24
+ - keep-alive
25
+ X-Runtime:
26
+ - '34'
27
+ Etag:
28
+ - ! '"1dbc21fb7c7e059bce9a52d441d344eb"'
29
+ Cache-Control:
30
+ - private, max-age=0, must-revalidate
31
+ Access-Control-Allow-Methods:
32
+ - GET, PUT, POST, DELETE
33
+ Access-Control-Allow-Headers:
34
+ - Accept, Authorization, Content-Type, Origin
35
+ Access-Control-Allow-Origin:
36
+ - ! '*'
37
+ X-Cacheable:
38
+ - NO:Cache-Control=max-age=0
39
+ Content-Length:
40
+ - '21'
41
+ X-Varnish:
42
+ - '500767527'
43
+ Age:
44
+ - '0'
45
+ Via:
46
+ - 1.1 varnish
47
+ X-Cache:
48
+ - MISS
49
+ body:
50
+ encoding: US-ASCII
51
+ string: ! '{"status":"200 - OK"}'
52
+ http_version:
53
+ recorded_at: Sat, 14 Jul 2012 23:59:17 GMT
54
+ recorded_with: VCR 2.2.2
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe RedHaze::Activity do
4
+ let(:raw_hash) do
5
+ setup_config(:oauth)
6
+ VCR.use_cassette('me_activities') do
7
+ RedHaze::Request.get('/me/activities/all')['collection'].sample
8
+ end
9
+ end
10
+
11
+ let(:instance) { described_class.new(raw_hash) }
12
+ subject { instance }
13
+
14
+ its(:type) { should be_a String }
15
+ its(:created_at) { should be_a DateTime }
16
+ its(:origin) { subject.class.name.should =~ /RedHaze/ }
17
+ its(:tags) { should be_an Array }
18
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe RedHaze::Client do
4
+
5
+ let(:instance) { described_class.new(client_id: 'id', client_secret: 'secret') }
6
+
7
+ describe "#initialize" do
8
+ context "with client and secret keys" do
9
+ subject { instance }
10
+ its(:client_id) { should == 'id' }
11
+ its(:client_secret) { should == 'secret' }
12
+ end
13
+
14
+ context "with only access token" do
15
+ subject { described_class.new(access_token: 'token') }
16
+ its(:access_token) { should == 'token' }
17
+ end
18
+
19
+ context "with missing keys" do
20
+ subject { described_class.new(client_secret: 'secret') }
21
+ specify do
22
+ expect { subject }.to raise_error /missing client_id/
23
+ end
24
+ end
25
+ end
26
+
27
+ describe "#authorize_url" do
28
+ context "with right attributes" do
29
+ let(:instance_with_response_uri) do
30
+ instance.redirect_uri = 'uri'
31
+ instance
32
+ end
33
+ subject { instance_with_response_uri.authorize_url }
34
+ it { subject.should =~ /https:\/\/soundcloud\.com\/connect\?client_id=.+&redirect_uri=.+&response_type=code/ }
35
+ end
36
+
37
+ context "without right attributes" do
38
+ subject { instance.authorize_url }
39
+ specify { expect { subject }.to raise_error }
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe RedHaze::Collection do
4
+ # just need a good example of a collection hash
5
+ let(:raw_hash) do
6
+ setup_config(:oauth)
7
+ VCR.use_cassette('me_activities') do
8
+ RedHaze::Request.get('/me/activities/all')
9
+ end
10
+ end
11
+
12
+ let(:instance) { described_class.new(raw_hash) }
13
+ subject { instance }
14
+
15
+ its(:items) { should return_an_array_of_red_haze_objects }
16
+ its(:next_href) { should =~ /http/ }
17
+ its(:future_href) { should =~ /http/ }
18
+
19
+ describe "#next" do
20
+ subject do
21
+ VCR.use_cassette('collection_next') { instance.next }
22
+ end
23
+ it{ should be_a described_class }
24
+ end
25
+
26
+ end
@@ -0,0 +1,30 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ describe RedHaze::Comment do
4
+ before(:all) { setup_config(:client) }
5
+
6
+ let(:instance) { described_class.new(13685794) }
7
+
8
+ describe "#initialize" do
9
+ subject { instance }
10
+ it { should be_a described_class }
11
+ its(:id) { should == 13685794 }
12
+ end
13
+
14
+ describe "#sync" do
15
+ subject do
16
+ VCR.use_cassette("comment_sync") { instance.sync }
17
+ end
18
+
19
+ it { should be_a described_class }
20
+ its(:created_at) { should be_a DateTime }
21
+ its(:user_id) { should be_a Integer }
22
+ its(:track_id) { should be_a Integer }
23
+ its(:timestamp) { should be_a Integer }
24
+ its(:body) { should be_a String }
25
+ its(:uri) { should =~ /http:\/\/api.soundcloud.com/ }
26
+ its(:user) { should be_a RedHaze::User }
27
+ end
28
+
29
+ end
30
+
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe RedHaze::Group do
4
+ before(:all) { setup_config(:client) }
5
+
6
+ let(:instance) { described_class.new(83495) }
7
+
8
+ describe "#initialize" do
9
+ subject { instance }
10
+ it { should be_a described_class }
11
+ its(:id) { should == 83495 }
12
+ end
13
+
14
+ describe "#sync" do
15
+ subject do
16
+ VCR.use_cassette("group_sync") { instance.sync }
17
+ end
18
+ its(:uri) { should =~ /http:\/\/api.soundcloud.com/ }
19
+ its(:created_at) { should be_a DateTime }
20
+ its(:permalink) { should be_a String }
21
+ its(:permalink_url) { should =~ /http:\/\/soundcloud.com/ }
22
+ its(:artwork_url) { should =~ /http:\/\/.*\.(jpg|png)/ }
23
+ its(:name) { should be_a String }
24
+ its(:description) { should be_a String }
25
+ its(:short_description) { should be_a String }
26
+ its(:creator) { should be_a RedHaze::User }
27
+ end
28
+
29
+ describe "#members" do
30
+ subject do
31
+ VCR.use_cassette("group_members") { instance.members }
32
+ end
33
+ it { should return_an_array_of RedHaze::User }
34
+ end
35
+
36
+ describe "#moderators" do
37
+ subject do
38
+ VCR.use_cassette("group_moderators") { instance.moderators }
39
+ end
40
+ it { should return_an_array_of RedHaze::User }
41
+ end
42
+
43
+ describe "#contributors" do
44
+ subject do
45
+ VCR.use_cassette("group_contributors") { instance.contributors }
46
+ end
47
+ it { should return_an_array_of RedHaze::User }
48
+ end
49
+
50
+ describe "#users" do
51
+ subject do
52
+ VCR.use_cassette("group_users") { instance.users }
53
+ end
54
+ it { should return_an_array_of RedHaze::User }
55
+ end
56
+
57
+ end
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+
3
+ describe RedHaze::Me do
4
+ let(:instance) { VCR.use_cassette('me') { described_class.new } }
5
+ let(:friend_id) { 19813607 }
6
+ let(:friend) { RedHaze::User.new(friend_id) }
7
+ subject { instance }
8
+
9
+ context "with oauth token " do
10
+ before(:all) { setup_config(:oauth) }
11
+
12
+ its(:id) { should == 999942 }
13
+ it { should be_a RedHaze::User }
14
+
15
+ shared_examples_for "an ambiguous id argument" do
16
+ before do
17
+ @vcr_name = "#{klass}_#{method}".sub('?','_get').sub('!','_put')
18
+ end
19
+
20
+ it "accepts an object" do
21
+ VCR.use_cassette(@vcr_name) do
22
+ instance.send(method, friend)
23
+ end
24
+ end
25
+
26
+ it "accepts an id" do
27
+ VCR.use_cassette(@vcr_name) do
28
+ instance.send(method, friend_id)
29
+ end
30
+ end
31
+
32
+ it "fails otherwise" do
33
+ expect { instance.send(method,'something') }.to raise_error ArgumentError
34
+ end
35
+ end
36
+
37
+ context "follow actions" do
38
+ let(:klass) { 'user' }
39
+ pending "application test"
40
+ describe "#follow!" do
41
+ let(:method) { 'follow!' }
42
+ it_behaves_like "an ambiguous id argument"
43
+ end
44
+
45
+ describe "#unfollow!" do
46
+ let(:method) { 'unfollow!' }
47
+ it_behaves_like "an ambiguous id argument"
48
+ end
49
+
50
+ describe "#follows?" do
51
+ let(:method) { 'follows?' }
52
+ it_behaves_like "an ambiguous id argument"
53
+ end
54
+ end
55
+
56
+ context "favorite actions" do
57
+ let(:klass) { 'track' }
58
+ let(:track_id) { 8774929 }
59
+
60
+ describe "#favorite?" do
61
+ let(:method) { 'favorite?' }
62
+ subject { instance.favorite?(track_id) }
63
+ it_behaves_like "an ambiguous id argument"
64
+ end
65
+
66
+ describe "#favorite!" do
67
+ let(:method) { 'favorite!' }
68
+ subject { instance.favorite?(track_id) }
69
+ it_behaves_like "an ambiguous id argument"
70
+ end
71
+
72
+ describe "#unfavorite!" do
73
+ let(:method) { 'unfavorite!' }
74
+ subject { instance.unfavorite!(track_id) }
75
+ it_behaves_like "an ambiguous id argument"
76
+ end
77
+ end
78
+
79
+ describe "#activities" do
80
+ subject do
81
+ VCR.use_cassette("me_activities") { instance.activities }
82
+ end
83
+ it { should be_a RedHaze::Collection }
84
+
85
+ context "with limit" do
86
+ subject do
87
+ VCR.use_cassette("me_activities_limit") { instance.activities(limit: 10) }
88
+ end
89
+ its(:items) { subject.size.should == 10 }
90
+ end
91
+
92
+ context "with underscored filter" do
93
+ subject { instance.activities(filter: :tracks_affiliated) }
94
+ specify do
95
+ instance.should_receive(:get_endpoint).with("/activities/tracks/affiliated",anything)
96
+ subject
97
+ end
98
+ end
99
+
100
+ context "with bad filter" do
101
+ subject { instance.activities(filter: :bad) }
102
+ specify do
103
+ expect { subject }.to raise_error /bad activities filter/i
104
+ end
105
+ end
106
+ end
107
+
108
+ end
109
+
110
+ context "without access token" do
111
+ before(:all) { setup_config(:client) }
112
+ specify do
113
+ expect { subject }.to raise_error /access_token/
114
+ end
115
+ end
116
+
117
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ require 'red_haze/playlist'
3
+
4
+ describe RedHaze::Playlist do
5
+ before(:all) { setup_config(:client) }
6
+
7
+ let(:instance) { described_class.new(2161228) }
8
+
9
+ describe "#sync" do
10
+ subject { VCR.use_cassette("playlist") { instance.sync } }
11
+ its(:id) { should be_an Integer }
12
+ its(:created_at) { should be_a DateTime }
13
+ its(:user_id) { should be_an Integer }
14
+ its(:user) { should be_a RedHaze::User }
15
+ its(:title) { should be_a String }
16
+ its(:permalink) { should be_a String }
17
+ its(:permalink_url) { should be_a String }
18
+ its(:url) { should be_a String }
19
+ its(:sharing) { should be_a String }
20
+ #its(:purchase_url) { should be_a String }
21
+ #its(:artwork_url) { should be_a String }
22
+ its(:description) { should be_a String }
23
+ #its(:label) { should be_a String }
24
+ its(:duration) { should be_an Integer }
25
+ its(:streamable) { should be_boolean }
26
+ its(:downloadable) { should be_boolean }
27
+
28
+ end
29
+
30
+ describe "#shared_to_emails" do
31
+ #subject { instance.shared_to_emails }
32
+ #it { should be_an_array_of String }
33
+ pending "need token"
34
+ end
35
+
36
+ describe "#shared_to_emails" do
37
+ #subject { instance.shared_to_emails }
38
+ #it { should be_an_array_of String }
39
+ pending "need token"
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe RedHaze::Request do
4
+
5
+ context "oauth request" do
6
+ before(:all) { setup_config(:oauth) }
7
+ specify { described_class.base_uri.should == 'https://api.soundcloud.com'}
8
+ end
9
+
10
+ context "non-oauth request" do
11
+ before(:all) { setup_config(:client) }
12
+ specify { described_class.base_uri.should == 'http://api.soundcloud.com'}
13
+ end
14
+
15
+ specify { described_class.headers['Accept'].should == 'application/json' }
16
+
17
+ end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ describe RedHaze::Track do
4
+ before(:all) { setup_config(:client) }
5
+
6
+ let(:instance) { described_class.new(49518905) }
7
+ let(:synced_track) do
8
+ VCR.use_cassette('track_sync') { instance.sync }
9
+ end
10
+
11
+ describe "#initialize" do
12
+ subject { instance }
13
+ specify { should be_a described_class }
14
+ its(:id) { should == 49518905 }
15
+ end
16
+
17
+ describe "#tag_list" do
18
+ pending
19
+ end
20
+
21
+ describe "#sync" do
22
+ subject { synced_track }
23
+
24
+ its(:created_at) { should be_a DateTime }
25
+ its(:user_id) { should be_an Integer }
26
+ its(:title) { should be_a String }
27
+ its(:permalink) { should be_a String }
28
+ its(:permalink_url) { should =~ /http:\/\/soundcloud.com/ }
29
+ its(:uri) { should =~ /http:\/\/api.soundcloud.com/ }
30
+ its(:sharing) { should be_a String }
31
+ its(:purchase_url) { should =~ /http:\/\// }
32
+ its(:artwork_url) { should =~ /http:\/\/.*\.jpg/ }
33
+ its(:description) { should be_a String }
34
+ its(:duration) { should be_an Integer }
35
+ its(:genre) { should be_a String }
36
+ its(:label_name) { should be_a String }
37
+ its(:license) { should be_a String }
38
+ its(:release) { should be_a String }
39
+ its(:streamable) { should be_boolean }
40
+ its(:downloadable) { should be_boolean }
41
+ its(:state) { should be_a String }
42
+ its(:waveform_url) { should =~ /http:\/\/.*\.png/ }
43
+ its(:commentable) { should be_boolean }
44
+ its(:comment_count) { should be_an Integer }
45
+ its(:download_count) { should be_an Integer }
46
+ its(:playback_count) { should be_an Integer }
47
+ its(:favoritings_count) { should be_an Integer }
48
+ its(:original_format) { should be_a String }
49
+ its(:original_content_size) { should be_an Integer }
50
+
51
+ #no test data
52
+ #its(:label_id) { should be_nil }
53
+ #its(:release_day) { should be_nil }
54
+ #its(:release_month) { should be_nil }
55
+ #its(:release_year) { should be_nil }
56
+ #its(:track_type) { should be_nil }
57
+ #its(:bpm) { should be_nil }
58
+ #its(:isrc) { should be_nil }
59
+ end
60
+
61
+ describe "#comments" do
62
+ subject do
63
+ VCR.use_cassette("track_comments") { instance.comments }
64
+ end
65
+
66
+ it { should return_an_array_of RedHaze::Comment }
67
+ end
68
+
69
+ describe "#favoriters" do
70
+ subject do
71
+ VCR.use_cassette('track_favoriters') { instance.favoriters }
72
+ end
73
+ it { should return_an_array_of RedHaze::User }
74
+ end
75
+
76
+ describe "#shared_to" do
77
+ pending "Do not have any actual data for this"
78
+ #subject do
79
+ # VCR.use_cassette('track_shared_tos') { instance.shared_to }
80
+ #end
81
+ #it { should be_an_array_of RedHaze::Track }
82
+ end
83
+
84
+ describe "#secret_token" do
85
+ pending
86
+ end
87
+
88
+ describe "#owner" do
89
+ subject { synced_track.owner }
90
+ it { should be_a RedHaze::User }
91
+ end
92
+
93
+ describe "#comment" do
94
+ pending
95
+ end
96
+ end
@@ -0,0 +1,110 @@
1
+ require 'spec_helper'
2
+
3
+ describe RedHaze::User do
4
+ let(:instance) { described_class.new(2879548) }
5
+ context "without auth" do
6
+ before(:all) { setup_config(:client) }
7
+
8
+
9
+ describe "#initialize" do
10
+ subject { instance }
11
+ specify { should be_a described_class }
12
+ its(:id) { should be_an Integer }
13
+ end
14
+
15
+ describe "#sync" do
16
+ subject do
17
+ VCR.use_cassette('user_sync') { instance.sync }
18
+ end
19
+ it { should be_a described_class }
20
+ its(:permalink) { should be_a String }
21
+ its(:username) { should be_a String }
22
+ its(:uri) { should =~ /http:\/\/api.soundcloud.com\/*/ }
23
+ its(:permalink_url) { should =~ /http:\/\/soundcloud.com\/*/ }
24
+ its(:avatar_url) { should =~ /http:\/\/.*.jpg/ }
25
+ its(:country) { should be_a String }
26
+ its(:full_name) { should be_a String }
27
+ its(:city) { should be_a String }
28
+ its(:description) { should be_a String }
29
+ its(:website) { should be_a String }
30
+ its(:online) { should be_boolean }
31
+ its(:track_count) { should be_an Integer }
32
+ its(:playlist_count) { should be_an Integer }
33
+ its(:followers_count) { should be_an Integer }
34
+ its(:followings_count) { should be_an Integer }
35
+ its(:public_favorites_count) { should be_an Integer }
36
+ its(:website_title) { should be_a String }
37
+
38
+ # no real data for these
39
+ its(:discogs_name) { should be_nil }
40
+ its(:myspace_name) { should be_nil }
41
+ end
42
+
43
+ describe "#playlists" do
44
+ subject do
45
+ VCR.use_cassette('user_playlists') { instance.playlists }
46
+ end
47
+ it { should return_an_array_of RedHaze::Playlist }
48
+ end
49
+
50
+ describe "#followings" do
51
+ context "with arg" do
52
+ context "valid followings user id" do
53
+ subject do
54
+ VCR.use_cassette("user_followings_valid_id") do
55
+ instance.followings(903649)
56
+ end
57
+ end
58
+ #it { should be_an_array_of RedHaze::User }
59
+ pending "need authorization"
60
+ end
61
+ end
62
+
63
+ context "without arg" do
64
+ subject do
65
+ VCR.use_cassette("user_followings") { instance.followings }
66
+ end
67
+ it { return_an_array_of return_an_array_of RedHaze::User }
68
+ end
69
+ end
70
+
71
+ describe "#followers" do
72
+ subject do
73
+ VCR.use_cassette('user_followers') { instance.followers }
74
+ end
75
+ it { should return_an_array_of RedHaze::User }
76
+ end
77
+
78
+ describe "#comments" do
79
+ subject do
80
+ VCR.use_cassette('user_comments') { instance.comments }
81
+ end
82
+ it { should return_an_array_of RedHaze::Comment }
83
+ end
84
+
85
+ describe "#groups" do
86
+ subject do
87
+ VCR.use_cassette('user_groups') { instance.groups }
88
+ end
89
+ it { should return_an_array_of RedHaze::Group }
90
+ end
91
+
92
+ describe "#web_profiles" do
93
+ pending
94
+ end
95
+
96
+ describe "#favorites" do
97
+ context "with arg" do
98
+ pending "need authentication"
99
+ end
100
+ context "without arg" do
101
+ subject do
102
+ VCR.use_cassette("user_favorites") { instance.favorites }
103
+ end
104
+
105
+ it { should return_an_array_of RedHaze::Track }
106
+ end
107
+ end
108
+ end
109
+
110
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe RedHaze do
4
+ describe ".configure" do
5
+ subject { described_class.configure(client_id: 'id', client_secret: 'secret') }
6
+ its(:client) { should be_a RedHaze::Client }
7
+ end
8
+
9
+ describe ".configure_from_file" do
10
+ subject { described_class.configure_from_file 'config.template.yml' }
11
+ its(:client) { should be_a RedHaze::Client }
12
+ end
13
+ end