lonely_coder 0.1.3 → 0.1.4
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/CHANGELOG +3 -0
- data/lib/lonely_coder/profile.rb +12 -0
- data/lib/lonely_coder/search.rb +31 -15
- data/lib/lonely_coder.rb +1 -1
- data/lonely_coder.gemspec +1 -1
- data/spec/cassettes/load_profile_from_search.yml +1284 -723
- data/spec/cassettes/paginate_search_results_by_10.yml +1410 -791
- data/spec/cassettes/paginate_search_results_by_10_with_failure.yml +1502 -0
- data/spec/cassettes/search_by_filters.yml +1315 -733
- data/spec/cassettes/search_finding_no_results.yml +1365 -0
- data/spec/pagination_spec.rb +44 -12
- data/spec/profile_spec.rb +23 -10
- data/spec/search_spec.rb +13 -2
- metadata +7 -2
data/spec/pagination_spec.rb
CHANGED
@@ -1,20 +1,52 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "pagination" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
describe "success" do
|
5
|
+
before(:each) do
|
6
|
+
VCR.use_cassette('paginate_search_results_by_10', :erb => {:username => ENV['OKC_USERNAME'], :password => ENV['OKC_PASSWORD']}) do
|
7
|
+
okc = OKCupid.new(ENV['OKC_USERNAME'], ENV['OKC_PASSWORD'])
|
8
|
+
|
9
|
+
@search = okc.search({
|
10
|
+
gentation: 'girls who like guys',
|
11
|
+
location: 4356796
|
12
|
+
})
|
13
|
+
@search.results
|
14
|
+
@did_it_work = @search.load_next_page
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "snags 10 more results" do
|
19
|
+
@search.results.size.should == 20
|
20
|
+
@search.results.all? {|p| p.kind_of?(OKCupid::Profile)}.should == true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns true" do
|
24
|
+
@did_it_work.should == true
|
13
25
|
end
|
14
26
|
end
|
15
27
|
|
16
|
-
|
17
|
-
|
18
|
-
|
28
|
+
describe "failure" do
|
29
|
+
before(:each) do
|
30
|
+
VCR.use_cassette('paginate_search_results_by_10_with_failure', :erb => {:username => ENV['OKC_USERNAME'], :password => ENV['OKC_PASSWORD']}) do
|
31
|
+
okc = OKCupid.new(ENV['OKC_USERNAME'], ENV['OKC_PASSWORD'])
|
32
|
+
|
33
|
+
@search = okc.search({
|
34
|
+
gentation: 'guys who like guys',
|
35
|
+
location: 4204350, # "Provo, Utah"
|
36
|
+
min_age: 30,
|
37
|
+
max_age: 30
|
38
|
+
})
|
39
|
+
@count = @search.results.size
|
40
|
+
@did_it_work = @search.load_next_page
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "doesn't snag any more results" do
|
45
|
+
@search.results.size.should == @count
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns false" do
|
49
|
+
@did_it_work.should == false
|
50
|
+
end
|
19
51
|
end
|
20
52
|
end
|
data/spec/profile_spec.rb
CHANGED
@@ -5,6 +5,16 @@ describe "Profile" do
|
|
5
5
|
it "checks for equality based on username" do
|
6
6
|
OKCupid::Profile.new(:username => 'someguy', :age => 22).should == OKCupid::Profile.new(:username => 'someguy', :age => 35)
|
7
7
|
end
|
8
|
+
|
9
|
+
it "checks for object equality based on username" do
|
10
|
+
OKCupid::Profile.new(:username => 'someguy', :age => 22).should eql(OKCupid::Profile.new(:username => 'someguy', :age => 35))
|
11
|
+
end
|
12
|
+
|
13
|
+
it "hashes itself by username if present, for Set inclusion" do
|
14
|
+
one = OKCupid::Profile.new(:username => 'someguy')
|
15
|
+
two = OKCupid::Profile.new(:username => 'someguy')
|
16
|
+
one.hash.should == two.hash
|
17
|
+
end
|
8
18
|
end
|
9
19
|
|
10
20
|
describe "Profile from specific find" do
|
@@ -125,6 +135,7 @@ describe "Profile from specific find" do
|
|
125
135
|
end
|
126
136
|
|
127
137
|
describe "Profile from search result" do
|
138
|
+
# N.B. we used to check for specific values. This is maddening. Now we match found values to a regexp or Ruby class.
|
128
139
|
before(:each) do
|
129
140
|
VCR.use_cassette('load_profile_from_search', :erb => {:username => ENV['OKC_USERNAME'], :password => ENV['OKC_PASSWORD']}) do
|
130
141
|
@profile = OKCupid.new(ENV['OKC_USERNAME'], ENV['OKC_PASSWORD']).search({
|
@@ -134,42 +145,44 @@ describe "Profile from search result" do
|
|
134
145
|
end
|
135
146
|
|
136
147
|
it "has a username" do
|
137
|
-
@profile.username.should
|
148
|
+
@profile.username.should be_kind_of(String)
|
138
149
|
end
|
139
150
|
|
140
151
|
it "has an age" do
|
141
|
-
@profile.age.should
|
152
|
+
@profile.age.should be_kind_of(String)
|
142
153
|
end
|
143
154
|
|
144
155
|
it "has a match %" do
|
145
|
-
@profile.match.should
|
156
|
+
@profile.match.should be_kind_of(Integer)
|
146
157
|
end
|
147
158
|
|
148
159
|
it "has a friend %" do
|
149
|
-
@profile.friend.should
|
160
|
+
@profile.friend.should be_kind_of(Integer)
|
150
161
|
end
|
151
162
|
|
152
163
|
it "has an enemy %" do
|
153
|
-
@profile.enemy.should
|
164
|
+
@profile.enemy.should be_kind_of(Integer)
|
154
165
|
end
|
155
166
|
|
156
167
|
it "has a location" do
|
157
|
-
@profile.location.should
|
168
|
+
@profile.location.should match(/[\w]+, [\w]+/)
|
158
169
|
end
|
159
170
|
|
160
171
|
it "has a small avatar url" do
|
161
|
-
@profile.small_avatar_url.should
|
172
|
+
@profile.small_avatar_url.should match(/^http:\/\//)
|
173
|
+
#== 'http://ak2.okccdn.com/php/load_okc_image.php/images/82x82/82x82/14x56/323x365/2/853930758706783150.jpeg'
|
162
174
|
end
|
163
175
|
|
164
176
|
it "has a sex" do
|
165
|
-
|
177
|
+
sexes = ['M', 'F']
|
178
|
+
sexes.should include(@profile.sex)
|
166
179
|
end
|
167
180
|
|
168
181
|
it "has an orientation" do
|
169
|
-
@profile.orientation.should
|
182
|
+
@profile.orientation.should be_kind_of(String)
|
170
183
|
end
|
171
184
|
|
172
185
|
it "has a signle status" do
|
173
|
-
@profile.single.should
|
186
|
+
@profile.single.should be_kind_of(String)
|
174
187
|
end
|
175
188
|
end
|
data/spec/search_spec.rb
CHANGED
@@ -46,14 +46,25 @@ describe "Search" do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "Results" do
|
49
|
-
it "returns an
|
49
|
+
it "returns an empty collection if nothing is found" do
|
50
|
+
VCR.use_cassette('search_finding_no_results', :erb => {:username => ENV['OKC_USERNAME'], :password => ENV['OKC_PASSWORD']}) do
|
51
|
+
@results = OKCupid.new(ENV['OKC_USERNAME'], ENV['OKC_PASSWORD']).search({
|
52
|
+
gentation: 'guys who like guys',
|
53
|
+
min_age: 25,
|
54
|
+
max_age: 25,
|
55
|
+
location: 4195656
|
56
|
+
}).results
|
57
|
+
end
|
58
|
+
@results.empty?.should == true
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns an collection of OKCupid::Profile objects" do
|
50
62
|
VCR.use_cassette('search_by_filters', :erb => {:username => ENV['OKC_USERNAME'], :password => ENV['OKC_PASSWORD']}) do
|
51
63
|
@results = OKCupid.new(ENV['OKC_USERNAME'], ENV['OKC_PASSWORD']).search({
|
52
64
|
gentation: 'girls who like guys'
|
53
65
|
}).results
|
54
66
|
end
|
55
67
|
|
56
|
-
@results.should be_kind_of(Array)
|
57
68
|
@results.size.should == 10
|
58
69
|
@results.all? {|p| p.kind_of?(OKCupid::Profile)}.should == true
|
59
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lonely_coder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
@@ -50,6 +50,7 @@ executables: []
|
|
50
50
|
extensions: []
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
|
+
- CHANGELOG
|
53
54
|
- Gemfile
|
54
55
|
- README.mdown
|
55
56
|
- lib/lonely_coder.rb
|
@@ -68,8 +69,10 @@ files:
|
|
68
69
|
- spec/cassettes/loading_mailbox.yml
|
69
70
|
- spec/cassettes/location_filter_looks_up_location_id.yml
|
70
71
|
- spec/cassettes/paginate_search_results_by_10.yml
|
72
|
+
- spec/cassettes/paginate_search_results_by_10_with_failure.yml
|
71
73
|
- spec/cassettes/search_by_filters.yml
|
72
74
|
- spec/cassettes/search_by_username.yml
|
75
|
+
- spec/cassettes/search_finding_no_results.yml
|
73
76
|
- spec/cassettes/search_that_includes_a_location.yml
|
74
77
|
- spec/cassettes/successful_authentication.yml
|
75
78
|
- spec/helper_spec.rb
|
@@ -114,8 +117,10 @@ test_files:
|
|
114
117
|
- spec/cassettes/loading_mailbox.yml
|
115
118
|
- spec/cassettes/location_filter_looks_up_location_id.yml
|
116
119
|
- spec/cassettes/paginate_search_results_by_10.yml
|
120
|
+
- spec/cassettes/paginate_search_results_by_10_with_failure.yml
|
117
121
|
- spec/cassettes/search_by_filters.yml
|
118
122
|
- spec/cassettes/search_by_username.yml
|
123
|
+
- spec/cassettes/search_finding_no_results.yml
|
119
124
|
- spec/cassettes/search_that_includes_a_location.yml
|
120
125
|
- spec/cassettes/successful_authentication.yml
|
121
126
|
- spec/helper_spec.rb
|