Sha256: 95e804ad1a45d853795f8031897d5a94dae0294c9cfd0676b526c141d02c3d69

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

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.3 spec/gman/country_code_spec.rb