spec/query/formats/weather_id_spec.rb in barometer-0.9.1 vs spec/query/formats/weather_id_spec.rb in barometer-0.9.2

- old
+ new

@@ -1,31 +1,29 @@ 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 +module Barometer::Query + describe Format::WeatherID do + describe '.geo' do + specify { expect( Format::WeatherID.geo(nil) ).to be_nil } + specify { expect( Format::WeatherID.geo('i') ).to be_nil } - describe ".is?" do - it "recognizes a valid format" do - Barometer::Query::Format::WeatherID.is?("USGA0028").should be_true - end + context 'when the country code is standard' do + specify { expect( Format::WeatherID.geo('USGA0000') ).to eq({country_code: 'US'}) } + specify { expect( Format::WeatherID.geo('CAAB0000') ).to eq({country_code: 'CA'}) } + end - it "recognizes non-valid format" do - Barometer::Query::Format::WeatherID.is?("invalid").should be_false + context 'when the country code is non standard' do + specify { expect( Format::WeatherID.geo('SPXX0000') ).to eq({country_code: 'ES'}) } + end 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 + describe '.is?' do + it 'recognizes a valid format' do + expect( Format::WeatherID.is?('USGA0028') ).to be_true + end - it "fixes an incorrect code" do - Barometer::Query::Format::WeatherID.send("_fix_country", "SP").should == "ES" + it 'recognizes non-valid format' do + expect( Format::WeatherID.is?('invalid') ).to be_false + end end end end