geonames_api 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/geonames_api/version.rb +1 -1
- data/spec/geonames_api/place_search_spec.rb +22 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b04085ba81b7f7d468df252648f0b343e510a422
|
4
|
+
data.tar.gz: c9d634bfbdf444b769f43abd67bc2a5b2238ef56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d083c2f06f3b1a5f4d2d624206f586e652df601caea5ec3d78b3be993bac3252fc3b7ff93782dbbc1896573f1f00112bb73843ff5e11550adc274bb1490cc11c
|
7
|
+
data.tar.gz: 1cdc8e7ee3166aec78f9e4c41b3023410c3e0a173e8900a5fb6e8210a2a1f7d63d9dfe1d44449660d4c8d3a7fc8d11b284199fb822da7c5d4777318aa3e2c7a0
|
data/lib/geonames_api/version.rb
CHANGED
@@ -28,24 +28,35 @@ describe GeoNamesAPI::PlaceSearch do
|
|
28
28
|
|
29
29
|
describe "#next_page" do
|
30
30
|
it "should grab the next page of results from the same search" do
|
31
|
-
|
32
|
-
big_search = GeoNamesAPI::PlaceSearch.where(name: 'goleta', maxRows:
|
33
|
-
search_pg1 = GeoNamesAPI::PlaceSearch.where(name: 'goleta', maxRows:
|
31
|
+
page_size = 3
|
32
|
+
big_search = GeoNamesAPI::PlaceSearch.where(name: 'goleta', maxRows: page_size * 4)
|
33
|
+
search_pg1 = GeoNamesAPI::PlaceSearch.where(name: 'goleta', maxRows: page_size)
|
34
|
+
search_pg1.size.should == page_size
|
35
|
+
|
34
36
|
search_pg2 = search_pg1.next_page
|
37
|
+
search_pg2.size.should == page_size
|
38
|
+
search_pg2.request_params[:startRow].should == page_size
|
39
|
+
|
35
40
|
search_pg3 = search_pg2.next_page
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
search_pg3.request_params[:startRow].should == page_size * 2
|
42
|
+
search_pg3.size.should == page_size
|
43
|
+
|
44
|
+
# Ordering isn't always deterministic, so we're just looking for an overlap bigger than 1 page size:
|
45
|
+
expected_ids = big_search.results.map { |ea| ea.geoname_id }
|
46
|
+
paged_ids = (search_pg1.results + search_pg2.results + search_pg3.results).map { |ea| ea.geoname_id }
|
47
|
+
matching_ids = paged_ids & expected_ids
|
48
|
+
if matching_ids.size <= page_size
|
49
|
+
# use .should just to render a nice error message:
|
50
|
+
paged_ids.should =~ matching_ids
|
51
|
+
end
|
41
52
|
end
|
42
53
|
end
|
43
54
|
|
44
55
|
describe "#to_page" do
|
45
|
-
it "should
|
46
|
-
search10 = GeoNamesAPI::PlaceSearch.all("columbus", 10)
|
56
|
+
it "should set startRow appropriately" do
|
47
57
|
search2 = GeoNamesAPI::PlaceSearch.all("columbus", 2)
|
48
|
-
search2.to_page(4)
|
58
|
+
page4 = search2.to_page(4)
|
59
|
+
page4.request_params[:startRow].should == 8
|
49
60
|
end
|
50
61
|
end
|
51
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geonames_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Devine
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|