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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b50c12c8caf88cb16c72e51b02e0899f9f6f76df
4
- data.tar.gz: 31bf711659f22e768a31827e15d1577e1d138362
3
+ metadata.gz: b04085ba81b7f7d468df252648f0b343e510a422
4
+ data.tar.gz: c9d634bfbdf444b769f43abd67bc2a5b2238ef56
5
5
  SHA512:
6
- metadata.gz: b09f7294b7b01b99732866b17fb59ae7b96a3065ed06c344a5219cd2737e2f1a6b133ca07d792c05b2b05fcafe63a56d2065bc97697a7df4246b5db7c63f463e
7
- data.tar.gz: c6bc4c9b9326f9837f473231280a2f59a57169a46f453d4c21eee6c39d2635daccc15013746f7a777a63789f5d8c68a047c13d28f3d0ff963af9a22b98aee79c
6
+ metadata.gz: d083c2f06f3b1a5f4d2d624206f586e652df601caea5ec3d78b3be993bac3252fc3b7ff93782dbbc1896573f1f00112bb73843ff5e11550adc274bb1490cc11c
7
+ data.tar.gz: 1cdc8e7ee3166aec78f9e4c41b3023410c3e0a173e8900a5fb6e8210a2a1f7d63d9dfe1d44449660d4c8d3a7fc8d11b284199fb822da7c5d4777318aa3e2c7a0
@@ -1,3 +1,3 @@
1
1
  module GeoNamesAPI
2
- VERSION = Gem::Version.new('0.1.3')
2
+ VERSION = Gem::Version.new('0.1.4')
3
3
  end
@@ -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
- # the paging with 'columbus' sometimes doesn't match across the 3 pages.
32
- big_search = GeoNamesAPI::PlaceSearch.where(name: 'goleta', maxRows: 9)
33
- search_pg1 = GeoNamesAPI::PlaceSearch.where(name: 'goleta', maxRows: 3)
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
- search_pg1.size.should == 3
37
- search_pg2.size.should == 3
38
- search_pg3.size.should == 3
39
- search_pg3.request_params[:startRow].should == 6
40
- (search_pg1.results + search_pg2.results + search_pg3.results).map{|ea|ea.geoname_id}.should == big_search.results.map{|ea|ea.geoname_id}
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 grab the specified page of results from the same search" do
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).first.geoname_id.should == search10.results[8].geoname_id
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.3
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-03-19 00:00:00.000000000 Z
12
+ date: 2014-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport