<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Rakefile</filename>
    </added>
    <added>
      <filename>test/test_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -80,11 +80,11 @@ different combinations:
 
 Origin as a two-element array of latititude/longitude:
 
-		find(:all, :origin=&gt;[37.792,-122.393])
+		find(:all, :origin =&gt; [37.792,-122.393])
 
 Origin as a geocodeable string:
 
-		find(:all, :origin=&gt;'100 Spear st, San Francisco, CA')
+		find(:all, :origin =&gt; '100 Spear st, San Francisco, CA')
 
 Origin as an object which responds to lat and lng methods, 
 or latitude and longitude methods, or whatever methods you have 
@@ -97,7 +97,7 @@ formula for the distance field in the conditions clause.  This saves
 from having to add complicated SQL in the conditions clause.  The result
 set returns model instances that are less than 5 units away.
 
-    find(:all, :origin, :conditions =&gt; &quot;distance &lt; 5&quot;)
+    find(:all, :origin =&gt; @somewhere, :conditions =&gt; &quot;distance &lt; 5&quot;)
 
 NOTE: conditions can also be compound as in 
 :conditions =&gt; &quot;distance &lt; 100 and state ='TX'&quot;.
@@ -108,10 +108,10 @@ from the :options hash prior to invoking the superclass behavior.
 
 Other convenience methods work intuitively and are as follows:
 
-    find_within(distance, options={})
-    find_beyond(distance, options={})
-    find_closest(options={})
-    find_farthest(options={})
+    find_within(distance, :origin =&gt; @somewhere)
+    find_beyond(distance, :origin =&gt; @somewhere)
+    find_closest(:origin =&gt; @somewhere)
+    find_farthest(:origin =&gt; @somewhere)
 
 where the options respect the defaults, but can be overridden if 
 desired.  
@@ -123,6 +123,14 @@ calculations, you can use the following:
 
 Thereafter, you are free to use it in find_by_sql as you wish.
 
+There are methods available to enable you to get the count based upon
+the find condition that you have provided.  These all work similarly to
+the finders.  So for instance:
+
+    count(:origin, :conditions =&gt; &quot;distance &lt; 5&quot;)
+    count_within(distance, :origin =&gt; @somewhere)
+    count_beyond(distance, :origin =&gt; @somewhere)
+
 ## IP GEOCODING
 
 You can obtain the location for an IP at any time using the geocoder</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,9 @@
+author:
+  name_1: Bill Eisenhauer
+  homepage_1: http://blog.billeisenhauer.com
+  name_2: Andre Lewis
+  homepage_2: http://www.earthcode.com
 summary: Geo distance calculations, distance calculation query support, geocoding for physical and ip addresses.
-version: 0.1
-author_1: Bill Eisenhauer
-homepage_1: http://www.billeisenhauer.com
-author_2: Andre Lewis
-homepage_andre: http://www.earthcode.com
+version: 1.0
 rails_version: 1.0+
 license: MIT
\ No newline at end of file</diff>
      <filename>about.yml</filename>
    </modified>
    <modified>
      <diff>@@ -2,22 +2,36 @@
 GeoKit::default_units = :miles
 GeoKit::default_formula = :sphere
 
+# This is the timeout value in seconds to be used for calls to the geocoder web
+# services.  For no timeout at all, comment out the setting.  The timeout unit
+# is in seconds. 
+GeoKit::Geocoders::timeout = 3
+
+# These settings are used if web service calls must be routed through a proxy.
+# These setting can be nil if not needed, otherwise, addr and port must be 
+# filled in at a minimum.  If the proxy requires authentication, the username
+# and password can be provided as well.
+GeoKit::Geocoders::proxy_addr = nil
+GeoKit::Geocoders::proxy_port = nil
+GeoKit::Geocoders::proxy_user = nil
+GeoKit::Geocoders::proxy_pass = nil
+
 # This is your yahoo application key for the Yahoo Geocoder.
 # See http://developer.yahoo.com/faq/index.html#appid
 # and http://developer.yahoo.com/maps/rest/V1/geocode.html
-GeoKit::Geocoders::yahoo='REPLACE_WITH_YOUR_YAHOO_KEY'
+GeoKit::Geocoders::yahoo = 'REPLACE_WITH_YOUR_YAHOO_KEY'
     
 # This is your Google Maps geocoder key. 
 # See http://www.google.com/apis/maps/signup.html
 # and http://www.google.com/apis/maps/documentation/#Geocoding_Examples
-GeoKit::Geocoders::google='REPLACE_WITH_YOUR_GOOGLE_KEY'
+GeoKit::Geocoders::google = 'REPLACE_WITH_YOUR_GOOGLE_KEY'
     
 # This is your username and password for geocoder.us.
 # To use the free service, the value can be set to nil or false.  For 
 # usage tied to an account, the value should be set to username:password.
 # See http://geocoder.us
 # and http://geocoder.us/user/signup
-GeoKit::Geocoders::geocoder_us=false 
+GeoKit::Geocoders::geocoder_us = false 
 
 # This is your authorization key for geocoder.ca.
 # To use the free service, the value can be set to nil or false.  For 
@@ -25,7 +39,7 @@ GeoKit::Geocoders::geocoder_us=false
 # Geocoder.ca.
 # See http://geocoder.ca
 # and http://geocoder.ca/?register=1
-GeoKit::Geocoders::geocoder_ca=false
+GeoKit::Geocoders::geocoder_ca = false
 
 # This is the order in which the geocoders are called in a failover scenario
 # If you only want to use a single geocoder, put a single symbol in the array.
@@ -33,4 +47,4 @@ GeoKit::Geocoders::geocoder_ca=false
 # Be aware that there are Terms of Use restrictions on how you can use the 
 # various geocoders.  Make sure you read up on relevant Terms of Use for each
 # geocoder you are going to use.
-GeoKit::Geocoders::provider_order=[:google,:us]
\ No newline at end of file
+GeoKit::Geocoders::provider_order = [:google,:us]
\ No newline at end of file</diff>
      <filename>assets/api_keys_template</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,13 @@
-require File.dirname(__FILE__) + '/lib/geo_kit/defaults'
-require File.dirname(__FILE__) + '/lib/geo_kit/acts_as_mappable'
-require File.dirname(__FILE__) + '/lib/geo_kit/ip_geocode_lookup'
-require File.dirname(__FILE__) + '/lib/geo_kit/geocoders'
-require File.dirname(__FILE__) + '/lib/geo_kit/mappable'
+# Load modules and classes needed to automatically mix in ActiveRecord and 
+# ActionController helpers.  All other functionality must be explicitly 
+# required.
+require 'geo_kit/defaults'
+require 'geo_kit/mappable'
+require 'geo_kit/acts_as_mappable'
+require 'geo_kit/ip_geocode_lookup'
+
+# Automatically mix in distance finder support into ActiveRecord classes.
 ActiveRecord::Base.send :include, GeoKit::ActsAsMappable
+
+# Automatically mix in ip geocoding helpers into ActionController classes.
 ActionController::Base.send :include, GeoKit::IpGeocodeLookup</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,4 @@
+# Display to the console the contents of the README file.
 puts IO.read(File.join(File.dirname(__FILE__), 'README'))
 
 # Append the contents of api_keys_template to the application's environment.rb file</diff>
      <filename>install.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,8 @@ module GeoKit
   # * find_closest (alias: find_nearest)
   # * find_farthest
   #
+  # Counter methods are available and work similarly to finders.  
+  #
   # If raw SQL is desired, the distance_sql method can be used to obtain SQL appropriate
   # to use in a find_by_sql call.
   module ActsAsMappable 
@@ -64,18 +66,19 @@ module GeoKit
         #   conditions, substitutes the distance sql for the distance column -- this saves
         #   having to write the gory SQL.
         def find(*args)
-          options = extract_options_from_args!(args)
-          origin = extract_origin_from_options(options)
-          units = extract_units_from_options(options)
-          formula = extract_formula_from_options(options)
-          add_distance_to_select(options, origin, units, formula) if origin
-          apply_find_scope(args, options)
-          apply_distance_scope(options)
-          substitute_distance_in_conditions(options, origin, units, formula) if origin &amp;&amp; options.has_key?(:conditions)
-          args.push(options)
+          prepare_for_find_or_count(:find, args)
           super(*args)
         end     
         
+        # Extends the existing count method by:
+        # - If a mappable instance exists in the options and the distance column exists in the
+        #   conditions, substitutes the distance sql for the distance column -- this saves
+        #   having to write the gory SQL.
+        def count(*args)
+          prepare_for_find_or_count(:count, args)
+          super(*args)
+        end
+        
         # Finds within a distance radius.
         def find_within(distance, options={})
           options[:within] = distance
@@ -107,6 +110,26 @@ module GeoKit
           find(:farthest, options)
         end
         
+        # counts within a distance radius.
+        def count_within(distance, options={})
+          options[:within] = distance
+          count(options)
+        end
+        alias count_inside count_within
+        
+        # Counts beyond a distance radius.
+        def count_beyond(distance, options={})
+          options[:beyond] = distance
+          count(options)
+        end
+        alias count_outside count_beyond
+        
+        # Counts according to a range.  Accepts inclusive or exclusive ranges.
+        def count_by_range(range, options={})
+          options[:range] = range
+          count(options)
+        end
+        
         # Returns the distance calculation to be used as a display column or a condition.  This
         # is provide for anyone wanting access to the raw SQL.
         def distance_sql(origin, units=default_units, formula=default_formula)
@@ -121,6 +144,26 @@ module GeoKit
 
         private
         
+        # Prepares either a find or a count action by parsing through the options and
+        # conditionally adding to the select clause for finders.
+        def prepare_for_find_or_count(action, args)
+          options = extract_options_from_args!(args)
+          # Obtain items affecting distance condition.
+          origin = extract_origin_from_options(options)
+          units = extract_units_from_options(options)
+          formula = extract_formula_from_options(options)
+          # Apply select adjustments based upon action.
+          add_distance_to_select(options, origin, units, formula) if origin &amp;&amp; action == :find
+          # Apply distance scoping and perform substitutions.
+          apply_distance_scope(options)
+          substitute_distance_in_conditions(options, origin, units, formula) if origin &amp;&amp; options.has_key?(:conditions)
+          # Order by scoping for find action.
+          apply_find_scope(args, options) if action == :find
+          # Restore options minus the extra options that we used for the
+          # GeoKit API.
+          args.push(options)   
+        end
+        
         # Looks for mapping-specific tokens and makes appropriate translations so that the 
         # original finder has its expected arguments.  Resets the the scope argument to 
         # :first and ensures the limit is set to one.
@@ -142,7 +185,7 @@ module GeoKit
         def apply_distance_scope(options)
           distance_condition = &quot;#{distance_column_name} &lt;= #{options[:within]}&quot; if options.has_key?(:within)
           distance_condition = &quot;#{distance_column_name} &gt; #{options[:beyond]}&quot; if options.has_key?(:beyond)
-          distance_condition = &quot;#{distance_column_name} &gt;= #{options[:range].first} AND #{distance_column_name} &lt;= #{options[:range].last}&quot; if options.has_key?(:range)
+          distance_condition = &quot;#{distance_column_name} &gt;= #{options[:range].first} AND #{distance_column_name} &lt;#{'=' unless options[:range].exclude_end?} #{options[:range].last}&quot; if options.has_key?(:range)
           [:within, :beyond, :range].each { |option| options.delete(option) } if distance_condition
           if distance_condition &amp;&amp; options.has_key?(:conditions)
             original_conditions = options[:conditions]</diff>
      <filename>lib/geo_kit/acts_as_mappable.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 require 'net/http'
 require 'rexml/document'
 require 'yaml'
+require 'timeout'
 
 module GeoKit
   # Contains a set of geocoders which can be used independently if desired.  The list contains:
@@ -15,13 +16,19 @@ module GeoKit
   # Some configuration is required for these geocoders and can be located in the environment
   # configuration files.
   module Geocoders
+    @@proxy_addr = nil
+    @@proxy_port = nil
+    @@proxy_user = nil
+    @@proxy_pass = nil
+    @@timeout = nil    
     @@yahoo = 'REPLACE_WITH_YOUR_YAHOO_KEY'
     @@google = 'REPLACE_WITH_YOUR_GOOGLE_KEY'
     @@geocoder_us = false
     @@geocoder_ca = false
     @@provider_order = [:google,:us]
     
