File: region_spec.rb

package info (click to toggle)
ruby-iso 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 204 kB
  • sloc: ruby: 364; makefile: 4
file content (31 lines) | stat: -rw-r--r-- 703 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'spec_helper'

describe ISO::Region do
  let(:region) { ISO::Region.new('FR', name: 'France') }

  it "is a ISO Subtag" do
    expect(region).to be_kind_of(ISO::Subtag)
  end

  it "has a code" do
    expect(region.code).to eq 'FR'
  end

  it "has a name" do
    expect(region.name).to eq 'France'
  end

  describe ".identify(full_code)" do
    it "identifies from 'fr-CH'" do
      expect(ISO::Region.identify('fr-CH')).to eq ISO::Region.find('CH')
    end

    it "identifies from 'es_MX" do
      expect(ISO::Region.identify('es_MX')).to eq ISO::Region.find('MX')
    end

    it "returns nil when it can't identify" do
      expect(ISO::Region.identify('gsw')).to be_nil
    end
  end
end