Sha256: c03c90de8b1fef5b8109e2b67d5c5a2f93862c3244a69d3be075ad4169cb0955

Contents?: true

Size: 1.88 KB

Versions: 7

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

module Stash
  module Sword
    describe DepositReceipt do
      describe '#parse_xml' do

        it 'parses the response from the spec' do
          xml = File.read('spec/data/deposit_receipt_spec.xml')
          receipt = DepositReceipt.parse_xml(xml)
          expect(receipt).to be_a(DepositReceipt)

          em_iri = receipt.link(rel: 'edit-media')
          expect(em_iri.href).to eq(URI('http://www.swordserver.ac.uk/col1/mydeposit'))

          se_iri = receipt.link(rel: URI('http://purl.org/net/sword/terms/add'))
          expect(se_iri.href).to eq(URI('http://www.swordserver.ac.uk/col1/mydeposit.atom'))

          edit_iri = receipt.link(rel: 'edit')
          expect(edit_iri.href).to eq(URI('http://www.swordserver.ac.uk/col1/mydeposit.atom'))

          expect(receipt.em_iri).to eq(em_iri.href)
          expect(receipt.se_iri).to eq(se_iri.href)
          expect(receipt.edit_iri).to eq(edit_iri.href)
        end

        it 'parses a Merritt response' do
          xml = File.read('spec/data/deposit_receipt_merritt.xml')
          receipt = DepositReceipt.parse_xml(xml)
          expect(receipt).to be_a(DepositReceipt)

          em_iri = receipt.link(rel: 'edit-media')
          expect(em_iri.href).to eq(URI('http://merritt-dev.cdlib.org/d/ark%3A%2F99999%2Ffk47h1tz4k'))

          se_iri = receipt.link(rel: URI('http://purl.org/net/sword/terms/add'))
          expect(se_iri.href).to eq(URI('http://sword-aws-dev.cdlib.org:39001/mrtsword/edit/dash_cdl/doi%3A10.5072%2FFK1465406644'))

          edit_iri = receipt.link(rel: 'edit')
          expect(edit_iri.href).to eq(URI('http://sword-aws-dev.cdlib.org:39001/mrtsword/edit/dash_cdl/doi%3A10.5072%2FFK1465406644'))

          expect(receipt.em_iri).to eq(em_iri.href)
          expect(receipt.se_iri).to eq(se_iri.href)
          expect(receipt.edit_iri).to eq(edit_iri.href)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stash-sword-0.1.6 spec/unit/stash/sword2/deposit_receipt_spec.rb
stash-sword-0.1.5 spec/unit/stash/sword2/deposit_receipt_spec.rb
stash-sword-0.1.4 spec/unit/stash/sword2/deposit_receipt_spec.rb
stash-sword-0.1.3 spec/unit/stash/sword2/deposit_receipt_spec.rb
stash-sword-0.1.2 spec/unit/stash/sword2/deposit_receipt_spec.rb
stash-sword-0.1.1 spec/unit/stash/sword2/deposit_receipt_spec.rb
stash-sword-0.1.0 spec/unit/stash/sword2/deposit_receipt_spec.rb