-    [:yahoo, :google, :geocoder_us, :geocoder_ca, :provider_order].each do |sym|
+    [:yahoo, :google, :geocoder_us, :geocoder_ca, :provider_order, :timeout, 
+     :proxy_addr, :proxy_port, :proxy_user, :proxy_pass].each do |sym|
       class_eval &lt;&lt;-EOS, __FILE__, __LINE__
         def self.#{sym}
           if defined?(#{sym.to_s.upcase})
@@ -50,6 +57,14 @@ module GeoKit
         res = do_geocode(address)
         return res.success ? res : GeoLoc.new
       end  
+      
+      # Call the geocoder service using the timeout if configured.
+      def self.call_geocoder_service(url)
+        timeout(GeoKit::Geocoders::timeout) { return self.do_get(url) } if GeoKit::Geocoders::timeout        
+        return self.do_get(url)
+      rescue TimeoutError
+        return nil  
+      end
 
       protected
 
@@ -57,6 +72,12 @@ module GeoKit
       
       private
       
+      # Wraps the geocoder call around a proxy if necessary.
+      def self.do_get(url)     
+        return Net::HTTP::Proxy(GeoKit::Geocoders::proxy_addr, GeoKit::Geocoders::proxy_port,
+            GeoKit::Geocoders::proxy_user, GeoKit::Geocoders::proxy_pass).get_response(URI.parse(url))          
+      end
+      
       # Adds subclass' geocode method making it conveniently available through 
       # the base class.
       def self.inherited(clazz)
@@ -88,7 +109,7 @@ module GeoKit
       def self.do_geocode(address)
         raise ArgumentError('Geocoder.ca requires a GeoLoc argument') unless address.is_a?(GeoLoc)
         url = construct_request(address)
-        res = Net::HTTP.get_response(URI.parse(url))
+        res = self.call_geocoder_service(url)
         return GeoLoc.new if !res.is_a?(Net::HTTPSuccess)
         xml = res.body
         logger.debug &quot;Geocoder.ca geocoding. Address: #{address}. Result: #{xml}&quot;
@@ -130,7 +151,8 @@ module GeoKit
       # Template method which does the geocode lookup.
       def self.do_geocode(address)
         address_str = address.is_a?(GeoLoc) ? address.to_geocodeable_s : address
-        res = Net::HTTP.get_response(URI.parse(&quot;http://maps.google.com/maps/geo?q=#{CGI.escape(address_str)}&amp;output=xml&amp;key=#{GeoKit::Geocoders::google}&amp;oe=utf-8&quot;))
+        res = self.call_geocoder_service(&quot;http://maps.google.com/maps/geo?q=#{CGI.escape(address_str)}&amp;output=xml&amp;key=#{GeoKit::Geocoders::google}&amp;oe=utf-8&quot;)
+#        res = Net::HTTP.get_response(URI.parse(&quot;http://maps.google.com/maps/geo?q=#{CGI.escape(address_str)}&amp;output=xml&amp;key=#{GeoKit::Geocoders::google}&amp;oe=utf-8&quot;))
         return GeoLoc.new if !res.is_a?(Net::HTTPSuccess)
         xml=res.body
         logger.debug &quot;Google geocoding. Address: #{address}. Result: #{xml}&quot;
@@ -183,7 +205,8 @@ module GeoKit
       # parameter does not match an ip address.  
       def self.do_geocode(ip)
         return GeoLoc.new unless /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})?$/.match(ip)
-        response = Net::HTTP.get_response('api.hostip.info', &quot;/get_html.php?ip=#{ip}&amp;position=true&quot;)
+        url = &quot;http://api.hostip.info/get_html.php?ip=#{ip}&amp;position=true&quot;
+        response = self.call_geocoder_service(url)
         response.is_a?(Net::HTTPSuccess) ? parse_body(response.body) : GeoLoc.new
       rescue
         logger.error &quot;Caught an error during HostIp geocoding call: &quot;+$!
@@ -223,7 +246,7 @@ module GeoKit
       def self.do_geocode(address)
         address_str = address.is_a?(GeoLoc) ? address.to_geocodeable_s : address
         url = &quot;http://&quot;+(GeoKit::Geocoders::geocoder_us || '')+&quot;geocoder.us/service/csv/geocode?address=#{CGI.escape(address_str)}&quot;
-        res = Net::HTTP.get_response(URI.parse(url))
+        res = self.call_geocoder_service(url)
         return GeoLoc.new if !res.is_a?(Net::HTTPSuccess)
         data = res.body
         logger.debug &quot;Geocoder.us geocoding. Address: #{address}. Result: #{data}&quot;
@@ -255,7 +278,7 @@ module GeoKit
       def self.do_geocode(address)
         address_str = address.is_a?(GeoLoc) ? address.to_geocodeable_s : address
         url=&quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=#{GeoKit::Geocoders::yahoo}&amp;location=#{CGI.escape(address_str)}&quot;
-        res = Net::HTTP.get_response(URI.parse(url))
+        res = self.call_geocoder_service(url)
         return GeoLoc.new if !res.is_a?(Net::HTTPSuccess)
         xml = res.body
         doc = REXML::Document.new(xml)
@@ -309,7 +332,7 @@ module GeoKit
       def self.do_geocode(address)
         GeoKit::Geocoders::provider_order.each do |provider|
           begin
-            klass=GeoKit::Geocoders.const_get &quot;#{provider.to_s.capitalize}Geocoder&quot;
+            klass = GeoKit::Geocoders.const_get &quot;#{provider.to_s.capitalize}Geocoder&quot;
             res = klass.send :geocode, address
             return res if res.success
           rescue</diff>
      <filename>lib/geo_kit/geocoders.rb</filename>
    </modified>
    <modified>
      <diff>@@ -37,12 +37,10 @@ module GeoKit
       return location.success ? location : nil
     end
     
-    # Either returns the real ip address or a fake one in the case where
-    # doing live testing via localhost.
+    # Returns the real ip address, though this could be the localhost ip
+    # address.  No special handling here anymore.
     def get_ip_address
-      
-      address = request.remote_ip
-      address == '127.0.0.1' ? '12.215.42.19' : address
+      request.remote_ip
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/geo_kit/ip_geocode_lookup.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+require 'geo_kit/defaults'
+
 module GeoKit
   # Contains class and instance methods providing distance calcuation services.  This
   # module is meant to be mixed into classes containing lat and lng attributes where</diff>
      <filename>lib/geo_kit/mappable.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,21 +1,6 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-require 'test/unit'
-require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
-require 'breakpoint'
-require 'active_record/fixtures'
-require 'action_controller/test_process'
 require 'rubygems'
 require 'mocha'
-
-# Config database connection.
-config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
-ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + &quot;/debug.log&quot;)
-ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'mysql'])
-#ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'postgresql'])
-
-
-# Establish test tables.
-load(File.dirname(__FILE__) + &quot;/schema.rb&quot;)
+require File.join(File.dirname(__FILE__), 'test_helper')
 
 GeoKit::Geocoders::provider_order=[:google,:us]
 
@@ -30,6 +15,7 @@ class Location &lt; ActiveRecord::Base #:nodoc: all
   acts_as_mappable
 end
 
