spec/search_spec.rb in parkwhiz-0.3.0 vs spec/search_spec.rb in parkwhiz-0.4.0

- old
+ new

@@ -5,17 +5,31 @@ let :la_search_response do File.read(File.expand_path("spec/responses/la_search_response.json")) end + let :no_location_search_response do + File.read(File.expand_path("spec/responses/no_location_response.json")) + end + let :invalid_search_response do File.read(File.expand_path("spec/responses/invalid_key_response.json")) end before :each do Parkwhiz.api_key = 'asdf1234' end + context 'on empty search results' do + it "should return an emtpy Array" do + expect(connection).to receive(:get) { double( body: JSON.parse(no_location_search_response) ) } + Parkwhiz.connection = connection + locations = Parkwhiz.search({}) + expect(locations).to be_kind_of(Array) + expect(locations).to be_empty + + end + end context "on successful search" do it "should return an array of Parkwhiz::Locations" do expect(connection).to receive(:get) { double( body: JSON.parse(la_search_response) ) } Parkwhiz.connection = connection locations = Parkwhiz.search({}) \ No newline at end of file