graticule 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,7 @@ require 'graticule/geocoder/bogus'
10
10
  require 'graticule/geocoder/rest'
11
11
  require 'graticule/geocoder/google'
12
12
  require 'graticule/geocoder/host_ip'
13
+ require 'graticule/geocoder/multi'
13
14
  require 'graticule/geocoder/yahoo'
14
15
  require 'graticule/geocoder/geocoder_ca'
15
16
  require 'graticule/geocoder/geocoder_us'
@@ -2,7 +2,7 @@ module Graticule #:nodoc:
2
2
  module Version #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -8,6 +8,7 @@ require 'yaml'
8
8
  require 'test/unit'
9
9
  require 'breakpoint'
10
10
  require 'graticule'
11
+ require 'mocha'
11
12
 
12
13
  TEST_RESPONSE_PATH = File.dirname(__FILE__) + '/fixtures/responses'
13
14
 
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../../../test_helper'
2
+
3
+ module Graticule
4
+ module Geocoder
5
+ class MultiTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @mock_geocoders = [mock("geocoder 1"), mock("geocoder 2")]
9
+ @mock_geocoders.each {|g| g.stubs(:locate) }
10
+ @geocoder = Multi.new *@mock_geocoders
11
+ end
12
+
13
+ def test_locate_calls_each_geocoder_and_raises_error
14
+ @mock_geocoders.each do |g|
15
+ g.expects(:locate).with('test').raises(Graticule::AddressError)
16
+ end
17
+ assert_raises(Graticule::AddressError) { @geocoder.locate 'test' }
18
+ end
19
+
20
+ def test_locate_returns_first_result_without_calling_others
21
+ result = mock("result")
22
+ @mock_geocoders.first.expects(:locate).returns(result)
23
+ @mock_geocoders.last.expects(:locate).never
24
+ assert_equal result, @geocoder.locate('test')
25
+ end
26
+
27
+ def test_locate_with_custom_block
28
+ @mock_geocoders.first.expects(:locate).returns(1)
29
+ @mock_geocoders.last.expects(:locate).returns(2)
30
+ @geocoder = Multi.new(*@mock_geocoders) {|r| r == 2 }
31
+ assert_equal 2, @geocoder.locate('test')
32
+ end
33
+
34
+ def test_locate_with_custom_block_and_no_match
35
+ @mock_geocoders.first.expects(:locate).returns(1)
36
+ @mock_geocoders.last.expects(:locate).returns(2)
37
+ @geocoder = Multi.new(*@mock_geocoders) {|r| r == 3 }
38
+ assert_raises(Graticule::AddressError) { @geocoder.locate('test') }
39
+ end
40
+
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: graticule
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.4
7
- date: 2007-05-15 00:00:00 -04:00
6
+ version: 0.2.5
7
+ date: 2007-09-12 00:00:00 -04:00
8
8
  summary: API for using all the popular geocoding services.
9
9
  require_paths:
10
10
  - lib
@@ -100,19 +100,30 @@ files:
100
100
  - test/unit/graticule/location_test.rb
101
101
  test_files:
102
102
  - test/unit/graticule/distance_test.rb
103
- - test/unit/graticule/geocoder_test.rb
104
- - test/unit/graticule/location_test.rb
105
103
  - test/unit/graticule/geocoder/geocoder_us_test.rb
106
104
  - test/unit/graticule/geocoder/google_test.rb
107
105
  - test/unit/graticule/geocoder/host_ip_test.rb
108
106
  - test/unit/graticule/geocoder/local_search_maps_test.rb
109
107
  - test/unit/graticule/geocoder/meta_carta_test.rb
108
+ - test/unit/graticule/geocoder/multi_test.rb
110
109
  - test/unit/graticule/geocoder/postcode_anywhere_test.rb
111
110
  - test/unit/graticule/geocoder/yahoo_test.rb
112
- rdoc_options: []
113
-
114
- extra_rdoc_files: []
115
-
111
+ - test/unit/graticule/geocoder_test.rb
112
+ - test/unit/graticule/location_test.rb
113
+ rdoc_options:
114
+ - --main
115
+ - README.txt
116
+ extra_rdoc_files:
117
+ - CHANGELOG.txt
118
+ - LICENSE.txt
119
+ - Manifest.txt
120
+ - README.txt
121
+ - test/fixtures/responses/host_ip/private.txt
122
+ - test/fixtures/responses/host_ip/success.txt
123
+ - test/fixtures/responses/host_ip/unknown.txt
124
+ - test/fixtures/responses/local_search_maps/empty.txt
125
+ - test/fixtures/responses/local_search_maps/not_found.txt
126
+ - test/fixtures/responses/local_search_maps/success.txt
116
127
  executables:
117
128
  - geocode
118
129
  extensions: []
@@ -136,5 +147,5 @@ dependencies:
136
147
  requirements:
137
148
  - - ">="
138
149
  - !ruby/object:Gem::Version
139
- version: 1.2.0
150
+ version: 1.3.0
140
151
  version: