require "spec_helper" require "nokogiri" RSpec.describe IsoDoc do it "processes IsoXML metadata" do c = IsoDoc::Convert.new({}) arr = c.convert_init(<<~"INPUT", "test", false) INPUT expect(Hash[c.info(Nokogiri::XML(<<~"INPUT"), nil).sort]).to be_equivalent_to <<~"OUTPUT" <title-intro language="en" format="text/plain">Cereals and pulses</title-intro> <title-main language="en" format="text/plain">Specifications and test methods</title-main> <title-part language="en" format="text/plain">Rice</title-part> <title-intro language="fr" format="text/plain">Céréales et légumineuses</title-intro> <title-main language="fr" format="text/plain">Spécification et méthodes d'essai</title-main> <title-part language="fr" format="text/plain">Riz</title-part> 17301 17301 2011 2012 20102011 2013 2014 ISO ISO en 30 92 3 2016 ISO Food products Cereals and pulses Rice Group GB 2 2016-05-01 0.4 INPUT {:accesseddate=>"2012", :activateddate=>"2013", :agency=>"ISO", :confirmeddate=>"XXX", :createddate=>"2010–2011", :docnumber=>"PreCD3 17301-1", :docsubtitle=>"Céréales et légumineuses — Spécification et méthodes d'essai — Partie 1: Riz", :docsubtitleintro=>"C\u00E9r\u00E9ales et l\u00E9gumineuses", :docsubtitlemain=>"Sp\u00E9cification et m\u00E9thodes d'essai", :docsubtitlepart=>"Partie 1: Riz", :doctitle=>"Cereals and pulses — Specifications and test methods — Part 1: Rice", :doctitleintro=>"Cereals and pulses", :doctitlemain=>"Specifications and test methods", :doctitlepart=>"Part 1: Rice", :doctype=>"International Standard", :docyear=>"2016", :draft=>"0.4", :draftinfo=>" (draft 0.4, 2016-05-01)", :editorialgroup=>["TC 34", "SC 4", "WG 3"], :implementeddate=>"XXX", :issueddate=>"XXX", :obsoleteddate=>"2014", :obsoletes=>nil, :obsoletes_part=>nil, :publisheddate=>"2011", :revdate=>"2016-05-01", :sc=>"SC 4", :secretariat=>"GB", :stage=>"30", :stageabbr=>"PreCD3", :tc=>"TC 34", :updateddate=>"XXX", :wg=>"WG 3"} OUTPUT end it "processes IsoXML metadata" do c = IsoDoc::Convert.new({}) arr = c.convert_init(<<~"INPUT", "test", false) INPUT expect(Hash[c.info(Nokogiri::XML(<<~"INPUT"), nil).sort]).to be_equivalent_to <<~"OUTPUT" <title-intro language="en" format="text/plain">Cereals and pulses</title-intro> <title-main language="en" format="text/plain">Specifications and test methods</title-main> <title-part language="en" format="text/plain">Rice</title-part> <title-intro language="fr" format="text/plain">Céréales et légumineuses</title-intro> <title-main language="fr" format="text/plain">Spécification et méthodes d'essai</title-main> <title-part language="fr" format="text/plain">Riz</title-part> 17301 17301 ISO ISO IEC en 30 92 2016 International Organization for Standardization 3.1 IEC 8121 Food products Cereals and pulses Rice Group 2 2016-05-01 12 INPUT {:accesseddate=>"XXX", :agency=>"ISO/IEC", :confirmeddate=>"XXX", :createddate=>"XXX", :docnumber=>"CD 17301-1-3", :docsubtitle=>"Céréales et légumineuses — Spécification et méthodes d'essai — Partie 1–3: Riz", :docsubtitleintro=>"C\u00E9r\u00E9ales et l\u00E9gumineuses", :docsubtitlemain=>"Sp\u00E9cification et m\u00E9thodes d'essai", :docsubtitlepart=>"Partie 1–3: Riz", :doctitle=>"Cereals and pulses — Specifications and test methods — Part 1–3: Rice", :doctitleintro=>"Cereals and pulses", :doctitlemain=>"Specifications and test methods", :doctitlepart=>"Part 1–3: Rice", :doctype=>"International Standard", :docyear=>"2016", :draft=>"12", :draftinfo=>" (draft 12, 2016-05-01)", :editorialgroup=>["ABC 34", "DEF 4", "GHI 3"], :implementeddate=>"XXX", :issueddate=>"XXX", :obsoleteddate=>"XXX", :obsoletes=>"IEC 8121", :obsoletes_part=>"3.1", :publisheddate=>"XXX", :revdate=>"2016-05-01", :sc=>"DEF 4", :secretariat=>"XXXX", :stage=>"30", :stageabbr=>"CD", :tc=>"ABC 34", :updateddate=>"XXX", :wg=>"GHI 3"} OUTPUT end end