-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathtc_instance_provider.rb
41 lines (33 loc) · 1.59 KB
/
tc_instance_provider.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
require 'test_helper_provider'
class TestInstanceProvider < Test::Unit::TestCase
# Prior to the commit introducing this code, the InstanceProvider#identify
# method would instantiate a Response::Identify object, passing the
# InstanceProvider class as the provider for the Response::Identify
# instance. With the commit introducing this test, the
# InstanceProvider#identify now passes the instance of InstanceProvider
# to the instantiation of Response::Identify.
#
# Thus we can override, on an instance by instance basis, the behavior of a
# response object.
def test_instance_used_in_responses
@url_path = "/stringy-mc-string-face"
@instance_provider = InstanceProvider.new({ :provider_context => :instance_based, :url_path => @url_path })
xml = @instance_provider.identify
doc = REXML::Document.new(xml)
assert_equal "http://localhost#{@url_path}", doc.elements["OAI-PMH/Identify/baseURL"].text
end
def test_class_used_in_responses
@url_path = "/stringy-mc-string-face"
@instance_provider = InstanceProvider.new({ :provider_context => :class_based, :url_path => @url_path })
xml = @instance_provider.identify
doc = REXML::Document.new(xml)
assert_equal "http://localhost", doc.elements["OAI-PMH/Identify/baseURL"].text
end
def test_by_default_class_used_in_responses
@url_path = "/stringy-mc-string-face"
@instance_provider = InstanceProvider.new({ :url_path => @url_path })
xml = @instance_provider.identify
doc = REXML::Document.new(xml)
assert_equal "http://localhost", doc.elements["OAI-PMH/Identify/baseURL"].text
end
end