-
Notifications
You must be signed in to change notification settings - Fork 78
/
capability_list_writer_spec.rb
26 lines (20 loc) · 1.1 KB
/
capability_list_writer_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'spec_helper'
RSpec.describe Sufia::ResourceSync::CapabilityListWriter do
let(:sitemap) { 'http://www.sitemaps.org/schemas/sitemap/0.9' }
let(:rs) { 'http://www.openarchives.org/rs/terms/' }
let(:resource_list) { 'http://example.com/resourcelist.xml' }
let(:description) { 'http://example.com/resourcesync_description.xml' }
subject { described_class.new(resource_list_url: resource_list,
description_url: description).write }
let(:xml) { Nokogiri::XML.parse(subject) }
it "has url to the capability list" do
description_href = xml.xpath('/x:urlset/rs:ln[@rel="up"]/@href', 'x' => sitemap, 'rs' => rs).map(&:value)
expect(description_href).to eq [description]
capability = xml.xpath('/x:urlset/rs:md/@capability', 'x' => sitemap, 'rs' => rs).map(&:value)
expect(capability).to eq ["capabilitylist"]
url = xml.xpath('//x:url[1]/x:loc', 'x' => sitemap).text
expect(url).to eq resource_list
capability = xml.xpath('//x:url[1]/rs:md/@capability', 'x' => sitemap, 'rs' => rs).map(&:value)
expect(capability).to eq ["resourcelist"]
end
end