spec/ratis/landmark_spec.rb in ratis-3.4.1 vs spec/ratis/landmark_spec.rb in ratis-3.4.2
- old
+ new
@@ -10,39 +10,59 @@
end
end
describe "#where" do
before do
- @conditions = {:type => 'all',
+ @conditions = {:type => '*',
:zipcode => '85224'}
end
- it 'only makes one request' do
- pending 'Need method turned on in ATIS'
-
+ it 'only makes one request', vcr: {} do
# false just to stop further processing of response
Ratis::Request.should_receive(:get).once.and_call_original
Ratis::Landmark.where(@conditions.dup)
end
- end
- it 'requests the correct SOAP action' do
- pending
- an_atis_request_for('Getlandmarks', 'Type' => 'ALL').should have_been_made
- end
+ it 'requests the correct SOAP action' do
+ Ratis::Request.should_receive(:get) do |action, options|
+ action.should eq('Getlandmarks')
+ options["Type"].should eq(@conditions[:type])
+ options["Zipcode"].should eq(@conditions[:zipcode])
- it 'should return all landmarks' do
- pending
- @landmarks.should have(2).items
+ end.and_return(double('response', :success? => false))
- @landmarks[0].type.should eql 'AIRPT'
- @landmarks[0].verbose.should eql 'FALCON FIELD AIRPORT'
- @landmarks[0].location.should eql '4800 E. FALCON DR.'
- @landmarks[0].locality.should eql 'N'
+ Ratis::Landmark.where(@conditions.dup)
+ end
- @landmarks[1].type.should eql 'AIRPT'
- @landmarks[1].verbose.should eql 'SKY HARBOR AIRPORT TERMINAL 4 WB'
- @landmarks[1].location.should eql '3700 E SKY HARBOR BLVD'
- @landmarks[1].locality.should eql 'N'
+ it "should return a collection of Ratis::Landmark(s)", vcr: {} do
+ stops = Ratis::Landmark.where(@conditions.dup)
+ stops.each do |obj|
+ expect(obj).to be_a(Ratis::Landmark)
+ end
+ end
+
+ it 'returns multiple landmarks', vcr: {} do
+ stops = Ratis::Landmark.where(@conditions.dup)
+ stops.should have(1514).items
+ end
+
+ it 'parses out the landmark fields correctly', vcr: {} do
+ landmarks = Ratis::Landmark.where(@conditions.dup)
+ landmark = landmarks.first
+
+ expect(landmark.type).to eq('LRT')
+ expect(landmark.verbose).to eq('12JF')
+ expect(landmark.location).to eq('S 12TH ST & E JEFFERSON ST')
+ expect(landmark.locality).to eq('N')
+ end
+
+ it "should raise error for missing arg type" do
+ conditions = @conditions.dup
+ conditions.delete(:type)
+
+ expect do
+ Ratis::Landmark.where(conditions)
+ end.to raise_error(ArgumentError, 'You must provide a type')
+ end
end
end