google-maps 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/LICENSE.mkd +7 -0
- data/README.mkd +34 -0
- data/Rakefile +19 -0
- data/google-maps.gemspec +31 -0
- data/lib/google-maps.rb +38 -0
- data/lib/google-maps/api.rb +89 -0
- data/lib/google-maps/configuration.rb +70 -0
- data/lib/google-maps/location.rb +25 -0
- data/lib/google-maps/logger.rb +18 -0
- data/lib/google-maps/place.rb +88 -0
- data/lib/google-maps/route.rb +37 -0
- data/lib/google-maps/version.rb +5 -0
- data/spec/fixtures/amsterdam-deventer-en.json +394 -0
- data/spec/fixtures/amsterdam-deventer-nl.json +394 -0
- data/spec/fixtures/den-haag-nl.json +165 -0
- data/spec/fixtures/deventer-en.json +139 -0
- data/spec/fixtures/deventer-nl.json +135 -0
- data/spec/fixtures/geocoder/amsterdam-en.json +111 -0
- data/spec/fixtures/geocoder/science-park-400-amsterdam-en.json +78 -0
- data/spec/fixtures/geocoder/science-park-400-amsterdam-nl.json +78 -0
- data/spec/fixtures/over_query_limit.json +4 -0
- data/spec/fixtures/place_details.json +131 -0
- data/spec/fixtures/zero-results.json +4 -0
- data/spec/google-maps/api_spec.rb +103 -0
- data/spec/google-maps/logger_spec.rb +15 -0
- data/spec/google-maps/place_details_spec.rb +32 -0
- data/spec/google-maps/place_spec.rb +45 -0
- data/spec/google-maps/route_spec.rb +52 -0
- data/spec/google-maps_spec.rb +103 -0
- data/spec/spec_helper.rb +36 -0
- metadata +233 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
{
|
2
|
+
"results" : [
|
3
|
+
{
|
4
|
+
"address_components" : [
|
5
|
+
{
|
6
|
+
"long_name" : "400",
|
7
|
+
"short_name" : "400",
|
8
|
+
"types" : [ "street_number" ]
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"long_name" : "University of Amsterdam",
|
12
|
+
"short_name" : "University of Amsterdam",
|
13
|
+
"types" : [ "establishment" ]
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"long_name" : "Science Park Amsterdam",
|
17
|
+
"short_name" : "Science Park Amsterdam",
|
18
|
+
"types" : [ "route" ]
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"long_name" : "Middenmeer",
|
22
|
+
"short_name" : "Middenmeer",
|
23
|
+
"types" : [ "sublocality", "political" ]
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"long_name" : "Watergraafsmeer",
|
27
|
+
"short_name" : "Watergraafsmeer",
|
28
|
+
"types" : [ "sublocality", "political" ]
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"long_name" : "Amsterdam",
|
32
|
+
"short_name" : "Amsterdam",
|
33
|
+
"types" : [ "locality", "political" ]
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"long_name" : "Government of Amsterdam",
|
37
|
+
"short_name" : "Government of Amsterdam",
|
38
|
+
"types" : [ "administrative_area_level_2", "political" ]
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"long_name" : "Noord-Holland",
|
42
|
+
"short_name" : "NH",
|
43
|
+
"types" : [ "administrative_area_level_1", "political" ]
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"long_name" : "The Netherlands",
|
47
|
+
"short_name" : "NL",
|
48
|
+
"types" : [ "country", "political" ]
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"long_name" : "1098 XH",
|
52
|
+
"short_name" : "1098 XH",
|
53
|
+
"types" : [ "postal_code" ]
|
54
|
+
}
|
55
|
+
],
|
56
|
+
"formatted_address" : "Science Park Amsterdam 400, University of Amsterdam, 1098 XH Amsterdam, The Netherlands",
|
57
|
+
"geometry" : {
|
58
|
+
"location" : {
|
59
|
+
"lat" : 52.3564490,
|
60
|
+
"lng" : 4.95568890
|
61
|
+
},
|
62
|
+
"location_type" : "ROOFTOP",
|
63
|
+
"viewport" : {
|
64
|
+
"northeast" : {
|
65
|
+
"lat" : 52.35779798029149,
|
66
|
+
"lng" : 4.957037880291502
|
67
|
+
},
|
68
|
+
"southwest" : {
|
69
|
+
"lat" : 52.35510001970850,
|
70
|
+
"lng" : 4.954339919708498
|
71
|
+
}
|
72
|
+
}
|
73
|
+
},
|
74
|
+
"types" : [ "street_address" ]
|
75
|
+
}
|
76
|
+
],
|
77
|
+
"status" : "OK"
|
78
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
{
|
2
|
+
"results" : [
|
3
|
+
{
|
4
|
+
"address_components" : [
|
5
|
+
{
|
6
|
+
"long_name" : "400",
|
7
|
+
"short_name" : "400",
|
8
|
+
"types" : [ "street_number" ]
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"long_name" : "Amsterdam",
|
12
|
+
"short_name" : "Amsterdam",
|
13
|
+
"types" : [ "establishment" ]
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"long_name" : "Science Park",
|
17
|
+
"short_name" : "Science Park",
|
18
|
+
"types" : [ "route" ]
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"long_name" : "Middenmeer",
|
22
|
+
"short_name" : "Middenmeer",
|
23
|
+
"types" : [ "sublocality", "political" ]
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"long_name" : "Watergraafsmeer",
|
27
|
+
"short_name" : "Watergraafsmeer",
|
28
|
+
"types" : [ "sublocality", "political" ]
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"long_name" : "Amsterdam",
|
32
|
+
"short_name" : "Amsterdam",
|
33
|
+
"types" : [ "locality", "political" ]
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"long_name" : "Amsterdam",
|
37
|
+
"short_name" : "Amsterdam",
|
38
|
+
"types" : [ "administrative_area_level_2", "political" ]
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"long_name" : "Noord-Holland",
|
42
|
+
"short_name" : "NH",
|
43
|
+
"types" : [ "administrative_area_level_1", "political" ]
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"long_name" : "Nederland",
|
47
|
+
"short_name" : "NL",
|
48
|
+
"types" : [ "country", "political" ]
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"long_name" : "1098 XH",
|
52
|
+
"short_name" : "1098 XH",
|
53
|
+
"types" : [ "postal_code" ]
|
54
|
+
}
|
55
|
+
],
|
56
|
+
"formatted_address" : "Science Park 400, Amsterdam, 1098 XH Amsterdam, Nederland",
|
57
|
+
"geometry" : {
|
58
|
+
"location" : {
|
59
|
+
"lat" : 52.3564490,
|
60
|
+
"lng" : 4.95568890
|
61
|
+
},
|
62
|
+
"location_type" : "ROOFTOP",
|
63
|
+
"viewport" : {
|
64
|
+
"northeast" : {
|
65
|
+
"lat" : 52.35779798029149,
|
66
|
+
"lng" : 4.957037880291502
|
67
|
+
},
|
68
|
+
"southwest" : {
|
69
|
+
"lat" : 52.35510001970850,
|
70
|
+
"lng" : 4.954339919708498
|
71
|
+
}
|
72
|
+
}
|
73
|
+
},
|
74
|
+
"types" : [ "street_address" ]
|
75
|
+
}
|
76
|
+
],
|
77
|
+
"status" : "OK"
|
78
|
+
}
|
@@ -0,0 +1,131 @@
|
|
1
|
+
{
|
2
|
+
"html_attributions" : [],
|
3
|
+
"result" : {
|
4
|
+
"address_components" : [
|
5
|
+
{
|
6
|
+
"long_name" : "48",
|
7
|
+
"short_name" : "48",
|
8
|
+
"types" : [ "street_number" ]
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"long_name" : "Pirrama Road",
|
12
|
+
"short_name" : "Pirrama Road",
|
13
|
+
"types" : [ "route" ]
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"long_name" : "Pyrmont",
|
17
|
+
"short_name" : "Pyrmont",
|
18
|
+
"types" : [ "locality", "political" ]
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"long_name" : "NSW",
|
22
|
+
"short_name" : "NSW",
|
23
|
+
"types" : [ "administrative_area_level_1", "political" ]
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"long_name" : "AU",
|
27
|
+
"short_name" : "AU",
|
28
|
+
"types" : [ "country", "political" ]
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"long_name" : "2009",
|
32
|
+
"short_name" : "2009",
|
33
|
+
"types" : [ "postal_code" ]
|
34
|
+
}
|
35
|
+
],
|
36
|
+
"formatted_address" : "5/48 Pirrama Road, Pyrmont NSW, Australia",
|
37
|
+
"geometry" : {
|
38
|
+
"location" : {
|
39
|
+
"lat" : -33.8669750,
|
40
|
+
"lng" : 151.1956770
|
41
|
+
}
|
42
|
+
},
|
43
|
+
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
|
44
|
+
"id" : "4f89212bf76dde31f092cfc14d7506555d85b5c7",
|
45
|
+
"name" : "Google Sydney",
|
46
|
+
"photos" : [
|
47
|
+
{
|
48
|
+
"height" : 1536,
|
49
|
+
"html_attributions" : [],
|
50
|
+
"photo_reference" : "CoQBcgAAALLroO5acXwquBFUPyAbemoxDjt4Dx8fu0bNzwQFSnFRMuu3UcTGH5GUzCb7tqO9kR0016cDjqFyIfdDHDZrsF101R_wXCtsHLxh-h9oww3qQOCqvrA8IkyBu8egY6ZSII0JPKhKYsT9DpbR5FDtWW5lUbnfq-Y7LWCZIKIghPM6EhCuQBKLOxZBv0nBzkHbGaG2GhQvoB4JGipfjK_F4hEfBB4SnljN2Q",
|
51
|
+
"width" : 2048
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"height" : 480,
|
55
|
+
"html_attributions" : [],
|
56
|
+
"photo_reference" : "CnRqAAAAln93UDawHiQrVVVo9_V_GG9GniClBhwSS7EniT10_AvNZmW9LlMgbWi9eXSusyq3j5Es9xDrQ1Zsvub7uQx5bxOCBOnKzkTrucKD_Mi84aE0scpk2i3tIhs2Jdb07sruocLBNs4v5OTLQxQgVj-inxIQDnl1mmvxXSkQCs296xQBLRoUEw6XEGHSfvyzUEBSz_mqVgx9R4I",
|
57
|
+
"width" : 640
|
58
|
+
}
|
59
|
+
],
|
60
|
+
"rating" : 4.70,
|
61
|
+
"reference" : "CpQBiAAAAGs4XDizjQoVk9NjuY3ll3aLBLafpDxaFPSJSO7icOj07IRHO4KjjcRIbKEmeSVTcG75kIvwqE7VzA8D7BFvWp8OPwgAiKMveQQUsTGfJrRG5EVd7J34hY8e5JDbaXEPOMUPIWLfiugwUfQqAImvWQCGrMG1iyOpZfaW22NNhornssEg90uxrLbwLJ7QZhwGIRIQSBc_BlD7mILqQaixzTqE1BoUbNrhbmsZYkIurvK4l9exKBryfKk",
|
62
|
+
"reviews" : [
|
63
|
+
{
|
64
|
+
"aspects" : [
|
65
|
+
{
|
66
|
+
"rating" : 0,
|
67
|
+
"type" : "quality"
|
68
|
+
}
|
69
|
+
],
|
70
|
+
"author_name" : "Vanessa Wiseman",
|
71
|
+
"author_url" : "https://plus.google.com/118187699378922275112",
|
72
|
+
"text" : "Google advertising is EVIL! It is not a fair forum and Google wont help. They never help. Good luck speaking with a real human. Competitors can post any nasty unture statements they like to ruin your business. Google doesnt care. Google + Sux. I wish i had never heard of it. Woopdi they have given themselves great pay and a great office and free food. I hope you choke on it. Stop patting your self on the back and try listening to small business and actually doing some work instead of having meetings and discussing how good you think you all are. PS. Lets see if you keep this review, or delete it. BECAUSE ITS TRUE!!!!!!",
|
73
|
+
"time" : 1346283496
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"aspects" : [
|
77
|
+
{
|
78
|
+
"rating" : 0,
|
79
|
+
"type" : "quality"
|
80
|
+
}
|
81
|
+
],
|
82
|
+
"author_name" : "Sunstruck Window Cleaning Hornsby",
|
83
|
+
"author_url" : "https://plus.google.com/103617623203300214486",
|
84
|
+
"text" : "I agree with Vanessa Wiseman. Google doesn't give a damm about your business and reviews unless they are making money from you. I have spent years and thousands on getting my business on their first page only for some reason that I can't get an explanation from anyone disappeared a few days ago. I went from being number 1 in the organic listing to gone, no where to be seen. WHY GOOGLE? WHY HAS MY BUSINESS AD SUDDENLY DISAPPEARED?",
|
85
|
+
"time" : 1348551490
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"aspects" : [
|
89
|
+
{
|
90
|
+
"rating" : 3,
|
91
|
+
"type" : "overall"
|
92
|
+
}
|
93
|
+
],
|
94
|
+
"author_name" : "Joseph Wang",
|
95
|
+
"author_url" : "https://plus.google.com/100092142084689765727",
|
96
|
+
"text" : "Born from the depths of Sydney Harbour, the Accenture building transcends the ephemeral to become a landmark of liberty of freedom. Within the predefined boundaries of this establishment lies the brain, heart and soul of Google Sydney. And may this magnificent deity continue to be for eternity.",
|
97
|
+
"time" : 1329380640
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"aspects" : [
|
101
|
+
{
|
102
|
+
"rating" : 3,
|
103
|
+
"type" : "quality"
|
104
|
+
}
|
105
|
+
],
|
106
|
+
"author_name" : "Tim Lacey",
|
107
|
+
"author_url" : "https://plus.google.com/111157746837259488919",
|
108
|
+
"text" : "What I would give to work here: ALL OF THE THINGS!!! Nerds in their element and Australia's Best Place to Work in 2011.",
|
109
|
+
"time" : 1338385221
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"aspects" : [
|
113
|
+
{
|
114
|
+
"rating" : 3,
|
115
|
+
"type" : "quality"
|
116
|
+
}
|
117
|
+
],
|
118
|
+
"author_name" : "Simon Bengtsson",
|
119
|
+
"author_url" : "https://plus.google.com/104675092887960962573",
|
120
|
+
"text" : "Just went inside to have a look at Google. Amazing.",
|
121
|
+
"time" : 1338440552
|
122
|
+
}
|
123
|
+
],
|
124
|
+
"types" : [ "establishment" ],
|
125
|
+
"url" : "https://plus.google.com/111840715355681175070/about?hl=en-US",
|
126
|
+
"utc_offset" : 660,
|
127
|
+
"vicinity" : "5/48 Pirrama Road, Pyrmont",
|
128
|
+
"website" : "http://www.google.com.au/"
|
129
|
+
},
|
130
|
+
"status" : "OK"
|
131
|
+
}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Google::Maps::API do
|
4
|
+
it "should raise a custom exception when the query fails by net" do
|
5
|
+
HTTPClient.any_instance.unstub(:get_content)
|
6
|
+
|
7
|
+
Google::Maps.end_point = "http://unknown.tld/"
|
8
|
+
lambda{ Google::Maps.distance("Amsterdam", "Deventer") }.should raise_error(Google::Maps::InvalidResponseException)
|
9
|
+
Google::Maps.end_point = "http://unknown-domain-asdasdasdas123123zxcasd.com/"
|
10
|
+
lambda{ Google::Maps.distance("Amsterdam", "Deventer") }.should raise_error(Google::Maps::InvalidResponseException)
|
11
|
+
Google::Maps.end_point = "http://www.google.com/404"
|
12
|
+
lambda{ Google::Maps.distance("Amsterdam", "Deventer") }.should raise_error(Google::Maps::InvalidResponseException)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should raise a custom exception when the query fails by Google" do
|
16
|
+
stub_response("over_query_limit.json")
|
17
|
+
lambda{ Google::Maps.distance("Amsterdam", "Deventer") }.should raise_error(Google::Maps::InvalidResponseException)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should raise a custom exception when there are no results" do
|
21
|
+
stub_response("zero-results.json")
|
22
|
+
lambda{ Google::Maps.distance("Blah blah", "Jalala") }.should raise_error(Google::Maps::ZeroResultsException)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise a custom exception that is rescue-able" do
|
26
|
+
stub_response("zero-results.json")
|
27
|
+
begin
|
28
|
+
Google::Maps.distance("Blah blah", "Jalala")
|
29
|
+
rescue => error
|
30
|
+
@error = error
|
31
|
+
ensure
|
32
|
+
@error.should_not be_nil
|
33
|
+
@error.should be_a_kind_of StandardError
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "premier signing" do
|
38
|
+
before :each do
|
39
|
+
Google::Maps.configure do |config|
|
40
|
+
config.premier_client_id = "clientID"
|
41
|
+
config.premier_key = "vNIXE0xscrmjlyV-12Nj_BvUPaw="
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should raise an exception when a client id is set but no key" do
|
46
|
+
Google::Maps.premier_key = nil
|
47
|
+
lambda{ Google::Maps.distance("Amsterdam", "Deventer") }.should raise_error(Google::Maps::InvalidPremierConfigurationException)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should sign the url parameters when a client id and premier key is set" do
|
51
|
+
# http://code.google.com/apis/maps/documentation/webservices/index.html#URLSigning
|
52
|
+
|
53
|
+
# Example:
|
54
|
+
# Private Key: vNIXE0xscrmjlyV-12Nj_BvUPaw=
|
55
|
+
# Signature: KrU1TzVQM7Ur0i8i7K3huiw3MsA=
|
56
|
+
# Client ID: clientID
|
57
|
+
# URL: http://maps.googleapis.com/maps/api/geocode/json?address=New+York&sensor=false&client=clientID
|
58
|
+
url = "http://maps.google.com/maps/api/geocode/json?address=New+York&sensor=false&client=clientID"
|
59
|
+
signed_url = Google::Maps::API.send(:premier_signing, url)
|
60
|
+
signed_url.should == "#{url}&signature=KrU1TzVQM7Ur0i8i7K3huiw3MsA="
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should allow a parsed URI object to be used for signing" do
|
64
|
+
url = URI.parse("http://maps.google.com/maps/api/geocode/json?address=New+York&sensor=false&client=clientID")
|
65
|
+
signed_url = Google::Maps::API.send(:premier_signing, url)
|
66
|
+
signed_url.should == "#{url}&signature=KrU1TzVQM7Ur0i8i7K3huiw3MsA="
|
67
|
+
end
|
68
|
+
|
69
|
+
context "per service overrides" do
|
70
|
+
let(:reference) { "CpQBiAAAAGs4XDizjQoVk9NjuY3ll3aLBLafpDxaFPSJSO7icOj07IRHO4KjjcRIbKEmeSVTcG75kIvwqE7VzA8D7BFvWp8OPwgAiKMveQQUsTGfJrRG5EVd7J34hY8e5JDbaXEPOMUPIWLfiugwUfQqAImvWQCGrMG1iyOpZfaW22NNhornssEg90uxrLbwLJ7QZhwGIRIQSBc_BlD7mILqQaixzTqE1BoUbNrhbmsZYkIurvK4l9exKBryfKk" }
|
71
|
+
let(:api_key) { "some_api_key" }
|
72
|
+
let(:parameters) { [:premier_client_id, :premier_key, :api_key, :default_params] }
|
73
|
+
|
74
|
+
before :each do
|
75
|
+
parameters.each do |what|
|
76
|
+
self.instance_variable_set(:"@old_#{what}", Google::Maps.send(what))
|
77
|
+
end
|
78
|
+
|
79
|
+
Google::Maps.configure do |config|
|
80
|
+
config.premier_client_id = "gme-test"
|
81
|
+
config.premier_key = "secret"
|
82
|
+
config.api_key = api_key
|
83
|
+
config.default_params = {place_details_service: {:use_premier_signing => false}}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
after :each do
|
88
|
+
Google::Maps.configure do |config|
|
89
|
+
parameters.each do |what|
|
90
|
+
config.send(:"#{what}=", self.instance_variable_get(:"@old_#{what}"))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should not be used when configured for a certain service" do
|
96
|
+
stub_response("place_details.json", "https://maps.googleapis.com/maps/api/place/details/json?sensor=false&language=nl&reference=#{reference}&key=#{api_key}")
|
97
|
+
|
98
|
+
Google::Maps::place(reference, :nl).should_not be_nil
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
describe Google::Maps::Logger do
|
5
|
+
it "should be able to log messages when a log output is set" do
|
6
|
+
# fake an exception
|
7
|
+
HTTPClient.any_instance.expects(:get_content).raises("test exception")
|
8
|
+
|
9
|
+
# expect the logger to be called once
|
10
|
+
Logger.any_instance.expects(:error).at_least_once
|
11
|
+
|
12
|
+
# trigger the exception
|
13
|
+
lambda{ Google::Maps.distance("Amsterdam", "Deventer") }.should raise_error
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Google::Maps::PlaceDetails do
|
4
|
+
let(:reference) { "CpQBiAAAAGs4XDizjQoVk9NjuY3ll3aLBLafpDxaFPSJSO7icOj07IRHO4KjjcRIbKEmeSVTcG75kIvwqE7VzA8D7BFvWp8OPwgAiKMveQQUsTGfJrRG5EVd7J34hY8e5JDbaXEPOMUPIWLfiugwUfQqAImvWQCGrMG1iyOpZfaW22NNhornssEg90uxrLbwLJ7QZhwGIRIQSBc_BlD7mILqQaixzTqE1BoUbNrhbmsZYkIurvK4l9exKBryfKk" }
|
5
|
+
|
6
|
+
context "given a canned response" do
|
7
|
+
before(:each) do
|
8
|
+
stub_response("place_details.json")
|
9
|
+
@details = Google::Maps::PlaceDetails.find(reference, :nl)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should have a reference" do
|
13
|
+
@details.reference.should == reference
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have a latlong" do
|
17
|
+
@details.latitude.should == "-33.866975"
|
18
|
+
@details.longitude.should =="151.195677"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has data containing at least address components" do
|
22
|
+
@details.data.address_components.should_not be_empty
|
23
|
+
end
|
24
|
+
|
25
|
+
context "#address_components" do
|
26
|
+
it "allows easy access by type" do
|
27
|
+
@details.address_components.postal_code.long_name.should eq "2009"
|
28
|
+
@details.address_components.locality.long_name.should eq "Pyrmont"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|