Sha256: 182f982ec94702788b6ad346ae40f55d4be4f66d2ed9a30dc2eded128f8cd4f1

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# coding: utf-8

$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')

require 'onix'

context "ONIX::Language" do

  before(:each) do
    data_path = File.join(File.dirname(__FILE__),"..","data")
    file1    = File.join(data_path, "language.xml")
    @doc = LibXML::XML::Document.file(file1)
    @root = @doc.root
  end

  specify "should correctly convert to a string" do
    lan = ONIX::Language.from_xml(@root.to_s)
    lan.to_xml.to_s[0,10].should eql("<Language>")
  end

  specify "should provide read access to first level attibutes" do
    lan = ONIX::Language.from_xml(@root.to_s)

    lan.language_role.should eql(1)
    lan.language_code.should eql("eng")
    lan.country_code.should eql("US")
  end

  specify "should provide write access to first level attibutes" do
    lan = ONIX::Language.new

    lan.language_role = 2
    lan.to_xml.to_s.include?("<LanguageRole>02</LanguageRole>").should be_true

    lan.language_code = "aar"
    lan.to_xml.to_s.include?("<LanguageCode>aar</LanguageCode>").should be_true

    lan.country_code = "AD"
    lan.to_xml.to_s.include?("<CountryCode>AD</CountryCode>").should be_true
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onix-0.7.8 spec/language_spec.rb