Sha256: 4f97c21be343bd42d4fdf80349722eaf1230674ba0bec77d13121eea5de6e769

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require_relative '../../spec_helper'

describe Barometer::Query::Format::WeatherID do
  it ".country_code" do
    Barometer::Query::Format::WeatherID.country_code(nil).should be_nil
    Barometer::Query::Format::WeatherID.country_code("i").should be_nil
    Barometer::Query::Format::WeatherID.country_code("USGA0000").should == "US"
    Barometer::Query::Format::WeatherID.country_code("CAAB0000").should == "CA"
    Barometer::Query::Format::WeatherID.country_code("SPXX0000").should == "ES"
  end

  describe ".is?" do
    it "recognizes a valid format" do
      Barometer::Query::Format::WeatherID.is?("USGA0028").should be_true
    end

    it "recognizes non-valid format" do
      Barometer::Query::Format::WeatherID.is?("invalid").should be_false
    end
  end

  describe "fixing country codes" do
    it "doesn't fix a correct code" do
      Barometer::Query::Format::WeatherID.send("_fix_country", "CA").should == "CA"
    end

    it "fixes an incorrect code" do
      Barometer::Query::Format::WeatherID.send("_fix_country", "SP").should == "ES"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
barometer-0.9.1 spec/query/formats/weather_id_spec.rb
barometer-0.9.0 spec/query/formats/weather_id_spec.rb