Sha256: 11a002e433d03fab73dacf9b3ddd9f7aff454faad521941db08d043b14f5aa9d

Contents?: true

Size: 960 Bytes

Versions: 9

Compression:

Stored size: 960 Bytes

Contents

require 'test_helper'
require 'stringio'

require 'traject/debug_writer'
require 'traject'
require 'marc'

describe 'Simple output' do
  before do
    @record = MARC::Reader.new(support_file_path  "manufacturing_consent.marc").to_a.first
    @indexer = Traject::Indexer.new
    @indexer.instance_eval do
      to_field "id", extract_marc("001", :first => true)
      to_field "title", extract_marc("245ab")
    end
    @io = StringIO.new
    @writer = Traject::DebugWriter.new("output_stream" => @io)
    
    @id = "2710183"
    @title = "Manufacturing consent : the political economy of the mass media /"
  end
  
  it "does a simple output" do
    @writer.put Traject::Indexer::Context.new(:output_hash => @indexer.map_record(@record))
    expected = [
      "#{@id} id #{@id}",
      "#{@id} title #{@title}",
      "\n"
    ]
    assert_equal expected.join("\n").gsub(/\s/, ''), @io.string.gsub(/\s/, '')
    @writer.close
    
  end
  
end
    
    
    

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
traject-0.16.0 test/debug_writer_test.rb
traject-0.15.0 test/debug_writer_test.rb
traject-0.14.1 test/debug_writer_test.rb
traject-0.13.2 test/debug_writer_test.rb
traject-0.13.1 test/debug_writer_test.rb
traject-0.13.0 test/debug_writer_test.rb
traject-0.12.0 test/debug_writer_test.rb
traject-0.11.0 test/debug_writer_test.rb
traject-0.10.0 test/debug_writer_test.rb