Sha256: 573a77bf392e5ddd97485b27578c4701869b8bd8b7494194d10e670031a58cfc

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe Gull::Alert do
  it "should fetch parsed alerts" do
    xml = File.read "spec/alerts.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(3)

    first = alerts.first
    expect(first.id).to eq "http://alerts.weather.gov/cap/wwacapget.php?x=CA125171381DD0.HeatAdvisory"
    expect(first.alert_type).to eq "Heat Advisory"
    expect(first.title).to eq "Heat Advisory issued October 01 at 8:40AM PDT until October 03 at 9:00PM PDT by NWS"
    expect(first.summary).to eq "SUMMARY TEXT"
    
    coordinates = [[27.35,-81.79], [27.14,-81.89], [27.04,-81.97], [27.04,-82.02], [27.14,-81.97], [27.35,-81.86],
      [27.35,-81.79]]
    expect(first.polygon.coordinates).to eq coordinates
    
    expect(first.effective_at).to eq Time.parse("2014-10-01T08:40:00-07:00")
    expect(first.expires_at).to eq Time.parse("2014-10-03T21:00:00-07:00")
    expect(first.area).to eq "Southern Salinas Valley, Arroyo Seco and Lake San Antonio"
    expect(first.urgency).to eq :expected
    expect(first.severity).to eq :minor
    expect(first.certainty).to eq :very_likely

    second = alerts[1]
    expect(second.polygon).to be_nil
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gull-0.2.4 spec/alert_spec.rb
gull-0.2.3 spec/alert_spec.rb
gull-0.2.2 spec/alert_spec.rb
gull-0.2.1 spec/alert_spec.rb
gull-0.2.0 spec/alert_spec.rb