-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapbox_test.rb
41 lines (34 loc) · 1.06 KB
/
mapbox_test.rb
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
require 'mapbox'
require 'test/unit'
require 'mocha/setup'
require 'shoulda'
module Mapbox
class ModuleTest < Test::Unit::TestCase
should "throw if access_token is not defined" do
assert_raise {
Mapbox.request()
}
end
should "allow access token to be set" do
Mapbox.access_token = "foo"
end
end
class HashUtilTest < Test::Unit::TestCase
include Mapbox::HashUtils
should "return array of long,lat from hash with string keys" do
assert_equal xy_from_hash({'longitude' => -122, 'latitude' => 45}),
[-122, 45]
end
should "return array of long,lat from hash with symbol keys" do
assert_equal xy_from_hash({:longitude => -122, :latitude => 45}),
[-122, 45]
end
should "return array of long,lat from hash with mixed keys" do
assert_equal xy_from_hash({:longitude => -122, 'latitude' => 45}),
[-122, 45]
end
should "raise arguemnt error if not given a hash" do
assert_raise { xy_from_hash(Object.new) }
end
end
end