generate a name from the server details
This commit is contained in:
parent
7fd2f6b25b
commit
94a2d399eb
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue