adopt-a-hydrant/test/functional/addresses_controller_test.rb

20 lines
965 B
Ruby
Raw Normal View History

2011-05-08 22:12:01 +00:00
require 'test_helper'
class AddressesControllerTest < ActionController::TestCase
test 'should return latitude and longitude for a valid address' do
stub_request(:get, 'http://maps.google.com/maps/geo?q=City+Hall%2C+Boston%2C+MA&output=xml&key=REPLACE_WITH_YOUR_GOOGLE_KEY&oe=utf-8').
2012-06-18 17:49:28 +00:00
to_return(body: File.read(File.expand_path('../../fixtures/city_hall.kml', __FILE__)))
get :show, address: 'City Hall', city_state: "Boston, MA"
2011-05-08 22:12:01 +00:00
assert_not_nil assigns :address
end
test 'should return an error for an invalid address' do
stub_request(:get, 'http://maps.google.com/maps/geo?q=%2C+&output=xml&key=REPLACE_WITH_YOUR_GOOGLE_KEY&oe=utf-8').
2012-06-18 17:49:28 +00:00
to_return(body: File.read(File.expand_path('../../fixtures/unknown_address.kml', __FILE__)))
2011-05-08 22:12:01 +00:00
stub_request(:get, 'http://geocoder.us/service/csv/geocode?address=%2C+').
2012-06-18 17:49:28 +00:00
to_return(body: '', status: 204)
get :show, address: '', city_state: ''
2011-05-08 22:12:01 +00:00
assert_response :missing
end
end