-
Notifications
You must be signed in to change notification settings - Fork 78
/
resource_sync_controller_spec.rb
52 lines (45 loc) · 1.96 KB
/
resource_sync_controller_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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
RSpec.describe Sufia::ResourceSyncController do
before do
Rails.cache.clear
end
describe "source_description" do
let(:writer) { double }
let(:document) { '<xml>' }
let(:capability_list) { Sufia::Engine.routes.url_helpers.capability_list_url(host: 'test.host') }
it "is successful" do
allow(Sufia::ResourceSync::SourceDescriptionWriter).to receive(:new).with(capability_list_url: capability_list).and_return(writer)
expect(writer).to receive(:write).and_return(document)
get :source_description
expect(response.content_type).to eq 'application/xml'
expect(response.body).to eq document
end
end
describe "capability_list" do
let(:writer) { double }
let(:document) { '<xml>' }
let(:capability_list) { Sufia::Engine.routes.url_helpers.capability_list_url(host: 'test.host') }
it "is successful" do
allow(Sufia::ResourceSync::CapabilityListWriter).to receive(:new).with(resource_list_url: "http://test.host/resourcelist",
description_url: "http://test.host/.well-known/resourcesync").and_return(writer)
expect(writer).to receive(:write).and_return(document)
get :capability_list
expect(response.content_type).to eq 'application/xml'
expect(response.body).to eq document
end
end
describe "resource_list" do
before do
Rails.cache.clear
end
let(:writer) { double }
let(:document) { '<xml>' }
let(:capability_list) { Sufia::Engine.routes.url_helpers.capability_list_url(host: 'test.host') }
it "is successful" do
allow(Sufia::ResourceSync::ResourceListWriter).to receive(:new).with(capability_list_url: capability_list, resource_host: "test.host").and_return(writer)
expect(writer).to receive(:write).and_return(document)
get :resource_list
expect(response.content_type).to eq 'application/xml'
expect(response.body).to eq document
end
end
end