Sha256: ec478a3fa0fdf7cf204d2a540015de1b705cb2b264fcfe25a6bf5e916fed4bfb

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

# coding: utf-8

require File.dirname(__FILE__) + '/spec_helper.rb'

context "ONIX::Normaliser", "with a simple short tag file" do

  before(:each) do
    @data_path = File.join(File.dirname(__FILE__),"..","data")
    @filename  = File.join(@data_path, "short_tags.xml")
    @outfile   = @filename + ".new"
  end

  after(:each) do
    File.unlink(@outfile) if File.file?(@outfile)
  end

  specify "should correctly convert short tag file to reference tag" do
    ONIX::Normaliser.process(@filename, @outfile)

    File.file?(@outfile).should be_true
    content = File.read(@outfile)
    content.include?("<m174>").should be_false
    content.include?("<FromCompany>").should be_true
  end

end

context "ONIX::Normaliser", "with a utf8 file that has illegal control chars" do

  before(:each) do
    @data_path = File.join(File.dirname(__FILE__),"..","data")
    @filename  = File.join(@data_path, "control_chars.xml")
    @outfile   = @filename + ".new"
  end

  after(:each) do
    File.unlink(@outfile) if File.file?(@outfile)
  end

  specify "should remove all control chars except LF, CR and TAB" do
    ONIX::Normaliser.process(@filename, @outfile)

    File.file?(@outfile).should be_true
    content = File.read(@outfile)

    content.include?("<TitleText>OXFORDPICTURE DICTIONARY CHINESE</TitleText>").should be_true
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
onix-0.8.4 spec/normaliser_spec.rb
milkfarm-onix-0.8.6 spec/normaliser_spec.rb
milkfarm-onix-0.8.5 spec/normaliser_spec.rb
onix-0.8.3 spec/normaliser_spec.rb
milkfarm-onix-0.8.3 spec/normaliser_spec.rb
onix-0.8.2 spec/normaliser_spec.rb
onix-0.8.1 spec/normaliser_spec.rb