-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbart_directory_spec.rb
More file actions
52 lines (40 loc) · 1.66 KB
/
bart_directory_spec.rb
File metadata and controls
52 lines (40 loc) · 1.66 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
50
51
52
require './bart_directory'
describe BartDirectory do
before(:each) do
@directory = BartDirectory.new
end
describe '#bart_station?' do
it "should check if an address is a Bart station" do
origin = "2000 Mission Street"
destination = "Sunset Blvd."
@directory.bart_address?(origin).should == origin
@directory.bart_address?(destination).should == nil
end
end
describe "#closest_station" do
it "should return the closest station" do
origin = "2100 Mission Street San Francisco CA"
@directory.closest_station(origin).should == "2000 Mission Street"
end
it "should return the closest station for a different" do
destination = "2800 Diamond Street San Francisco CA"
@directory.closest_station(destination).should == "2901 Diamond Street"
end
end
describe '#get_abbr' do
it "should return the abbrevation of a bart station given an address" do
@directory.get_abbr("2000 Mission Street").should == "16TH"
end
end
describe '#get_lat_long' do
it "should return the latitude and longitude for each bart station" do
@directory.get_lat_long("923 Market St., San Francisco, CA").should == {"lat"=>37.78355000000001, "lng"=>-122.40864}
end
end
describe "#compare_lat_long" do
it "should return a single number value which represents the distance between two latitudes and longitudes" do
@directory.compare_lat_longs({"lat"=>37.78355000000001, "lng"=>-122.40864}, {"lat"=>37.765062, "lng"=>-122.419694}).should be_within(0.00001).of 0.029541999999999
#comparing 923 market st with 2000 mission st
end
end
end