+# Uses deviations from conventions.
 class CustomLocation &lt; ActiveRecord::Base #:nodoc: all
   belongs_to :company
   acts_as_mappable :distance_column_name =&gt; 'dist', 
@@ -47,7 +33,11 @@ class ActsAsMappableTest &lt; Test::Unit::TestCase #:nodoc: all
     
   LOCATION_A_IP = &quot;217.10.83.5&quot;  
     
-  self.fixture_path = File.dirname(__FILE__) + '/fixtures'  
+  #self.fixture_path = File.dirname(__FILE__) + '/fixtures'  
+  #self.fixture_path = RAILS_ROOT + '/test/fixtures/'
+  #puts &quot;Rails Path #{RAILS_ROOT}&quot;
+  #puts &quot;Fixture Path: #{self.fixture_path}&quot;
+  #self.fixture_path = ' /Users/bill_eisenhauer/Projects/geokit_test/test/fixtures/'
   fixtures :companies, :locations, :custom_locations
 
   def setup
@@ -70,6 +60,8 @@ class ActsAsMappableTest &lt; Test::Unit::TestCase #:nodoc: all
     Location.default_units = :kms
     locations = Location.find(:all, :origin =&gt; @loc_a, :conditions =&gt; &quot;distance &lt; 3.97&quot;)
     assert_equal 5, locations.size   
+    locations = Location.count(:origin =&gt; @loc_a, :conditions =&gt; &quot;distance &lt; 3.97&quot;)
+    assert_equal 5, locations
     Location.default_units = :miles
   end
   
@@ -111,66 +103,99 @@ class ActsAsMappableTest &lt; Test::Unit::TestCase #:nodoc: all
   def test_find_with_distance_condition
     locations = Location.find(:all, :origin =&gt; @loc_a, :conditions =&gt; &quot;distance &lt; 3.97&quot;)
     assert_equal 5, locations.size
+    locations = Location.count(:origin =&gt; @loc_a, :conditions =&gt; &quot;distance &lt; 3.97&quot;)
+    assert_equal 5, locations
   end 
   
   def test_find_with_distance_condition_with_units_override
     locations = Location.find(:all, :origin =&gt; @loc_a, :units =&gt; :kms, :conditions =&gt; &quot;distance &lt; 6.387&quot;)
     assert_equal 5, locations.size
+    locations = Location.count(:origin =&gt; @loc_a, :units =&gt; :kms, :conditions =&gt; &quot;distance &lt; 6.387&quot;)
+    assert_equal 5, locations
   end
   
   def test_find_with_distance_condition_with_formula_override
     locations = Location.find(:all, :origin =&gt; @loc_a, :formula =&gt; :flat, :conditions =&gt; &quot;distance &lt; 6.387&quot;)
     assert_equal 6, locations.size
+    locations = Location.count(:origin =&gt; @loc_a, :formula =&gt; :flat, :conditions =&gt; &quot;distance &lt; 6.387&quot;)
+    assert_equal 6, locations
   end
   
   def test_find_within
     locations = Location.find_within(3.97, :origin =&gt; @loc_a)
-    assert_equal 5, locations.size    
+    assert_equal 5, locations.size 
+    locations = Location.count_within(3.97, :origin =&gt; @loc_a)
+    assert_equal 5, locations   
   end
   
   def test_find_within_with_token
     locations = Location.find(:all, :within =&gt; 3.97, :origin =&gt; @loc_a)
     assert_equal 5, locations.size    
+    locations = Location.count(:within =&gt; 3.97, :origin =&gt; @loc_a)
+    assert_equal 5, locations
   end
   
   def test_find_within_with_coordinates
     locations = Location.find_within(3.97, :origin =&gt;[@loc_a.lat,@loc_a.lng])
     assert_equal 5, locations.size    
+    locations = Location.count_within(3.97, :origin =&gt;[@loc_a.lat,@loc_a.lng])
+    assert_equal 5, locations
   end
   
   def test_find_with_compound_condition
     locations = Location.find(:all, :origin =&gt; @loc_a, :conditions =&gt; &quot;distance &lt; 5 and city = 'Coppell'&quot;)
     assert_equal 2, locations.size
+    locations = Location.count(:origin =&gt; @loc_a, :conditions =&gt; &quot;distance &lt; 5 and city = 'Coppell'&quot;)
+    assert_equal 2, locations
   end
   
   def test_find_with_secure_compound_condition
     locations = Location.find(:all, :origin =&gt; @loc_a, :conditions =&gt; [&quot;distance &lt; ? and city = ?&quot;, 5, 'Coppell'])
     assert_equal 2, locations.size
+    locations = Location.count(:origin =&gt; @loc_a, :conditions =&gt; [&quot;distance &lt; ? and city = ?&quot;, 5, 'Coppell'])
+    assert_equal 2, locations
   end
   
   def test_find_beyond
     locations = Location.find_beyond(3.95, :origin =&gt; @loc_a)
     assert_equal 1, locations.size    
+    locations = Location.count_beyond(3.95, :origin =&gt; @loc_a)
+    assert_equal 1, locations
   end
   
   def test_find_beyond_with_token
     locations = Location.find(:all, :beyond =&gt; 3.95, :origin =&gt; @loc_a)
     assert_equal 1, locations.size    
+    locations = Location.count(:beyond =&gt; 3.95, :origin =&gt; @loc_a)
+    assert_equal 1, locations
   end
   
   def test_find_beyond_with_coordinates
     locations = Location.find_beyond(3.95, :origin =&gt;[@loc_a.lat, @loc_a.lng])
     assert_equal 1, locations.size    
+    locations = Location.count_beyond(3.95, :origin =&gt;[@loc_a.lat, @loc_a.lng])
+    assert_equal 1, locations
   end
   
   def test_find_range_with_token
     locations = Location.find(:all, :range =&gt; 0..10, :origin =&gt; @loc_a)
     assert_equal 6, locations.size
+    locations = Location.count(:range =&gt; 0..10, :origin =&gt; @loc_a)
+    assert_equal 6, locations
   end
   
   def test_find_range_with_token_with_conditions
     locations = Location.find(:all, :origin =&gt; @loc_a, :range =&gt; 0..10, :conditions =&gt; [&quot;city = ?&quot;, 'Coppell'])
     assert_equal 2, locations.size
+    locations = Location.count(:origin =&gt; @loc_a, :range =&gt; 0..10, :conditions =&gt; [&quot;city = ?&quot;, 'Coppell'])
+    assert_equal 2, locations
+  end
+  
+  def test_find_range_with_token_excluding_end
+    locations = Location.find(:all, :range =&gt; 0...10, :origin =&gt; @loc_a)
+    assert_equal 6, locations.size
+    locations = Location.count(:range =&gt; 0...10, :origin =&gt; @loc_a)
+    assert_equal 6, locations
   end
   
   def test_find_nearest
