File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ def initialize(default_options = {})
13
13
end
14
14
15
15
def geocode ( location , options = { } )
16
+ raise_error ( "400 Not a valid location: `#{ location . inspect } `" ) unless location . is_a? ( String )
17
+
16
18
request = Request . new ( @api_key , location , options )
17
19
18
20
begin
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ def geo
83
83
expect ( geo . geocode ( 'NOWHERE-INTERESTING' ) ) . to eql ( [ ] )
84
84
end
85
85
86
- it 'raises and error when undefined query' , :vcr do
86
+ it 'raises an error when undefined query' , :vcr do
87
87
expect do
88
88
geo . geocode ( nil )
89
89
end . to raise_error ( OpenCage ::Error ::InvalidRequest )
@@ -94,6 +94,12 @@ def geo
94
94
geo . geocode ( '' )
95
95
end . to raise_error ( OpenCage ::Error ::InvalidRequest )
96
96
end
97
+
98
+ it 'raises a useful error when the query is not a string' do
99
+ expect do
100
+ geo . geocode ( { query : 'NOT-A-STRING' } ) # it's a hash
101
+ end . to raise_error ( OpenCage ::Error ::InvalidRequest )
102
+ end
97
103
end
98
104
99
105
describe 'user agent' do
You can’t perform that action at this time.
0 commit comments