Sha256: 5f8911cc7a91088709ebe48922fe669529c0f941d930eeefcf736eb2e7494425

Contents?: true

Size: 1.2 KB

Versions: 26

Compression:

Stored size: 1.2 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

require 'spec_helper'

include TwitterCldr::Shared

describe PhoneCodes do
  describe "#territories" do
    let(:territories) { PhoneCodes.territories }

    it 'returns an array' do
      expect(territories).to be_instance_of(Array)
    end

    it 'returns symbols' do
      territories.each { |territory| expect(territory).to be_instance_of(Symbol) }
    end

    it 'returns supported territories' do
      expect(territories).to include(:br, :fr, :jp)
    end
  end

  describe '#code_for_territory' do
    let(:code)      { '123' }
    let(:territory) { :br }

    before(:each) { mock(PhoneCodes).resource { { territory => code } } }

    it 'returns phone code for a given territory' do
      expect(PhoneCodes.code_for_territory(territory)).to eq(code)
    end

    it 'returns nil if the regex is missing' do
      expect(PhoneCodes.code_for_territory(:foo)).to be_nil
    end

    it 'accepts strings' do
      expect(PhoneCodes.code_for_territory(territory.to_s)).to eq(code)
    end

    it 'accepts upper-case strings' do
      expect(PhoneCodes.code_for_territory(territory.to_s.upcase)).to eq(code)
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
twitter_cldr-4.3.1 spec/shared/phone_codes_spec.rb
twitter_cldr-4.3.0 spec/shared/phone_codes_spec.rb
twitter_cldr-4.2.0 spec/shared/phone_codes_spec.rb
twitter_cldr-4.1.0 spec/shared/phone_codes_spec.rb
twitter_cldr-4.0.0 spec/shared/phone_codes_spec.rb
twitter_cldr-3.6.0 spec/shared/phone_codes_spec.rb
twitter_cldr-3.5.0 spec/shared/phone_codes_spec.rb
twitter_cldr-3.4.0 spec/shared/phone_codes_spec.rb
twitter_cldr-3.3.0 spec/shared/phone_codes_spec.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/spec/shared/phone_codes_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/spec/shared/phone_codes_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/spec/shared/phone_codes_spec.rb
twitter_cldr-3.2.1 spec/shared/phone_codes_spec.rb
twitter_cldr-3.2.0 spec/shared/phone_codes_spec.rb
twitter_cldr-3.1.2 spec/shared/phone_codes_spec.rb
twitter_cldr-3.1.1 spec/shared/phone_codes_spec.rb
twitter_cldr-3.1.0 spec/shared/phone_codes_spec.rb
twitter_cldr-3.0.10 spec/shared/phone_codes_spec.rb
twitter_cldr-3.0.9 spec/shared/phone_codes_spec.rb
twitter_cldr-3.0.8 spec/shared/phone_codes_spec.rb