@@ -207,21 +232,29 @@ class ActsAsMappableTest &lt; Test::Unit::TestCase #:nodoc: all
   def test_scoped_find_with_distance_condition
     locations = @starbucks.locations.find(:all, :origin =&gt; @loc_a, :conditions =&gt; &quot;distance &lt; 3.97&quot;)
     assert_equal 4, locations.size
+    locations = @starbucks.locations.count(:origin =&gt; @loc_a, :conditions =&gt; &quot;distance &lt; 3.97&quot;)
+    assert_equal 4, locations
   end 
   
   def test_scoped_find_within
     locations = @starbucks.locations.find_within(3.97, :origin =&gt; @loc_a)
     assert_equal 4, locations.size    
+    locations = @starbucks.locations.count_within(3.97, :origin =&gt; @loc_a)
+    assert_equal 4, locations
   end
   
   def test_scoped_find_with_compound_condition
     locations = @starbucks.locations.find(:all, :origin =&gt; @loc_a, :conditions =&gt; &quot;distance &lt; 5 and city = 'Coppell'&quot;)
     assert_equal 2, locations.size
+    locations = @starbucks.locations.count( :origin =&gt; @loc_a, :conditions =&gt; &quot;distance &lt; 5 and city = 'Coppell'&quot;)
+    assert_equal 2, locations
   end
   
   def test_scoped_find_beyond
     locations = @starbucks.locations.find_beyond(3.95, :origin =&gt; @loc_a)
-    assert_equal 1, locations.size    
+    assert_equal 1, locations.size 
+    locations = @starbucks.locations.count_beyond(3.95, :origin =&gt; @loc_a)
+    assert_equal 1, locations   
   end
   
   def test_scoped_find_nearest
@@ -244,30 +277,45 @@ class ActsAsMappableTest &lt; Test::Unit::TestCase #:nodoc: all
     GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
     locations = Location.find(:all, :origin =&gt; LOCATION_A_IP, :conditions =&gt; &quot;distance &lt; 3.97&quot;)
     assert_equal 5, locations.size
+    GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
+    locations = Location.count(:origin =&gt; LOCATION_A_IP, :conditions =&gt; &quot;distance &lt; 3.97&quot;)
+    assert_equal 5, locations
   end 
   
   def test_ip_geocoded_find_within
     GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
     locations = Location.find_within(3.97, :origin =&gt; LOCATION_A_IP)
     assert_equal 5, locations.size    
+    GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
+    locations = Location.count_within(3.97, :origin =&gt; LOCATION_A_IP)
+    assert_equal 5, locations
   end
   
   def test_ip_geocoded_find_with_compound_condition
     GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
     locations = Location.find(:all, :origin =&gt; LOCATION_A_IP, :conditions =&gt; &quot;distance &lt; 5 and city = 'Coppell'&quot;)
     assert_equal 2, locations.size
+    GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
+    locations = Location.count(:origin =&gt; LOCATION_A_IP, :conditions =&gt; &quot;distance &lt; 5 and city = 'Coppell'&quot;)
+    assert_equal 2, locations
   end
   
   def test_ip_geocoded_find_with_secure_compound_condition
     GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
     locations = Location.find(:all, :origin =&gt; LOCATION_A_IP, :conditions =&gt; [&quot;distance &lt; ? and city = ?&quot;, 5, 'Coppell'])
     assert_equal 2, locations.size
+    GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
+    locations = Location.count(:origin =&gt; LOCATION_A_IP, :conditions =&gt; [&quot;distance &lt; ? and city = ?&quot;, 5, 'Coppell'])
+    assert_equal 2, locations
   end
   
   def test_ip_geocoded_find_beyond
     GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
     locations = Location.find_beyond(3.95, :origin =&gt; LOCATION_A_IP)
     assert_equal 1, locations.size    
+    GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
+    locations = Location.count_beyond(3.95, :origin =&gt; LOCATION_A_IP)
+    assert_equal 1, locations
   end
   
   def test_ip_geocoded_find_nearest
@@ -296,41 +344,57 @@ class ActsAsMappableTest &lt; Test::Unit::TestCase #:nodoc: all
   def test_find_with_custom_distance_condition
     locations = CustomLocation.find(:all, :origin =&gt; @loc_a, :conditions =&gt; &quot;dist &lt; 3.97&quot;)
     assert_equal 5, locations.size 
+    locations = CustomLocation.count(:origin =&gt; @loc_a, :conditions =&gt; &quot;dist &lt; 3.97&quot;)
+    assert_equal 5, locations
   end  
   
   def test_find_with_custom_distance_condition_using_custom_origin
     locations = CustomLocation.find(:all, :origin =&gt; @custom_loc_a, :conditions =&gt; &quot;dist &lt; 3.97&quot;)
     assert_equal 5, locations.size 
+    locations = CustomLocation.count(:origin =&gt; @custom_loc_a, :conditions =&gt; &quot;dist &lt; 3.97&quot;)
+    assert_equal 5, locations
   end
   
   def test_find_within_with_custom
     locations = CustomLocation.find_within(3.97, :origin =&gt; @loc_a)
     assert_equal 5, locations.size    
+    locations = CustomLocation.count_within(3.97, :origin =&gt; @loc_a)
+    assert_equal 5, locations
   end
   
   def test_find_within_with_coordinates_with_custom
     locations = CustomLocation.find_within(3.97, :origin =&gt;[@loc_a.lat, @loc_a.lng])
     assert_equal 5, locations.size    
+    locations = CustomLocation.count_within(3.97, :origin =&gt;[@loc_a.lat, @loc_a.lng])
+    assert_equal 5, locations
   end
   
   def test_find_with_compound_condition_with_custom
     locations = CustomLocation.find(:all, :origin =&gt; @loc_a, :conditions =&gt; &quot;dist &lt; 5 and city = 'Coppell'&quot;)
     assert_equal 1, locations.size
+    locations = CustomLocation.count(:origin =&gt; @loc_a, :conditions =&gt; &quot;dist &lt; 5 and city = 'Coppell'&quot;)
+    assert_equal 1, locations
   end
   
   def test_find_with_secure_compound_condition_with_custom
     locations = CustomLocation.find(:all, :origin =&gt; @loc_a, :conditions =&gt; [&quot;dist &lt; ? and city = ?&quot;, 5, 'Coppell'])
     assert_equal 1, locations.size
