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.
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Hypem do
4
4
  describe "convenience methods" do
5
5
  it "can access playlist class" do
6
- # pending
6
+ Hypem.playlist.should == Hypem::Playlist
7
7
  end
8
8
 
9
9
  it "can access user class" do
@@ -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'){Hypem::Playlist.latest}
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'){Hypem::Playlist.blog(1)}
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/time/today/json/1"
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
- describe "after get" do
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 ".create" do
30
+ describe ".create_url" do
38
31
  let(:tracks) {[mock('Hypem::Track',id: 'track1',), mock('Hypem::Track',id:'track2')]}
39
32
 
40
- it "requires an array of tracks" do
41
- expect { Hypem::Playlist.create_url(['not_a_track'])}.to raise_error ArgumentError
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
- Hypem::Playlist.create_url(tracks).should == 'http://hypem.com/playlist/set/track1,track2/json/1'
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
- it "returns a playlist" do
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 {Hypem::Playlist.stub_chain(:new, :get)}
48
+ before { described_class.stub_chain(:new, :get) }
58
49
 
59
50
  it "converts strings to symbols" do
60
- Hypem::Playlist.should_receive(:new).with(:popular,%s(3day),anything)
61
- Hypem::Playlist.popular('3day')
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
- Hypem::Playlist.should_receive(:new).with(:popular,%s(3day),anything)
66
- Hypem::Playlist.popular
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
- Hypem::Playlist.should_receive(:new).with(:popular,:lastweek,anything)
71
- Hypem::Playlist.popular(:lastweek)
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
- Hypem::Playlist.should_receive(:new).with(:popular,:noremix,anything)
76
- Hypem::Playlist.popular(:noremix)
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
- Hypem::Playlist.should_receive(:new).with(:popular,:artists,anything)
81
- Hypem::Playlist.popular(:artists)
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
- Hypem::Playlist.should_receive(:new).with(:popular,:twitter,anything)
86
- Hypem::Playlist.popular(:twitter)
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 {Hypem::Playlist.popular(:no_no)}.to raise_error(ArgumentError)
81
+ expect {described_class.popular(:no_no)}.to raise_error(ArgumentError)
91
82
  end
92
83
  end
93
84
 
94
- context "class methods" do
95
- before {Hypem::Playlist.stub_chain(:new, :get)}
96
-
97
- describe ".blog" do
98
- it "calls new with type blog" do
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
- describe ".tags" do
105
- it "creates a tag playlist from a string" do
106
- Hypem::Playlist.should_receive(:new).with(:tags,'tag1,tag2',5)
107
- Hypem::Playlist.tags('tag1,tag2',5)
108
- end
109
- it "creates a tag playlist from an array of strings" do
110
- Hypem::Playlist.should_receive(:new).with(:tags,'tag1,tag2',5)
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
- describe ".search" do
116
- it "calls new with type search" do
117
- Hypem::Playlist.should_receive(:new).with(:search,'query',5)
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
- describe ".artist" do
123
- it "calls new with type artist" do
124
- Hypem::Playlist.should_receive(:new).with(:artist,'name',5)
125
- Hypem::Playlist.artist('name',5)
126
- end
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
- Hypem::Playlist.stub_chain(:new,:get)
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
- Hypem::Playlist.should_receive(:new).with(anything,anything,2)
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
- Hypem::Playlist.should_receive(:new).with(anything,anything,0)
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
- Hypem::Playlist.should_receive(:new).with(anything,anything,5)
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
@@ -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
- it "initializes with a name parameter" do
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
- it "gets a loved playlist" do
15
- VCR.use_cassette('loved_playlist') do
16
- user.loved_playlist.should be_a Hypem::Playlist
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
- it "gets an obsessed playlist" do
21
- VCR.use_cassette('obsessed_playlist') do
22
- user.obsessed_playlist.should be_a Hypem::Playlist
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
- it "gets a feed playlist" do
27
- VCR.use_cassette('feed_playlist') do
28
- user.feed_playlist.should be_a Hypem::Playlist
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
- it "gets friends' playlist" do
33
- VCR.use_cassette('friends_playlist') do
34
- user.friends_favorites_playlist.should be_a Hypem::Playlist
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
- it "gets a friends' history playlist" do
39
- VCR.use_cassette('friends_history') do
40
- user.friends_history_playlist.should be_a Hypem::Playlist
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 ".get_profile" do
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 ".friends" do
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 ".favorite_blogs" do
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
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-05-24 00:00:00.000000000 Z
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: &70124648838920 !ruby/object:Gem::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: *70124648838920
24
+ version_requirements: *70329316144900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: vcr
27
- requirement: &70124648838460 !ruby/object:Gem::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: *70124648838460
35
+ version_requirements: *70329316144440
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70124648838080 !ruby/object:Gem::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: *70124648838080
46
+ version_requirements: *70329316144060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: faraday
49
- requirement: &70124648837540 !ruby/object:Gem::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: *70124648837540
57
+ version_requirements: *70329316143520
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: multi_json
60
- requirement: &70124648837040 !ruby/object:Gem::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: *70124648837040
68
+ version_requirements: *70329316143020
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: hashie
71
- requirement: &70124648836580 !ruby/object:Gem::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: *70124648836580
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: 1984432069541911698
145
+ hash: 3059941134840549137
145
146
  requirements: []
146
147
  rubyforge_project: hypem
147
148
  rubygems_version: 1.8.10