hypem 0.1.4 → 0.1.5
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/README.md +26 -43
- data/fixtures/vcr_cassettes/blog_all.yml +1353 -0
- data/fixtures/vcr_cassettes/latest_playlist.yml +178 -188
- data/lib/hypem/blog.rb +6 -0
- data/lib/hypem/playlist.rb +4 -3
- data/lib/hypem/version.rb +1 -1
- data/spec/blog_spec.rb +7 -7
- data/spec/hypem_spec.rb +1 -1
- data/spec/playlist_spec.rb +67 -73
- data/spec/user_spec.rb +25 -21
- metadata +16 -15
data/spec/hypem_spec.rb
CHANGED
data/spec/playlist_spec.rb
CHANGED
@@ -2,158 +2,152 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Hypem::Playlist do
|
4
4
|
let(:playlist) do
|
5
|
-
VCR.use_cassette('latest_playlist'){
|
5
|
+
VCR.use_cassette('latest_playlist'){described_class.latest}
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:blog_playlist) do
|
9
|
-
VCR.use_cassette('blog_playlist'){
|
9
|
+
VCR.use_cassette('blog_playlist'){described_class.blog(1)}
|
10
10
|
end
|
11
|
+
|
12
|
+
subject { playlist }
|
13
|
+
|
14
|
+
########################################
|
11
15
|
|
12
16
|
context "when initialized" do
|
13
|
-
|
14
17
|
it "assigns the path attribute" do
|
15
|
-
playlist.path.should == "/playlist/
|
18
|
+
playlist.path.should == "/playlist/latest/all/json/1"
|
16
19
|
end
|
17
20
|
|
18
21
|
it "assigns proper path for blog" do
|
19
22
|
blog_playlist.path.should == "/playlist/blog/1/json/1"
|
20
23
|
end
|
21
|
-
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
it "should be a playlist" do
|
27
|
-
playlist.should be_a Hypem::Playlist
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "tracks" do
|
31
|
-
it "should assign tracks attribute" do
|
32
|
-
playlist.tracks.should_not be_nil
|
33
|
-
end
|
34
|
-
end
|
26
|
+
context "after get" do
|
27
|
+
its(:tracks) { should_not be_empty }
|
35
28
|
end
|
36
29
|
|
37
|
-
describe ".
|
30
|
+
describe ".create_url" do
|
38
31
|
let(:tracks) {[mock('Hypem::Track',id: 'track1',), mock('Hypem::Track',id:'track2')]}
|
39
32
|
|
40
|
-
it "
|
41
|
-
expect {
|
33
|
+
it "raises if not given an array of tracks" do
|
34
|
+
expect { described_class.create_url(['not_a_track'])}.to raise_error ArgumentError
|
42
35
|
end
|
43
36
|
|
44
37
|
it "returns the correct playlist url " do
|
45
38
|
tracks.first.stub(:is_a?).and_return(true)
|
46
|
-
|
39
|
+
described_class.create_url(tracks).should == 'http://hypem.com/playlist/set/track1,track2/json/1'
|
47
40
|
end
|
48
41
|
end
|
49
42
|
|
50
43
|
describe ".latest" do
|
51
|
-
|
52
|
-
playlist.should be_a Hypem::Playlist
|
53
|
-
end
|
44
|
+
specify { playlist.should be_a described_class }
|
54
45
|
end
|
55
46
|
|
56
47
|
describe ".popular" do
|
57
|
-
before {
|
48
|
+
before { described_class.stub_chain(:new, :get) }
|
58
49
|
|
59
50
|
it "converts strings to symbols" do
|
60
|
-
|
61
|
-
|
51
|
+
described_class.should_receive(:new).with(:popular,%s(3day),anything)
|
52
|
+
described_class.popular('3day')
|
62
53
|
end
|
63
54
|
|
64
55
|
it "retrieves 3day by default" do
|
65
|
-
|
66
|
-
|
56
|
+
described_class.should_receive(:new).with(:popular,%s(3day),anything)
|
57
|
+
described_class.popular
|
67
58
|
end
|
68
59
|
|
69
60
|
it "accepts lastweek" do
|
70
|
-
|
71
|
-
|
61
|
+
described_class.should_receive(:new).with(:popular,:lastweek,anything)
|
62
|
+
described_class.popular(:lastweek)
|
72
63
|
end
|
73
64
|
|
74
65
|
it "accepts noremix" do
|
75
|
-
|
76
|
-
|
66
|
+
described_class.should_receive(:new).with(:popular,:noremix,anything)
|
67
|
+
described_class.popular(:noremix)
|
77
68
|
end
|
78
69
|
|
79
70
|
it "accepts artists" do
|
80
|
-
|
81
|
-
|
71
|
+
described_class.should_receive(:new).with(:popular,:artists,anything)
|
72
|
+
described_class.popular(:artists)
|
82
73
|
end
|
83
74
|
|
84
75
|
it "accepts twitter" do
|
85
|
-
|
86
|
-
|
76
|
+
described_class.should_receive(:new).with(:popular,:twitter,anything)
|
77
|
+
described_class.popular(:twitter)
|
87
78
|
end
|
88
79
|
|
89
80
|
it "rejects anything else" do
|
90
|
-
expect {
|
81
|
+
expect {described_class.popular(:no_no)}.to raise_error(ArgumentError)
|
91
82
|
end
|
92
83
|
end
|
93
84
|
|
94
|
-
|
95
|
-
before {
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
Hypem::Playlist.should_receive(:new).with(:blog,1,5)
|
100
|
-
Hypem::Playlist.blog(1,5)
|
101
|
-
end
|
85
|
+
describe ".blog" do
|
86
|
+
before { described_class.stub_chain(:new,:get) }
|
87
|
+
it "calls new with type blog" do
|
88
|
+
described_class.should_receive(:new).with(:blog,1,5)
|
89
|
+
described_class.blog(1,5)
|
102
90
|
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
Hypem::Playlist.tags(['tag1','tag2'],5)
|
112
|
-
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe ".tags" do
|
94
|
+
before { described_class.stub_chain(:new,:get) }
|
95
|
+
|
96
|
+
it "creates a tag playlist from a string" do
|
97
|
+
described_class.should_receive(:new).with(:tags,'tag1,tag2',5)
|
98
|
+
described_class.tags('tag1,tag2',5)
|
113
99
|
end
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
Hypem::Playlist.search('query',5)
|
119
|
-
end
|
100
|
+
|
101
|
+
it "creates a tag playlist from an array of strings" do
|
102
|
+
described_class.should_receive(:new).with(:tags,'tag1,tag2',5)
|
103
|
+
described_class.tags(['tag1','tag2'],5)
|
120
104
|
end
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
105
|
+
end
|
106
|
+
|
107
|
+
describe ".search" do
|
108
|
+
before { described_class.stub_chain(:new,:get) }
|
109
|
+
|
110
|
+
it "calls new with type search" do
|
111
|
+
described_class.should_receive(:new).with(:search,'query',5)
|
112
|
+
described_class.search('query',5)
|
127
113
|
end
|
128
114
|
end
|
129
|
-
|
115
|
+
|
116
|
+
describe ".artist" do
|
117
|
+
before { described_class.stub_chain(:new,:get) }
|
118
|
+
|
119
|
+
it "calls new with type artist" do
|
120
|
+
described_class.should_receive(:new).with(:artist,'name',5)
|
121
|
+
described_class.artist('name',5)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
130
125
|
describe "pagination" do
|
131
126
|
before do
|
132
127
|
playlist
|
133
|
-
|
128
|
+
described_class.stub_chain(:new,:get)
|
134
129
|
end
|
135
130
|
|
136
131
|
describe "#next_page" do
|
137
132
|
it "gets next page" do
|
138
|
-
|
133
|
+
described_class.should_receive(:new).with(anything,anything,2)
|
139
134
|
playlist.next_page
|
140
135
|
end
|
141
136
|
end
|
142
137
|
|
143
138
|
describe "#prev_page" do
|
144
139
|
it "gets previous page" do
|
145
|
-
|
140
|
+
described_class.should_receive(:new).with(anything,anything,0)
|
146
141
|
playlist.prev_page
|
147
142
|
end
|
148
143
|
end
|
149
144
|
|
150
145
|
describe "#page" do
|
151
146
|
it "gets any page number" do
|
152
|
-
|
147
|
+
described_class.should_receive(:new).with(anything,anything,5)
|
153
148
|
playlist.page(5)
|
154
149
|
end
|
155
150
|
end
|
156
|
-
|
157
151
|
end
|
158
152
|
|
159
153
|
end
|
data/spec/user_spec.rb
CHANGED
@@ -2,46 +2,50 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Hypem::User do
|
4
4
|
let(:user) { Hypem::User.new('jackca') }
|
5
|
+
subject { user }
|
5
6
|
|
6
|
-
|
7
|
-
user.instance_variable_get(:@name).should_not be_nil
|
8
|
-
end
|
7
|
+
its(:name) { should_not be_nil }
|
9
8
|
|
10
9
|
it "throws an error with an invalid username argument" do
|
11
10
|
expect { Hypem::User.new(:not_a_string) }.to raise_error(ArgumentError)
|
12
11
|
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
describe "#loved_playlist" do
|
14
|
+
specify do
|
15
|
+
Hypem::Playlist.should_receive(:loved).with(subject.name,anything)
|
16
|
+
subject.loved_playlist
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
describe "#obsessed_playlist" do
|
21
|
+
specify do
|
22
|
+
Hypem::Playlist.should_receive(:obsessed).with(subject.name,anything)
|
23
|
+
subject.obsessed_playlist
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
describe "#feed_playlist" do
|
28
|
+
specify do
|
29
|
+
Hypem::Playlist.should_receive(:feed).with(subject.name,anything)
|
30
|
+
subject.feed_playlist
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
describe "#friends_favorites_playlist" do
|
35
|
+
specify do
|
36
|
+
Hypem::Playlist.should_receive(:friends_favorites).with(subject.name,anything)
|
37
|
+
subject.friends_favorites_playlist
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
describe "#friends_history_playlist" do
|
42
|
+
specify do
|
43
|
+
Hypem::Playlist.should_receive(:friends_history).with(subject.name,anything)
|
44
|
+
subject.friends_history_playlist
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
44
|
-
describe "
|
48
|
+
describe "#get_profile" do
|
45
49
|
let(:user_with_profile) do
|
46
50
|
VCR.use_cassette('user_profile') {user.get_profile}
|
47
51
|
end
|
@@ -59,7 +63,7 @@ describe Hypem::User do
|
|
59
63
|
its(:followed_queries_count) {should == 15}
|
60
64
|
end
|
61
65
|
|
62
|
-
describe "
|
66
|
+
describe "#friends" do
|
63
67
|
let(:user_with_friends) do
|
64
68
|
VCR.use_cassette('user_friends') {user.friends}
|
65
69
|
end
|
@@ -73,7 +77,7 @@ describe Hypem::User do
|
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
76
|
-
describe "
|
80
|
+
describe "#favorite_blogs" do
|
77
81
|
let(:user_with_favorite_blogs) do
|
78
82
|
VCR.use_cassette('user_favorite_blogs') {user.favorite_blogs}
|
79
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hypem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70329316144900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.6'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70329316144900
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: vcr
|
27
|
-
requirement: &
|
27
|
+
requirement: &70329316144440 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '2.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70329316144440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70329316144060 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70329316144060
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: faraday
|
49
|
-
requirement: &
|
49
|
+
requirement: &70329316143520 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0.7'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70329316143520
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: multi_json
|
60
|
-
requirement: &
|
60
|
+
requirement: &70329316143020 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '1.1'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70329316143020
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: hashie
|
71
|
-
requirement: &
|
71
|
+
requirement: &70329316142560 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '1.2'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70329316142560
|
80
80
|
description:
|
81
81
|
email:
|
82
82
|
- jackcanderson@gmail.com
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- README.md
|
92
92
|
- Rakefile
|
93
93
|
- fixtures/vcr_cassettes/blog.yml
|
94
|
+
- fixtures/vcr_cassettes/blog_all.yml
|
94
95
|
- fixtures/vcr_cassettes/blog_playlist.yml
|
95
96
|
- fixtures/vcr_cassettes/feed_playlist.yml
|
96
97
|
- fixtures/vcr_cassettes/fresh_playlist.yml
|
@@ -141,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
version: '0'
|
142
143
|
segments:
|
143
144
|
- 0
|
144
|
-
hash:
|
145
|
+
hash: 3059941134840549137
|
145
146
|
requirements: []
|
146
147
|
rubyforge_project: hypem
|
147
148
|
rubygems_version: 1.8.10
|