spec/web/server_spec.rb in ronin-web-0.1.2 vs spec/web/server_spec.rb in ronin-web-0.1.3
- old
+ new
@@ -3,47 +3,47 @@
require 'spec_helper'
require 'web/helpers/server'
describe Web::Server do
before(:all) do
- @server = Web::Server.new do
- default do |env|
- response('This is default.')
+ @server = Web::Server.new do |server|
+ server.default do |env|
+ server.response('This is default.')
end
- bind('/test/bind.xml') do |env|
- response('<secret/>', :content_type => 'text/xml')
+ server.bind('/test/bind.xml') do |env|
+ server.response('<secret/>', :content_type => 'text/xml')
end
- paths_like(/path_patterns\/secret\./) do |env|
- response('No secrets here.')
+ server.paths_like(/path_patterns\/secret\./) do |env|
+ server.response('No secrets here.')
end
- map('/test/map') do |env|
- response('mapped')
+ server.map('/test/map') do |env|
+ server.response('mapped')
end
- file('/test/file.txt',File.join(WEB_SERVER_ROOT,'test.txt'))
+ server.file('/test/file.txt',File.join(WEB_SERVER_ROOT,'test.txt'))
- directory('/test/directory/',WEB_SERVER_ROOT)
+ server.directory('/test/directory/',WEB_SERVER_ROOT)
end
- @virtual_host = Web::Server.new do
- bind('/test/virtual_host.xml') do |env|
- response('<virtual/>', :content_type => 'text/xml')
+ @vhost = Web::Server.new do |vhost|
+ vhost.bind('/test/virtual_host.xml') do |env|
+ vhost.response('<virtual/>', :content_type => 'text/xml')
end
end
- @server.host('virtual.host.com') do
- bind('/test/virtual_host.xml') do |env|
- response('<virtual/>', :content_type => 'text/xml')
+ @server.host('virtual.host.com') do |vhost|
+ vhost.bind('/test/virtual_host.xml') do |env|
+ vhost.response('<virtual/>', :content_type => 'text/xml')
end
end
- @server.hosts_like(/^virtual[0-9]\./) do
- bind('/test/virtual_host_patterns.xml') do |env|
- response('<virtual-patterns/>', :content_type => 'text/xml')
+ @server.hosts_like(/^virtual[0-9]\./) do |vhost|
+ vhost.bind('/test/virtual_host_patterns.xml') do |env|
+ vhost.response('<virtual-patterns/>', :content_type => 'text/xml')
end
end
end
it "should have a default host to listen on" do
@@ -125,17 +125,17 @@
get_url(@server,url).body.should == ['<virtual-patterns/>']
end
it "should provide access to servers via their host-names" do
- virtual_host = @server.virtual_host('virtual.host.com')
+ virtual_host = @server.vhost('virtual.host.com')
url = 'http://virtual.host.com/test/virtual_host.xml'
get_url(virtual_host,url).body.should == ['<virtual/>']
end
it "should provide access to servers via their host-names that match virtual host patterns" do
- virtual_host = @server.virtual_host('virtual1.host.com')
+ virtual_host = @server.vhost('virtual1.host.com')
url = 'http://virtual0.host.com/test/virtual_host_patterns.xml'
get_url(virtual_host,url).body.should == ['<virtual-patterns/>']
end
end