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 = {})
1313 end
1414
1515 def geocode ( location , options = { } )
16+ raise_error ( "400 Not a valid location: `#{ location . inspect } `" ) unless location . is_a? ( String )
17+
1618 request = Request . new ( @api_key , location , options )
1719
1820 begin
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ def geo
8383 expect ( geo . geocode ( 'NOWHERE-INTERESTING' ) ) . to eql ( [ ] )
8484 end
8585
86- it 'raises and error when undefined query' , :vcr do
86+ it 'raises an error when undefined query' , :vcr do
8787 expect do
8888 geo . geocode ( nil )
8989 end . to raise_error ( OpenCage ::Error ::InvalidRequest )
@@ -94,6 +94,12 @@ def geo
9494 geo . geocode ( '' )
9595 end . to raise_error ( OpenCage ::Error ::InvalidRequest )
9696 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
97103 end
98104
99105 describe 'user agent' do
You can’t perform that action at this time.
0 commit comments