Sha256: 9ab0fc4de0007db8d18ec2359d90318c96f76554bac4795de88532d549d09c0f
Contents?: true
Size: 881 Bytes
Versions: 15
Compression:
Stored size: 881 Bytes
Contents
require 'test_helper' describe "Indexer Macros#to_field" do before do @indexer = Traject::Indexer.new @record = MARC::Reader.new(support_file_path "manufacturing_consent.marc").to_a.first end it "works with simple literal" do @indexer.configure do extend Traject::Macros::Basic to_field "source", literal("MY LIBRARY") end output = @indexer.map_record(@record) assert_equal ["MY LIBRARY"], output["source"] end it "works with macro AND block" do called = false @indexer.configure do extend Traject::Macros::Basic to_field "source", literal("MY LIBRARY") do |record, accumulator, context| called = true accumulator << "SECOND VALUE" end end output = @indexer.map_record(@record) assert called assert_equal ["MY LIBRARY", "SECOND VALUE"], output["source"] end end
Version data entries
15 entries across 15 versions & 1 rubygems