Permalink
Browse files

New configuration tests addedd

  • Loading branch information...
1 parent 0674c07 commit 713b6c916c499a7ac52d8f8b009abfa92fbb1f98 Anderson Bravalheri committed Jul 19, 2011
Showing with 39 additions and 0 deletions.
  1. +39 −0 test/configuration_test.rb
View
@@ -2,11 +2,50 @@
require 'test_helper'
class ConfigurationTest < Test::Unit::TestCase
+ def setup
+ Geocoder::Configuration.set_defaults
+ end
def test_exception_raised_on_bad_lookup_config
Geocoder::Configuration.lookup = :stoopid
assert_raises Geocoder::ConfigurationError do
Geocoder.search "something dumb"
end
end
+
+ # --- default configuration ---
+ def test_default_units_in_kilometers
+ assert_equal 111, Geocoder::Calculations.distance_between([0,0], [0,1]).round
+ end
+
+ # --- class method configuration ---
+ def test_configurated_by_class_method
+ Geocoder::Configuration.units = :mi
+ distance = Geocoder::Calculations.distance_between([0,0], [0,1]).round
+ assert_not_equal 111, distance
+ assert_equal 69, distance
+
+ Geocoder::Configuration.units = :km
+ distance = Geocoder::Calculations.distance_between([0,0], [0,1]).round
+ assert_equal 111, distance
+ assert_not_equal 69, distance
+ end
+
+ # --- Geocoder#configure method configuration ---
+ def test_geocoder_configuration
+ Geocoder.configure { |config| config.units = :mi }
+
+ assert_equal Geocoder::Configuration.units, :mi
+ distance = Geocoder::Calculations.distance_between([0,0], [0,1]).round
+ assert_not_equal 111, distance
+ assert_equal 69, distance
+
+ Geocoder.configure.units = :km
+
+ assert_equal Geocoder::Configuration.units, :km
+ distance = Geocoder::Calculations.distance_between([0,0], [0,1]).round
+ assert_equal 111, distance
+ assert_not_equal 69, distance
+ end
end
+

0 comments on commit 713b6c9

Please sign in to comment.