spec/lib/state_spec.rb in geolookup-0.6.2 vs spec/lib/state_spec.rb in geolookup-0.6.4

- old
+ new

@@ -36,19 +36,19 @@ it 'should return an array of state codes' do expect(Geolookup::USA::State.codes).to include(6) end end - describe "#ignored_state_codes" do - it 'should return an array of ignored state codes' do - expect(Geolookup::USA::State.ignored_state_codes).to include(60) + describe "#territory_state_codes" do + it 'should return an array of territory state codes' do + expect(Geolookup::USA::State.territory_state_codes).to include(60) end end - describe "#ignored_state_names" do - it 'should return an array of ignored state names' do - expect(Geolookup::USA::State.ignored_state_names).to include("American Samoa") + describe "#territory_state_names" do + it 'should return an array of territory state names' do + expect(Geolookup::USA::State.territory_state_names).to include("American Samoa") end end describe "#code_to_abbreviation" do it 'should return a state abbreviation gien a state code' do @@ -175,8 +175,119 @@ expect(Geolookup::USA::State.domestic_names.length).to eql(51) end it "should not return Guam" do expect(Geolookup::USA::State.domestic_names).to_not include("Guam") + end + end + + describe '#territory?' do + context 'input is a code' do + context 'code is an integer' do + context 'state is territory' do + it 'returns true' do + state_code = 60 + expect(Geolookup::USA::State.territory?(state_code)).to be true + end + end + context 'state is not territory' do + it 'returns false' do + state_code = 1 + expect(Geolookup::USA::State.territory?(state_code)).to be false + end + end + end + context 'code is a string' do + context 'state is territory' do + it 'returns true' do + state_code = '66' + expect(Geolookup::USA::State.territory?(state_code)).to be true + end + end + context 'state is not territory' do + it 'returns false' do + state_code = '2' + expect(Geolookup::USA::State.territory?(state_code)).to be false + end + end + end + end + context 'input is an abbreviation' do + context 'casing is all upcase' do + context 'state is territory' do + it 'returns true' do + state_abbreviation = 'MP' + expect(Geolookup::USA::State.territory?(state_abbreviation)).to be true + end + end + context 'state is not territory' do + it 'returns false' do + state_abbreviation = 'AZ' + expect(Geolookup::USA::State.territory?(state_abbreviation)).to be false + end + end + end + context 'casing is mixed' do + context 'state is territory' do + it 'returns true' do + state_abbreviation = 'vI' + expect(Geolookup::USA::State.territory?(state_abbreviation)).to be true + end + end + context 'state is not territory' do + it 'returns false' do + state_abbreviation = 'Ar' + expect(Geolookup::USA::State.territory?(state_abbreviation)).to be false + end + end + end + end + context 'input is a state name' do + context 'casing is all upcase' do + context 'state is territory' do + it 'returns true' do + state_name = 'AMERICAN SAMOA' + expect(Geolookup::USA::State.territory?(state_name)).to be true + end + end + context 'state is not territory' do + it 'returns false' do + state_name = 'CALIFORNIA' + expect(Geolookup::USA::State.territory?(state_name)).to be false + end + end + end + context 'casing is mixed' do + context 'state is territory' do + it 'returns true' do + state_name = 'Guam' + expect(Geolookup::USA::State.territory?(state_name)).to be true + end + end + context 'state is not territory' do + it 'returns false' do + state_name = 'CoLoRaDo' + expect(Geolookup::USA::State.territory?(state_name)).to be false + end + end + end + end + end + + describe '#ignored_state_names' do + it 'returns territory_state_names' do + expect(Geolookup::USA::State.ignored_state_names).to eq Geolookup::USA::State.territory_state_names + end + end + + describe '#ignored_state_codes' do + it 'returns territory_state_codes' do + expect(Geolookup::USA::State.ignored_state_codes).to eq Geolookup::USA::State.territory_state_codes + end + end + + describe '#ignored?' do + it 'returns territory' do + expect(Geolookup::USA::State.ignored?('ca')).to eq Geolookup::USA::State.territory?('ca') end end end