google-maps 2.2.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,45 +0,0 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
2
-
3
- describe Google::Maps::Place do
4
- describe ".find" do
5
- subject { Google::Maps::Place.find(keyword, country).first }
6
-
7
- context ":nl" do
8
- before{ stub_response("deventer-nl.json") }
9
-
10
- let(:keyword) { "Deventer" }
11
- let(:country) { :nl }
12
-
13
- its(:text) { should eq "Deventer, Nederland" }
14
- its(:html) { should eq "<strong>Deventer</strong>, Nederland" }
15
-
16
- context "keyword with escapeable characters" do
17
- let(:keyword) { "Deventer \\" }
18
- let(:country) { :nl }
19
-
20
- its(:text) { should eq "Deventer, Nederland" }
21
- its(:html) { should eq "<strong>Deventer</strong>, Nederland" }
22
- end
23
- end
24
-
25
- context ":en" do
26
- before { stub_response("deventer-en.json") }
27
-
28
- let(:keyword) { "Deventer" }
29
- let(:country) { :en }
30
-
31
- its(:text) { should eq "Deventer, The Netherlands" }
32
- its(:html) { should eq "<strong>Deventer</strong>, The Netherlands" }
33
- end
34
-
35
- context "only highlights words" do
36
- before { stub_response ("den-haag-nl.json") }
37
-
38
- let(:keyword) { "Den . * { } Haag \\" }
39
- let(:country) { :nl }
40
-
41
- its(:text) { should eq "Den Haag, Nederland" }
42
- its(:html) { should eq "<strong>Den</strong> <strong>Haag</strong>, Nederland" }
43
- end
44
- end
45
- end
@@ -1,52 +0,0 @@
1
- require File.expand_path('../../spec_helper', __FILE__)
2
-
3
- describe Google::Maps::Route do
4
- describe "dutch" do
5
- before(:each) do
6
- stub_response("amsterdam-deventer-nl.json")
7
- @route = Google::Maps::Route.new("Science Park, Amsterdam", "Deventer", :nl)
8
- end
9
-
10
- it "should be able to calculate a route" do
11
- @route.distance.text.should == "104 km"
12
- @route.duration.text.should == "1 uur 12 min."
13
- @route.distance.value.should == 103712
14
- @route.duration.value.should == 4337
15
- end
16
-
17
- it "should be able to present the text in Dutch" do
18
- @route.options[:language].should == :nl
19
- @route.end_address.should == "Deventer, Nederland"
20
- end
21
-
22
- it "should be able to return the address for the origin" do
23
- @route.start_address.should == "Science Park, 1098 Amsterdam, Nederland"
24
- end
25
-
26
- it "should be able to return the address for the destination" do
27
- @route.end_address.should == "Deventer, Nederland"
28
- end
29
-
30
- it "should be able to return the latiude and longitude for the origin" do
31
- @route.start_location.lat.should == 52.35445000000001
32
- @route.start_location.lng.should == 4.95420
33
- @route.origin_latlong.should == "52.35445000000001,4.9542"
34
- end
35
-
36
- it "should be able to return the latiude and longitude for the destination" do
37
- @route.end_location.lat.should == 52.25441000000001
38
- @route.end_location.lng.should == 6.160470
39
- @route.destination_latlong.should == "52.25441000000001,6.16047"
40
- end
41
- end
42
-
43
- describe "english" do
44
- it "should be able to present the text in English" do
45
- stub_response("amsterdam-deventer-en.json")
46
- route = Google::Maps::Route.new("Science Park, Amsterdam", "Deventer", :en)
47
- route.options[:language].should == :en
48
- route.end_address.should == "Deventer, The Netherlands"
49
- end
50
- end
51
-
52
- end
@@ -1,103 +0,0 @@
1
- require File.expand_path('../spec_helper', __FILE__)
2
-
3
- describe Google::Maps do
4
-
5
- describe "Directions" do
6
- before(:each) do
7
- stub_response("amsterdam-deventer-en.json")
8
- end
9
-
10
- it "should be able to calculate a route" do
11
- route = Google::Maps.route("Science Park, Amsterdam", "Deventer")
12
- route.class.should == Google::Maps::Route
13
- route.distance.text.should == "104 km"
14
- route.duration.text.should == "1 hour 12 mins"
15
- route.distance.value.should == 103712
16
- route.duration.value.should == 4337
17
- end
18
-
19
- it "should be able to calculate the distance" do
20
- Google::Maps.distance("Science Park, Amsterdam", "Deventer").should == "104 km"
21
- end
22
-
23
- it "should be able to calculate the duration" do
24
- Google::Maps.duration("Science Park, Amsterdam", "Deventer").should == "1 hour 12 mins"
25
- end
26
- end
27
-
28
- describe "Places" do
29
- before(:each) do
30
- stub_response("deventer-en.json")
31
- end
32
-
33
- it "should find a list of places for a keyword" do
34
- place = Google::Maps.places("Deventer").first
35
- place.class.should == Google::Maps::Place
36
- place.text.should == "Deventer, The Netherlands"
37
- place.html.should == "<strong>Deventer</strong>, The Netherlands"
38
- end
39
- end
40
-
41
- describe "Geocoder" do
42
- it "should lookup a latlong for an address" do
43
- stub_response("geocoder/science-park-400-amsterdam-en.json")
44
-
45
- location = Google::Maps.geocode("Science Park 400, Amsterdam").first
46
- location.class.should == Google::Maps::Location
47
- location.address.should == "Science Park Amsterdam 400, University of Amsterdam, 1098 XH Amsterdam, The Netherlands"
48
- location.latitude.should == 52.3564490
49
- location.longitude.should == 4.95568890
50
-
51
- location.lat_lng.should == [52.3564490, 4.95568890]
52
- end
53
-
54
- it "should handle multiple location for an address" do
55
- stub_response("geocoder/amsterdam-en.json")
56
-
57
- locations = Google::Maps.geocode("Amsterdam")
58
- locations.should have(2).items
59
- location = locations.last
60
- location.address.should == "Amsterdam, NY, USA"
61
- location.latitude.should == 42.93868560
62
- location.longitude.should == -74.18818580
63
- end
64
-
65
- it "should accept languages other than en" do
66
- stub_response("geocoder/science-park-400-amsterdam-nl.json")
67
-
68
- location = Google::Maps.geocode("Science Park 400, Amsterdam", :nl).first
69
- location.address.should == "Science Park 400, Amsterdam, 1098 XH Amsterdam, Nederland"
70
- end
71
-
72
- it "should return an empty array when an address could not be geocoded" do
73
- stub_response("zero-results.json")
74
-
75
- Google::Maps.geocode("Amsterdam").should == []
76
- end
77
- end
78
-
79
- describe ".end_point=" do
80
- it "should set the end_point" do
81
- Google::Maps.end_point = "http://maps.google.com/"
82
- Google::Maps.end_point.should == "http://maps.google.com/"
83
- end
84
- end
85
-
86
- describe ".options" do
87
- it "should return a hash with the current settings" do
88
- Google::Maps.end_point = "test end point"
89
- Google::Maps.options == {:end_point => "test end point"}
90
- end
91
- end
92
-
93
- describe ".configure" do
94
- Google::Maps::Configuration::VALID_OPTIONS_KEYS.each do |key|
95
- it "should set the #{key}" do
96
- Google::Maps.configure do |config|
97
- config.send("#{key}=", key)
98
- Google::Maps.send(key).should == key
99
- end
100
- end
101
- end
102
- end
103
- end