geoloc_test.rb
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'test/unit'
require File.join(File.dirname(__FILE__), '../../../../config/environment')
class GeoLocTest < Test::Unit::TestCase #:nodoc: all
def setup
@loc = GeoKit::GeoLoc.new
end
def test_is_us
assert !@loc.is_us?
@loc.country_code = 'US'
assert @loc.is_us?
end
def test_street_number
@loc.street_address = '123 Spear St.'
assert_equal '123', @loc.street_number
end
def test_street_name
@loc.street_address = '123 Spear St.'
assert_equal 'Spear St.', @loc.street_name
end
def test_city
@loc.city = "san francisco"
assert_equal 'San Francisco', @loc.city
end
def test_full_address
@loc.city = 'San Francisco'
@loc.state = 'CA'
@loc.zip = '94105'
@loc.country_code = 'US'
assert_equal 'San Francisco, CA, 94105, US', @loc.full_address
@loc.full_address = 'Irving, TX, 75063, US'
assert_equal 'Irving, TX, 75063, US', @loc.full_address
end
def test_hash
@loc.city = 'San Francisco'
@loc.state = 'CA'
@loc.zip = '94105'
@loc.country_code = 'US'
@another = GeoKit::GeoLoc.new @loc.to_hash
assert_equal @loc, @another
end
end