def test_document_setup
@properties['documents'] = [
{ 'document' => 'Page',
'arguments' => [
"Hello world.\n",
'text/html'
],
'mount_path' => '/hello',
'mount_mask' => nil,
'virtual_host' => nil
},
{ 'document' => 'LocalFile',
'arguments' => [
'/home/alice/public_html'
],
'mount_path' => '/~alice',
'mount_mask' => nil,
'virtual_host' => 'foo'
}
]
page = Object.new
class << page
include RUNIT::Assert
def doc_name
'Page'
end
def doc_args
[ [ 'content', :text, nil ],
[ 'content-type', :string, 'text/html' ]
]
end
def new(content, content_type)
assert_equal("Hello world.\n", content)
assert_equal('text/html', content_type)
:dummy_page_document
end
end
@factory.add_document(page)
local = Object.new
class << local
include RUNIT::Assert
def doc_name
'LocalFile'
end
def doc_args
[ [ 'local path', :string, nil ] ]
end
def new(local_path)
assert_equal('/home/alice/public_html', local_path)
:dummy_local_document
end
end
@factory.add_document(local)
build_control
@control.server_setup(self)
assert_equal(2, @mount_call)
assert_equal(1, @virtual_mount_call)
assert_equal(:dummy_page_document, @folder.find('/hello')[0])
assert_equal('/hello', @folder.find('/hello')[1])
assert_equal(:dummy_local_document, @folder.virtual_find('foo:8888', '/~alice')[0])
assert_equal('/~alice', @folder.virtual_find('foo:8888', '/~alice')[1])
end