Sha256: e71043cde744ddf8cc97bbca3975295725df2c2ca126ff8a7ae3e52fa32b60db

Contents?: true

Size: 865 Bytes

Versions: 8

Compression:

Stored size: 865 Bytes

Contents

# Encoding: UTF-8

require 'test_helper'
require 'traject/marc_reader'
require 'marc'

describe "Traject::MarcReader" do


  it "reads XML" do
    file = File.new(support_file_path "test_data.utf8.marc.xml")
    settings = Traject::Indexer::Settings.new("marc_source.type" => "xml")
    reader = Traject::MarcReader.new(file, settings)

    array = reader.to_a

    assert_equal 30, array.length
  end

  it "reads Marc binary" do
    file = File.new(support_file_path "test_data.utf8.mrc")
    settings = Traject::Indexer::Settings.new() # binary type is default
    reader = Traject::MarcReader.new(file, settings)

    array = reader.to_a

    assert_equal 30, array.length

    first = array.first

    assert_kind_of MARC::Record, first

    assert first['245']['a'].encoding.name, "UTF-8"
    assert_equal "Fikr-i Ayāz /", first['245']['a']
  end

  



end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
traject-0.14.1 test/marc_reader_test.rb
traject-0.13.2 test/marc_reader_test.rb
traject-0.13.1 test/marc_reader_test.rb
traject-0.13.0 test/marc_reader_test.rb
traject-0.12.0 test/marc_reader_test.rb
traject-0.11.0 test/marc_reader_test.rb
traject-0.10.0 test/marc_reader_test.rb
traject-0.9.1 test/marc_reader_test.rb