+    locations = CustomLocation.count(:origin =&gt; @loc_a, :conditions =&gt; [&quot;dist &lt; ? and city = ?&quot;, 5, 'Coppell'])
+    assert_equal 1, locations
   end
   
   def test_find_beyond_with_custom
     locations = CustomLocation.find_beyond(3.95, :origin =&gt; @loc_a)
-    assert_equal 1, locations.size    
+    assert_equal 1, locations.size  
+    locations = CustomLocation.count_beyond(3.95, :origin =&gt; @loc_a)
+    assert_equal 1, locations  
   end
   
   def test_find_beyond_with_coordinates_with_custom
     locations = CustomLocation.find_beyond(3.95, :origin =&gt;[@loc_a.lat, @loc_a.lng])
     assert_equal 1, locations.size    
+    locations = CustomLocation.count_beyond(3.95, :origin =&gt;[@loc_a.lat, @loc_a.lng])
+    assert_equal 1, locations
   end
   
   def test_find_nearest_with_custom
@@ -352,5 +416,7 @@ class ActsAsMappableTest &lt; Test::Unit::TestCase #:nodoc: all
   def test_find_with_array_origin
     locations = Location.find(:all, :origin =&gt;[@loc_a.lat,@loc_a.lng], :conditions =&gt; &quot;distance &lt; 3.97&quot;)
     assert_equal 5, locations.size
+    locations = Location.count(:origin =&gt;[@loc_a.lat,@loc_a.lng], :conditions =&gt; &quot;distance &lt; 3.97&quot;)
+    assert_equal 5, locations
   end
 end</diff>
      <filename>test/acts_as_mappable_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,9 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
 require 'test/unit'
 require 'net/http'
 require 'rubygems'
 require 'mocha'
-require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
+require File.join(File.dirname(__FILE__), '../../../../config/environment')
+
 
 class MockSuccess &lt; Net::HTTPSuccess #:nodoc: all
   def initialize
@@ -17,6 +17,7 @@ end
 
 # Base class for testing geocoders.
 class BaseGeocoderTest &lt; Test::Unit::TestCase #:nodoc: all
+
   # Defines common test fixtures.
   def setup
     @address = 'San Francisco, CA'    
@@ -27,6 +28,23 @@ class BaseGeocoderTest &lt; Test::Unit::TestCase #:nodoc: all
     @success.success = true    
   end  
   
+  def test_timeout_call_web_service
+    GeoKit::Geocoders::Geocoder.class_eval do
+      def self.do_get(url)
+        sleep(2)
+      end
+    end
+    url = &quot;http://www.anything.com&quot;
+    GeoKit::Geocoders::timeout = 1
+    assert_nil GeoKit::Geocoders::Geocoder.call_geocoder_service(url)    
+  end
+  
+  def test_successful_call_web_service
+    url = &quot;http://www.anything.com&quot;
+    GeoKit::Geocoders::Geocoder.expects(:do_get).with(url).returns(&quot;SUCCESS&quot;)
+    assert_equal &quot;SUCCESS&quot;, GeoKit::Geocoders::Geocoder.call_geocoder_service(url)
+  end
+  
   def test_find_geocoder_methods
     public_methods = GeoKit::Geocoders::Geocoder.public_methods
     assert public_methods.include?(&quot;yahoo_geocoder&quot;)</diff>
      <filename>test/base_geocoder_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,10 @@
-require File.dirname(__FILE__) + '/base_geocoder_test.rb'
+require File.join(File.dirname(__FILE__), 'base_geocoder_test')
 
 GeoKit::Geocoders::geocoder_ca = &quot;SOMEKEYVALUE&quot;
 
 class CaGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   
-  SUCCESS=&lt;&lt;-EOF
+  CA_SUCCESS=&lt;&lt;-EOF
   &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
   &lt;geodata&gt;&lt;latt&gt;49.243086&lt;/latt&gt;&lt;longt&gt;-123.153684&lt;/longt&gt;&lt;/geodata&gt;  
   EOF
@@ -16,14 +16,17 @@ class CaGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   
   def test_geocoder_with_geo_loc_with_account
     response = MockSuccess.new
-    response.expects(:body).returns(SUCCESS)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://geocoder.ca/?stno=2105&amp;addresst=West+32nd+Avenue&amp;city=Vancouver&amp;prov=BC&amp;auth=SOMEKEYVALUE&amp;geoit=xml&quot;)).returns(response)    
+    response.expects(:body).returns(CA_SUCCESS)
+    url = &quot;http://geocoder.ca/?stno=2105&amp;addresst=West+32nd+Avenue&amp;city=Vancouver&amp;prov=BC&amp;auth=SOMEKEYVALUE&amp;geoit=xml&quot;
+    GeoKit::Geocoders::CaGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     verify(GeoKit::Geocoders::CaGeocoder.geocode(@ca_full_loc))    
   end
   
   def test_service_unavailable
     response = MockFailure.new
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://geocoder.ca/?stno=2105&amp;addresst=West+32nd+Avenue&amp;city=Vancouver&amp;prov=BC&amp;auth=SOMEKEYVALUE&amp;geoit=xml&quot;)).returns(response)    
+    #Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://geocoder.ca/?stno=2105&amp;addresst=West+32nd+Avenue&amp;city=Vancouver&amp;prov=BC&amp;auth=SOMEKEYVALUE&amp;geoit=xml&quot;)).returns(response)  
+    url = &quot;http://geocoder.ca/?stno=2105&amp;addresst=West+32nd+Avenue&amp;city=Vancouver&amp;prov=BC&amp;auth=SOMEKEYVALUE&amp;geoit=xml&quot; 
+    GeoKit::Geocoders::CaGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     assert !GeoKit::Geocoders::CaGeocoder.geocode(@ca_full_loc).success   
   end  
   </diff>
      <filename>test/ca_geocoder_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 require 'test/unit'
-require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
+require File.join(File.dirname(__FILE__), '../../../../config/environment')
 
 class GeoLocTest &lt; Test::Unit::TestCase #:nodoc: all
   </diff>
      <filename>test/geoloc_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/base_geocoder_test.rb'
+require File.join(File.dirname(__FILE__), 'base_geocoder_test')
 
 GeoKit::Geocoders::google = 'Google'
 
@@ -24,7 +24,8 @@ class GoogleGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   def test_google_full_address
     response = MockSuccess.new
     response.expects(:body).returns(GOOGLE_FULL)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://maps.google.com/maps/geo?q=#{CGI.escape(@address)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;)).returns(response)
