mirror of https://github.com/Calamitous/iris.git
Fix handling of single-word hostname
This commit is contained in:
parent
03dfd561b4
commit
75b01ba2a1
5
iris.rb
5
iris.rb
|
@ -37,9 +37,10 @@ class Config
|
||||||
hostname = `hostname`.chomp
|
hostname = `hostname`.chomp
|
||||||
hostname = 'localhost' if hostname.empty?
|
hostname = 'localhost' if hostname.empty?
|
||||||
|
|
||||||
return @hostname = hostname if hostname == 'localhost'
|
components = hostname.split('.')
|
||||||
|
return @hostname = hostname if components.length == 1
|
||||||
|
|
||||||
@hostname = hostname.split('.')[-2..-1].compact.join('.')
|
@hostname = components[-2..-1].compact.join('.')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.author
|
def self.author
|
||||||
|
|
|
@ -44,6 +44,12 @@ describe Config do
|
||||||
_(Config.hostname).must_equal 'localhost'
|
_(Config.hostname).must_equal 'localhost'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'correctly interprets a single word' do
|
||||||
|
Config.instance_variable_set(:@hostname, nil)
|
||||||
|
Config.expects(:`).with('hostname').returns('example')
|
||||||
|
_(Config.hostname).must_equal 'example'
|
||||||
|
end
|
||||||
|
|
||||||
it 'correctly interprets a subdomain' do
|
it 'correctly interprets a subdomain' do
|
||||||
Config.instance_variable_set(:@hostname, nil)
|
Config.instance_variable_set(:@hostname, nil)
|
||||||
Config.expects(:`).with('hostname').returns('example.com')
|
Config.expects(:`).with('hostname').returns('example.com')
|
||||||
|
|
Loading…
Reference in New Issue