spec/alert_spec.rb in gull-0.2.8 vs spec/alert_spec.rb in gull-0.2.9

- old
+ new

@@ -5,11 +5,11 @@ alert = Gull::Alert.new expect(alert.geocode).not_to be_nil end it "should fetch parsed alerts" do - xml = File.read "spec/alerts.xml" + xml = File.read "spec/fixtures/alerts.xml" stub_request(:get, "http://alerts.weather.gov/cap/us.php?x=0"). with(:headers => {'Accept'=>'*/*'}). to_return(:status => 200, :body => xml, :headers => {}) @@ -46,7 +46,29 @@ expect(second.polygon).to be_nil expect(second.vtec).to be_nil third = alerts[2] expect(third.vtec).to be_nil + end + + it "should handle empty alerts" do + xml = File.read "spec/fixtures/empty.xml" + + stub_request(:get, "http://alerts.weather.gov/cap/us.php?x=0"). + with(:headers => {'Accept'=>'*/*'}). + to_return(:status => 200, :body => xml, :headers => {}) + + alerts = Gull::Alert.fetch + expect(alerts.size).to eq(0) + end + + it "should handle bad response" do + xml = File.read "spec/fixtures/bad.xml" + + stub_request(:get, "http://alerts.weather.gov/cap/us.php?x=0"). + with(:headers => {'Accept'=>'*/*'}). + to_return(:status => 200, :body => xml, :headers => {}) + + alerts = Gull::Alert.fetch + expect(alerts.size).to eq(0) end end \ No newline at end of file