summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2013-12-04 14:52:42 -0800
committerBryan McLellan <btm@loftninjas.org>2013-12-04 14:52:42 -0800
commita8237fb700760fbebd7e6212b6cd3ec7d016817a (patch)
treef741c7b2e40bda3ea131130e07ae05cc5ddea7c3
parent9ff75eb3acc1c19e73e5cca6cfa962dafd7398e5 (diff)
parente5434f52f7ba9a91491ccedec8165e494de2aa4f (diff)
downloadohai-a8237fb700760fbebd7e6212b6cd3ec7d016817a.tar.gz
Merge pull request #235 from opscode/OHAI-537
OHAI-537: Require the os plugin in the hostname plugin
-rw-r--r--lib/ohai/plugins/hostname.rb3
-rw-r--r--spec/unit/plugins/hostname_spec.rb12
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/ohai/plugins/hostname.rb b/lib/ohai/plugins/hostname.rb
index 119e3c29..34c9a155 100644
--- a/lib/ohai/plugins/hostname.rb
+++ b/lib/ohai/plugins/hostname.rb
@@ -18,10 +18,11 @@
provides "fqdn", "domain"
+require_plugin "os"
require_plugin "#{os}::hostname"
# Domain is everything after the first dot
if fqdn
fqdn =~ /.+?\.(.*)/
domain $1
-end \ No newline at end of file
+end
diff --git a/spec/unit/plugins/hostname_spec.rb b/spec/unit/plugins/hostname_spec.rb
index 1ac8dc53..fb427535 100644
--- a/spec/unit/plugins/hostname_spec.rb
+++ b/spec/unit/plugins/hostname_spec.rb
@@ -35,5 +35,15 @@ describe Ohai::System, "hostname plugin" do
@ohai._require_plugin("hostname")
@ohai.domain.should == nil
end
-
+
+ it "should require the os plugin" do
+ @ohai.should_receive(:require_plugin).with("os").and_return(true)
+ @ohai._require_plugin("hostname")
+ end
+
+ it "should load a platform specific hostname plugin" do
+ @ohai[:os] = "linux"
+ @ohai.should_receive(:require_plugin).with("linux::hostname").and_return(true)
+ @ohai._require_plugin("hostname")
+ end
end