Sha256: 3e3852b070ce7d6465cd4656507959196b7d1e537774e95b6bf39cf16625fd89

Contents?: true

Size: 961 Bytes

Versions: 1

Compression:

Stored size: 961 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

describe ArchivesSpace::Template do
  it "can list the default templates" do
    templates = ArchivesSpace::Template.list
    expect(templates).to_not be_empty
    expect(templates).to include(/repository_with_agent.*erb/)
  end

  it "can change the path when template envvar is set" do
    expect(ArchivesSpace::Template.templates_path).to match(
      /#{File.join('lib', 'archivesspace', 'client', 'templates')}/
    )
    ENV["ARCHIVESSPACE_CLIENT_TEMPLATES_PATH"] = "/path/to/nowhere"
    expect(ArchivesSpace::Template.templates_path).to eq "/path/to/nowhere"
    ENV.delete("ARCHIVESSPACE_CLIENT_TEMPLATES_PATH")
  end

  it "can process a template" do
    data = {repo_code: "ABC", name: "ABC Archive", agent_contact_name: "ABC Admin"}
    json = JSON.parse(ArchivesSpace::Template.process(:repository_with_agent, data))
    expect(json["repository"]["repo_code"]).to eq data[:repo_code]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archivesspace-client-0.2.0 spec/archivesspace/templates_spec.rb