Sha256: a016fd54572198c9d4dc040fd82e700a2b778765587e0a8d3141a484468babf6

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

RSpec.describe 'Gman Country Codes' do
  {
    'whitehouse.gov' => 'United States of America',
    'foo.gov.uk'     => 'United Kingdom of Great Britain and Northern Ireland',
    'army.mil'       => 'United States of America',
    'foo.gc.ca'      => 'Canada',
    'foo.eu'         => nil
  }.each do |domain, expected_country|
    context "given #{domain.inspect}" do
      subject { Gman.new(domain) }
      let(:country) { subject.country }

      it 'knows the country' do
        if expected_country.nil?
          expect(country).to be_nil
        else
          expect(country.name).to eql(expected_country)
        end
      end

      it 'knows the alpha2' do
        expected = case expected_country
                   when 'United States of America'
                     'us'
                   when 'Canada'
                     'ca'
                   when 'United Kingdom of Great Britain and Northern Ireland'
                     'gb'
                   else
                     'eu'
                   end
        expect(subject.alpha2).to eql(expected)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gman-7.0.2 spec/gman/country_code_spec.rb