0
0
Fork 0

generate a name from the server details

This commit is contained in:
Gibheer 2013-07-22 15:17:28 +02:00
parent 7fd2f6b25b
commit 94a2d399eb
2 changed files with 27 additions and 0 deletions

View File

@ -36,6 +36,13 @@ module Zero
# get the server software
# @return [String] the server software name
attr_reader :software
# returns the full name of the server
# @return [String] the full address to the server
def name
return @name if @name
@name = protocol + '://' + hostname + ':' + port.to_s
end
end
end
end

View File

@ -0,0 +1,20 @@
require 'spec_helper'
describe Zero::Request::Server, '#name' do
subject { Zero::Request::Server.new(env) }
let(:hostname) { 'FooName' }
let(:port) { '80' }
let(:protocol) { 'http' }
let(:result) { 'http://FooName:80' }
let(:env) { EnvGenerator.get('/foo', {
'SERVER_NAME' => hostname,
'SERVER_PROTOCOL' => protocol,
'SERVER_PORT' => port
}) }
it "generates a name" do
expect(subject.name).to match(result)
end
end