Skip to content
Snippets Groups Projects
Commit 8b2da844 authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge branch 'master' of github.com:alexreisner/geocoder

parents d8a6916f a3bb3ee0
No related branches found
No related tags found
No related merge requests found
......@@ -4,11 +4,17 @@ Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/*_test.rb'
test.pattern = 'test/*_test.rb'
test.verbose = true
end
task :default => :test
Rake::TestTask.new(:integration) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/integration/*_test.rb'
test.verbose = true
end
task :default => [:test, :integration]
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
......
......@@ -141,8 +141,11 @@ module Geocoder
def fetch_raw_data(query, reverse = false)
timeout(Geocoder::Configuration.timeout) do
url = query_url(query, reverse)
uri = URI.parse(url)
unless cache and response = cache[url]
response = http_client.get_response(URI.parse(url)).body
client = http_client.new(uri.host, uri.port)
client.use_ssl = true if Geocoder::Configuration.use_https
response = client.get(uri.request_uri).body
if cache
cache[url] = response
end
......
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[ .. .. lib]))
require 'pathname'
require 'rubygems'
require 'test/unit'
require 'geocoder'
class SmokeTest < Test::Unit::TestCase
def test_simple_zip_code_search
result = Geocoder.search "27701"
assert_equal "Durham", result.first.city
assert_equal "North Carolina", result.first.state
end
def test_simple_zip_code_search_with_ssl
Geocoder::Configuration.use_https = true
result = Geocoder.search "27701"
assert_equal "Durham", result.first.city
assert_equal "North Carolina", result.first.state
ensure
Geocoder::Configuration.use_https = false
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment