spec/federation_spec.rb in icu_utils-1.3.0 vs spec/federation_spec.rb in icu_utils-1.3.2

- old
+ new

@@ -1,10 +1,10 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') module ICU describe Federation do - let(:total) { 181 } + let(:total) { 193 } # This number has to be updated to be the number of elements in Federation.@@data context "#find using codes" do it "should find a federation given a valid code" do fed = Federation.find('IRL') expect(fed.code).to eq('IRL') @@ -134,42 +134,42 @@ expect(names.index('Iraq,Ireland,Israel')).not_to be_nil expect(codes.index('AFG')).to eq(0) expect(codes.index('IRQ,IRL,ISR')).not_to be_nil end - it "should be configuarble to order the list by codes" do + it "should be configurable to order the list by codes" do menu = Federation.menu(:order => "code") expect(menu.size).to eq(total) names = menu.map{|m| m.first}.join(',') codes = menu.map{|m| m.last}.join(',') expect(names.index('Afghanistan')).to eq(0) expect(names.index('Ireland,Iraq,Iceland')).not_to be_nil expect(codes.index('AFG')).to eq(0) expect(codes.index('IRL,IRQ,ISL')).not_to be_nil end - it "should be configuarble to have a selected country at the top" do + it "should be configurable to have a selected country at the top" do menu = Federation.menu(:top => 'IRL') expect(menu.size).to eq(total) names = menu.map{|m| m.first}.join(',') codes = menu.map{|m| m.last}.join(',') expect(names.index('Ireland,Afghanistan')).to eq(0) expect(names.index('Iraq,Israel')).not_to be_nil expect(codes.index('IRL,AFG')).to eq(0) expect(codes.index('IRQ,ISR')).not_to be_nil end - it "should be configuarble to have 'None' entry at the top" do + it "should be configurable to have 'None' entry at the top" do menu = Federation.menu(:none => 'None') expect(menu.size).to eq(total + 1) names = menu.map{|m| m.first}.join(',') codes = menu.map{|m| m.last}.join(',') expect(names.index('None,Afghanistan')).to eq(0) expect(codes.index(',AFG')).to eq(0) end - it "should be able to handle multiple configuarations" do + it "should be able to handle multiple configurations" do menu = Federation.menu(:top => 'IRL', :order => 'code', :none => 'None') expect(menu.size).to eq(total + 1) names = menu.map{|m| m.first}.join(',') codes = menu.map{|m| m.last}.join(',') expect(names.index('None,Ireland,Afghanistan')).to eq(0) @@ -187,254 +187,7 @@ expect(all.index('AFG')).to eq(0) expect(all.index('INA,IND,IRI,IRL,IRQ,ISL,ISR,ISV,ITA,IVB')).not_to be_nil end end - context "IOC codes" do - before(:all) do - ioc_and_fide = # from http://en.wikipedia.org/wiki/List_of_IOC_country_codes in November 2013 - { - "AFG" => "Afghanistan", - "AHO" => "Netherlands Antilles", - "ALB" => "Albania", - "ALG" => "Algeria", - "AND" => "Andorra", - "ANG" => "Angola", - "ANT" => "Antigua and Barbuda", - "ARG" => "Argentina", - "ARM" => "Armenia", - "ARU" => "Aruba", - "AUS" => "Australia", - "AUT" => "Austria", - "AZE" => "Azerbaijan", - "BAH" => "Bahamas", - "BAN" => "Bangladesh", - "BAR" => "Barbados", - "BDI" => "Burundi", - "BEL" => "Belgium", - "BEN" => "Benin", - "BER" => "Bermuda", - "BHU" => "Bhutan", - "BIH" => "Bosnia and Herzegovina", - "BIZ" => "Belize", - "BLR" => "Belarus", - "BOL" => "Bolivia", - "BOT" => "Botswana", - "BRA" => "Brazil", - "BRN" => "Bahrain", - "BRU" => "Brunei", - "BUL" => "Bulgaria", - "CAM" => "Cambodia", - "CAN" => "Canada", - "CGO" => "Congo", - "CHA" => "Chad", - "CHI" => "Chile", - "CHN" => "China", - "CIV" => "Ivory Coast", - "CMR" => "Cameroon", - "COL" => "Colombia", - "CRC" => "Costa Rica", - "CRO" => "Croatia", - "CUB" => "Cuba", - "CYP" => "Cyprus", - "CZE" => "Czech Republic", - "DEN" => "Denmark", - "DJI" => "Djibouti", - "DOM" => "Dominican Republic", - "ECU" => "Ecuador", - "EGY" => "Egypt", - "ESA" => "El Salvador", - "ESP" => "Spain", - "EST" => "Estonia", - "ETH" => "Ethiopia", - "FIJ" => "Fiji", - "FIN" => "Finland", - "FRA" => "France", - "FRO" => "Faroe Islands", - "GAB" => "Gabon", - "GAM" => "The Gambia", - "GEO" => "Georgia", - "GER" => "Germany", - "GHA" => "Ghana", - "GRE" => "Greece", - "GUA" => "Guatemala", - "GUM" => "Guam", - "GUY" => "Guyana", - "HAI" => "Haiti", - "HKG" => "Hong Kong", - "HON" => "Honduras", - "HUN" => "Hungary", - "INA" => "Indonesia", - "IND" => "India", - "IRI" => "Iran", - "IRL" => "Ireland", - "IRQ" => "Iraq", - "ISL" => "Iceland", - "ISR" => "Israel", - "ISV" => "Virgin Islands", - "ITA" => "Italy", - "IVB" => "British Virgin Islands", - "JAM" => "Jamaica", - "JOR" => "Jordan", - "JPN" => "Japan", - "KAZ" => "Kazakhstan", - "KEN" => "Kenya", - "KGZ" => "Kyrgyzstan", - "KOR" => "South Korea", - "KSA" => "Saudi Arabia", - "KUW" => "Kuwait", - "LAO" => "Laos", - "LAT" => "Latvia", - "LBA" => "Libya", - "LES" => "Lesotho", - "LIB" => "Lebanon", - "LIE" => "Liechtenstein", - "LTU" => "Lithuania", - "LUX" => "Luxembourg", - "MAC" => "Macau", - "MAD" => "Madagascar", - "MAR" => "Morocco", - "MAS" => "Malaysia", - "MAW" => "Malawi", - "MDA" => "Moldova", - "MDV" => "Maldives", - "MEX" => "Mexico", - "MGL" => "Mongolia", - "MKD" => "Macedonia", - "MLI" => "Mali", - "MLT" => "Malta", - "MNE" => "Montenegro", - "MON" => "Monaco", - "MOZ" => "Mozambique", - "MRI" => "Mauritius", - "MTN" => "Mauritania", - "MYA" => "Myanmar", - "NAM" => "Namibia", - "NCA" => "Nicaragua", - "NED" => "Netherlands", - "NEP" => "Nepal", - "NGR" => "Nigeria", - "NOR" => "Norway", - "NZL" => "New Zealand", - "PAK" => "Pakistan", - "PAN" => "Panama", - "PAR" => "Paraguay", - "PER" => "Peru", - "PHI" => "Philippines", - "PLE" => "Palestine", - "PLW" => "Palau", - "PNG" => "Papua New Guinea", - "POL" => "Poland", - "POR" => "Portugal", - "PUR" => "Puerto Rico", - "QAT" => "Qatar", - "ROU" => "Romania", - "RSA" => "South Africa", - "RUS" => "Russia", - "RWA" => "Rwanda", - "SEN" => "Senegal", - "SEY" => "Seychelles", - "SIN" => "Singapore", - "SLE" => "Sierra Leone", - "SLO" => "Slovenia", - "SMR" => "San Marino", - "SOL" => "Solomon Islands", - "SOM" => "Somalia", - "SRB" => "Serbia", - "SRI" => "Sri Lanka", - "STP" => "Sao Tome and Principe", - "SUD" => "Sudan", - "SUI" => "Switzerland", - "SUR" => "Suriname", - "SVK" => "Slovakia", - "SWE" => "Sweden", - "SWZ" => "Swaziland", - "SYR" => "Syria", - "TAN" => "Tanzania", - "THA" => "Thailand", - "TJK" => "Tajikistan", - "TKM" => "Turkmenistan", - "TOG" => "Togo", - "TPE" => "Chinese Taipei", - "TRI" => "Trinidad and Tobago", - "TUN" => "Tunisia", - "TUR" => "Turkey", - "UAE" => "United Arab Emirates", - "UGA" => "Uganda", - "UKR" => "Ukraine", - "URU" => "Uruguay", - "USA" => "United States", - "UZB" => "Uzbekistan", - "VEN" => "Venezuela", - "VIE" => "Vietnam", - "YEM" => "Yemen", - "ZAM" => "Zambia", - "ZIM" => "Zimbabwe", - } - ioc_but_not_fide = - { - "ASA" => "American Samoa", - "BUR" => "Burkina Faso", - "CAF" => "Central African Republic", - "CAY" => "Cayman Islands", - "COD" => "DR Congo", - "COK" => "Cook Islands", - "COM" => "Comoros", - "CPV" => "Cape Verde", - "DMA" => "Dominica", - "ERI" => "Eritrea", - "FSM" => "Federated States of Micronesia", - "GBR" => "Great Britain", - "GBS" => "Guinea-Bissau", - "GEQ" => "Equatorial Guinea", - "GRN" => "Grenada", - "GUI" => "Guinea", - "KIR" => "Kiribati", - "LBR" => "Liberia", - "LCA" => "Saint Lucia", - "MHL" => "Marshall Islands", - "NIG" => "Niger", - "NRU" => "Nauru", - "OMA" => "Oman", - "PRK" => "North Korea", - "SAM" => "Samoa", - "SKN" => "Saint Kitts and Nevis", - "TGA" => "Tonga", - "TLS" => "Timor-Leste", - "TUV" => "Tuvalu", - "VAN" => "Vanuatu", - "VIN" => "Saint Vincent and the Grenadines", - } - @missing = [] - @badname = [] - british = %w[ENG SCO WLS GCI JCI] - exceptions = # FIDE => IOC - { - "FAI" => "FRO", # Faroe Islands - "MNC" => "MON", # Monaco - } - got = {} - Federation.menu.each do |name, code| - if ioc_and_fide[code] - @badname << "#{code} #{name} #{ioc_and_fide[code]}" unless ioc_and_fide[code].include?(name) || name.include?(ioc_and_fide[code]) - else - @missing << code unless british.include?(code) || exceptions.keys.include?(code) - end - got[code] = true - end - @not_included = ioc_and_fide.keys.reject { |code| got[code] || exceptions.values.include?(code) } - end - - it "codes should be all IOC with some exceptions" do - expect(@missing.join("|")).to eq "" - end - - it "country names should be similar to the IOC name" do - expect(@badname.join("|")).to eq "" - end - - it "all IOC codes that are FIDE members should be present" do - expect(@not_included.join("|")).to eq "" - end - end end end