Sha256: 771e4e409a78a5ea38a4eb7551941c25077bf9ef3330a87a89a3edad45668700

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

# -*- coding: utf-8 -*-
require "test_helper"

describe Iso639::Language do
  it "should respond to char codes and names" do
    lang = Iso639::Language.new "eng", "", "en", "English", "anglais"
    assert lang.respond_to? :alpha3_bibliographic
    assert lang.respond_to? :alpha3_terminology
    assert lang.respond_to? :alpha3
    assert lang.respond_to? :alpha2
    assert lang.respond_to? :english_name
    assert lang.respond_to? :french_name
    assert lang.respond_to? :name
  end

  it "should assign the proper accessor from the constructor" do
    lang = Iso639::Language.new "fre", "fra", "fr", "French", "français"
    assert_equal "fre",      lang.alpha3_bibliographic
    assert_equal "fre",      lang.alpha3
    assert_equal "fra",      lang.alpha3_terminology
    assert_equal "fr",       lang.alpha2
    assert_equal "French",   lang.english_name
    assert_equal "French",   lang.name
    assert_equal "français", lang.french_name
  end

  it "should resolve blank values to nil" do
    lang = Iso639::Language.new "", "", "", "", ""
    assert_nil lang.alpha3_bibliographic
    assert_nil lang.alpha3_terminology
    assert_nil lang.alpha2
    assert_nil lang.english_name
    assert_nil lang.french_name
  end

  it "should not be mutable" do
    lang = Iso639::Language.new("eng", nil, "en", "English", "anglais").freeze
    begin
      lang.name = "British English"
      lang.alpha2 = "br"
      assert false
    rescue NoMethodError
      assert true
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
iso639-1.0.2 test/language_test.rb
iso639-1.0.1 test/language_test.rb
iso639-1.0.0 test/language_test.rb