Sha256: 145e5dd9f99a4ef7979e19a7c89386bd12aa6a9993b8445d6a639ae5e9de9d32

Contents?: true

Size: 1014 Bytes

Versions: 6

Compression:

Stored size: 1014 Bytes

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rubygems'
require 'go_maps'
require 'spec'
require 'spec/autorun'
require 'fakeweb'

Spec::Runner.configure do |config|
  FakeWeb.allow_net_connect = false
end

def map_addresses_to_file(address1, address2, file_name, options = {})
  options[:language] ||= "en"
  map_query_string_to_file "origin=#{address1}&destination=#{address2}&language=#{options[:language]}", file_name
end

def map_address_to_file(address, file_name)
  map_query_string_to_file "address=#{address}", file_name
end

def map_query_string_to_file(query_string, file_name)
  api = query_string.include?('destination') ? 'directions' : 'geocode'
  map_url_to_file "http://maps.google.com/maps/api/#{api}/json?sensor=false&units=metric&#{query_string}", file_name
end

def map_url_to_file(url, file_name)
  FakeWeb.register_uri(:get, URI.escape(url), :body => File.open("#{File.dirname(__FILE__)}/data/#{file_name}").read)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
go_maps-0.4.2 spec/spec_helper.rb
go_maps-0.4.1 spec/spec_helper.rb
go_maps-0.4 spec/spec_helper.rb
go_maps-0.3.2 spec/spec_helper.rb
go_maps-0.3.1 spec/spec_helper.rb
go_maps-0.3.0 spec/spec_helper.rb