+    url = &quot;http://maps.google.com/maps/geo?q=#{CGI.escape(@address)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;
+    GeoKit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     res=GeoKit::Geocoders::GoogleGeocoder.geocode(@address)
     assert_equal &quot;CA&quot;, res.state
     assert_equal &quot;San Francisco&quot;, res.city 
@@ -37,7 +38,8 @@ class GoogleGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   def test_google_full_address_with_geo_loc
     response = MockSuccess.new
     response.expects(:body).returns(GOOGLE_FULL)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://maps.google.com/maps/geo?q=#{CGI.escape(@full_address_short_zip)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;)).returns(response)
+    url = &quot;http://maps.google.com/maps/geo?q=#{CGI.escape(@full_address_short_zip)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;
+    GeoKit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     res=GeoKit::Geocoders::GoogleGeocoder.geocode(@google_full_loc)
     assert_equal &quot;CA&quot;, res.state
     assert_equal &quot;San Francisco&quot;, res.city 
@@ -50,7 +52,8 @@ class GoogleGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   def test_google_city
     response = MockSuccess.new
     response.expects(:body).returns(GOOGLE_CITY)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://maps.google.com/maps/geo?q=#{CGI.escape(@address)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;)).returns(response)    
+    url = &quot;http://maps.google.com/maps/geo?q=#{CGI.escape(@address)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;
+    GeoKit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     res=GeoKit::Geocoders::GoogleGeocoder.geocode(@address)
     assert_equal &quot;CA&quot;, res.state
     assert_equal &quot;San Francisco&quot;, res.city
@@ -64,7 +67,8 @@ class GoogleGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   def test_google_city_with_geo_loc
     response = MockSuccess.new
     response.expects(:body).returns(GOOGLE_CITY)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://maps.google.com/maps/geo?q=#{CGI.escape(@address)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;)).returns(response)    
+    url = &quot;http://maps.google.com/maps/geo?q=#{CGI.escape(@address)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;
+    GeoKit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     res=GeoKit::Geocoders::GoogleGeocoder.geocode(@google_city_loc)
     assert_equal &quot;CA&quot;, res.state
     assert_equal &quot;San Francisco&quot;, res.city
@@ -77,7 +81,8 @@ class GoogleGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   
   def test_service_unavailable
     response = MockFailure.new
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://maps.google.com/maps/geo?q=#{CGI.escape(@address)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;)).returns(response)    
+    url = &quot;http://maps.google.com/maps/geo?q=#{CGI.escape(@address)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;
+    GeoKit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     assert !GeoKit::Geocoders::GoogleGeocoder.geocode(@google_city_loc).success
   end 
 end
\ No newline at end of file</diff>
      <filename>test/google_geocoder_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,9 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
+require File.join(File.dirname(__FILE__), '../../../../config/environment')
+require 'action_controller/test_process'
 require 'test/unit'
 require 'rubygems'
 require 'mocha'
-require File.join(File.dirname(__FILE__), '../../../../test/test_helper')
-require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
+
 
 class LocationAwareController &lt; ActionController::Base #:nodoc: all
   geocode_ip_address</diff>
      <filename>test/ip_geocode_lookup_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,22 +1,22 @@
-require File.dirname(__FILE__) + '/base_geocoder_test.rb'
+require File.join(File.dirname(__FILE__), 'base_geocoder_test')
 
 class IpGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
     
-  FAILURE=&lt;&lt;-EOF
+  IP_FAILURE=&lt;&lt;-EOF
     Country: (Private Address) (XX)
     City: (Private Address)
     Latitude: 
     Longitude:
     EOF
     
-  SUCCESS=&lt;&lt;-EOF
+  IP_SUCCESS=&lt;&lt;-EOF
     Country: UNITED STATES (US)
     City: Sugar Grove, IL
     Latitude: 41.7696
     Longitude: -88.4588
     EOF
     
-  UNICODED=&lt;&lt;-EOF
+  IP_UNICODED=&lt;&lt;-EOF
     Country: SWEDEN (SE)
     City: Bor&#229;s
     Latitude: 57.7167
@@ -30,8 +30,9 @@ class IpGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   
   def test_successful_lookup
     success = MockSuccess.new
-    success.expects(:body).returns(SUCCESS)
-    Net::HTTP.expects(:get_response).with('api.hostip.info', '/get_html.php?ip=12.215.42.19&amp;position=true').returns(success)
+    success.expects(:body).returns(IP_SUCCESS)
+    url = 'http://api.hostip.info/get_html.php?ip=12.215.42.19&amp;position=true'
+    GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
     location = GeoKit::Geocoders::IpGeocoder.geocode('12.215.42.19')
     assert_not_nil location
     assert_equal 41.7696, location.lat
@@ -45,8 +46,9 @@ class IpGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   
   def test_unicoded_lookup
     success = MockSuccess.new
-    success.expects(:body).returns(UNICODED)
-    Net::HTTP.expects(:get_response).with('api.hostip.info', '/get_html.php?ip=12.215.42.19&amp;position=true').returns(success)
+    success.expects(:body).returns(IP_UNICODED)
+    url = 'http://api.hostip.info/get_html.php?ip=12.215.42.19&amp;position=true'
+    GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
     location = GeoKit::Geocoders::IpGeocoder.geocode('12.215.42.19')
     assert_not_nil location
     assert_equal 57.7167, location.lat
@@ -60,8 +62,9 @@ class IpGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   
   def test_failed_lookup
     failure = MockSuccess.new
-    failure.expects(:body).returns(FAILURE)
-    Net::HTTP.expects(:get_response).with('api.hostip.info', '/get_html.php?ip=0.0.0.0&amp;position=true').returns(failure)
+    failure.expects(:body).returns(IP_FAILURE)
+    url = 'http://api.hostip.info/get_html.php?ip=0.0.0.0&amp;position=true'
+    GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
     location = GeoKit::Geocoders::IpGeocoder.geocode(&quot;0.0.0.0&quot;)
     assert_not_nil location
     assert !location.success
@@ -75,7 +78,8 @@ class IpGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   
   def test_service_unavailable
     failure = MockFailure.new
-    Net::HTTP.expects(:get_response).with('api.hostip.info', '/get_html.php?ip=0.0.0.0&amp;position=true').returns(failure)
+    url = 'http://api.hostip.info/get_html.php?ip=0.0.0.0&amp;position=true'
+    GeoKit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
     location = GeoKit::Geocoders::IpGeocoder.geocode(&quot;0.0.0.0&quot;)
     assert_not_nil location
     assert !location.success</diff>
      <filename>test/ipgeocoder_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
+$LOAD_PATH.unshift File.join('..', 'lib')
+require 'geo_kit/mappable'
 require 'test/unit'
-require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
 
 class LatLngTest &lt; Test::Unit::TestCase #:nodoc: all
   
@@ -66,5 +67,4 @@ class LatLngTest &lt; Test::Unit::TestCase #:nodoc: all
     assert_in_delta 3.97, @point.distance_to(@loc_e, :units =&gt; :miles, :formula =&gt; :flat), 0.2
     assert_in_delta 6.39, @point.distance_to(@loc_e, :units =&gt; :kms, :formula =&gt; :flat), 0.4
   end
-  
 end
\ No newline at end of file</diff>
      <filename>test/latlng_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/base_geocoder_test.rb'
+require File.join(File.dirname(__FILE__), 'base_geocoder_test')
 
 GeoKit::Geocoders::provider_order=[:google,:yahoo,:us]
 </diff>
      <filename>test/multi_geocoder_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/base_geocoder_test.rb'
+require File.join(File.dirname(__FILE__), 'base_geocoder_test')
 
 GeoKit::Geocoders::geocoder_us = nil
 
@@ -15,20 +15,23 @@ class UsGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   def test_geocoder_us
     response = MockSuccess.new
     response.expects(:body).returns(GEOCODER_US_FULL)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://geocoder.us/service/csv/geocode?address=#{CGI.escape(@address)}&quot;)).returns(response)    
+    url = &quot;http://geocoder.us/service/csv/geocode?address=#{CGI.escape(@address)}&quot;
+    GeoKit::Geocoders::UsGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     verify(GeoKit::Geocoders::UsGeocoder.geocode(@address))
   end
   
   def test_geocoder_with_geo_loc
     response = MockSuccess.new
     response.expects(:body).returns(GEOCODER_US_FULL)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://geocoder.us/service/csv/geocode?address=#{CGI.escape(@address)}&quot;)).returns(response)    
+    url = &quot;http://geocoder.us/service/csv/geocode?address=#{CGI.escape(@address)}&quot;
+    GeoKit::Geocoders::UsGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     verify(GeoKit::Geocoders::UsGeocoder.geocode(@us_full_loc))    
   end
   
   def test_service_unavailable
     response = MockFailure.new
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://geocoder.us/service/csv/geocode?address=#{CGI.escape(@address)}&quot;)).returns(response)    
+    url = &quot;http://geocoder.us/service/csv/geocode?address=#{CGI.escape(@address)}&quot;
+    GeoKit::Geocoders::UsGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     assert !GeoKit::Geocoders::UsGeocoder.geocode(@us_full_loc).success   
   end  
   </diff>
      <filename>test/us_geocoder_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/base_geocoder_test.rb'
+require File.join(File.dirname(__FILE__), 'base_geocoder_test')
 
 GeoKit::Geocoders::yahoo = 'Yahoo'
 
@@ -27,34 +27,39 @@ class YahooGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
   def test_yahoo_full_address
     response = MockSuccess.new
     response.expects(:body).returns(YAHOO_FULL)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=Yahoo&amp;location=#{CGI.escape(@address)}&quot;)).returns(response)
+    url = &quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=Yahoo&amp;location=#{CGI.escape(@address)}&quot;
+    GeoKit::Geocoders::YahooGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     do_full_address_assertions(GeoKit::Geocoders::YahooGeocoder.geocode(@address))
   end 
   
   def test_yahoo_full_address_with_geo_loc
     response = MockSuccess.new
     response.expects(:body).returns(YAHOO_FULL)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=Yahoo&amp;location=#{CGI.escape(@full_address)}&quot;)).returns(response)
+    url = &quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=Yahoo&amp;location=#{CGI.escape(@full_address)}&quot;
+    GeoKit::Geocoders::YahooGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     do_full_address_assertions(GeoKit::Geocoders::YahooGeocoder.geocode(@yahoo_full_loc))
   end  
 
   def test_yahoo_city
     response = MockSuccess.new
     response.expects(:body).returns(YAHOO_CITY)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=Yahoo&amp;location=#{CGI.escape(@address)}&quot;)).returns(response)    
+    url = &quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=Yahoo&amp;location=#{CGI.escape(@address)}&quot;
+    GeoKit::Geocoders::YahooGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     do_city_assertions(GeoKit::Geocoders::YahooGeocoder.geocode(@address))
   end
   
   def test_yahoo_city_with_geo_loc
     response = MockSuccess.new
     response.expects(:body).returns(YAHOO_CITY)
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=Yahoo&amp;location=#{CGI.escape(@address)}&quot;)).returns(response)    
+    url = &quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=Yahoo&amp;location=#{CGI.escape(@address)}&quot;  
+    GeoKit::Geocoders::YahooGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     do_city_assertions(GeoKit::Geocoders::YahooGeocoder.geocode(@yahoo_city_loc))
   end  
   
   def test_service_unavailable
     response = MockFailure.new
-    Net::HTTP.expects(:get_response).with(URI.parse(&quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=Yahoo&amp;location=#{CGI.escape(@address)}&quot;)).returns(response)    
+    url = &quot;http://api.local.yahoo.com/MapsService/V1/geocode?appid=Yahoo&amp;location=#{CGI.escape(@address)}&quot;
+    GeoKit::Geocoders::YahooGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     assert !GeoKit::Geocoders::YahooGeocoder.geocode(@yahoo_city_loc).success
   end  
 </diff>
      <filename>test/yahoo_geocoder_test.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>rakefile.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>ed6cc61bc37aad4ebb34cecdb2fc94e49d32b4b4</id>
    </parent>
  </parents>
  <author>
    <name>bill_eisenhauer</name>
    <email>bill_eisenhauer@9265c765-0211-4c68-b2df-6d1bd6e20c4d</email>
  </author>
  <url>http://github.com/ptb/geokit/commit/e495d3dea2e6a8899fdba4620c45dcfade68620d</url>
  <id>e495d3dea2e6a8899fdba4620c45dcfade68620d</id>
  <committed-date>2007-06-03T23:28:09-07:00</committed-date>
  <authored-date>2007-06-03T23:28:09-07:00</authored-date>
  <message>Added timeout and proxy support.  Added count support.  Fixed rake-based test invocation.  Fixed exclusive range condition bug.  Fixed default ip address for localhost

git-svn-id: http://geokit.rubyforge.org/svn/trunk@32 9265c765-0211-4c68-b2df-6d1bd6e20c4d</message>
  <tree>1ed9a2c82590d24c497bfff0f4a57faaf783a19a</tree>
  <committer>
    <name>bill_eisenhauer</name>
    <email>bill_eisenhauer@9265c765-0211-4c68-b2df-6d1bd6e20c4d</email>
  </committer>
</commit>
