diff options
author | Theodore Nordsieck <theo@opscode.com> | 2013-09-10 09:06:43 -0700 |
---|---|---|
committer | Theodore Nordsieck <theo@opscode.com> | 2013-09-11 16:13:25 -0700 |
commit | 0c4d9e64532e3d00d4b771da1b1b68995c4970db (patch) | |
tree | dbcc32561d6f6a09a9d8671bad2caf11ec277e62 | |
parent | 4596a27431cee93a185ecb602792a1cb4e3ee28c (diff) | |
download | ohai-0c4d9e64532e3d00d4b771da1b1b68995c4970db.tar.gz |
Converted plugins/freebsd/hostname to Mixlib::ShellOut.
-rw-r--r-- | lib/ohai/plugins/freebsd/hostname.rb | 6 | ||||
-rw-r--r-- | spec/unit/plugins/freebsd/hostname_spec.rb | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/ohai/plugins/freebsd/hostname.rb b/lib/ohai/plugins/freebsd/hostname.rb index 53ca7c24..ba0a8bb7 100644 --- a/lib/ohai/plugins/freebsd/hostname.rb +++ b/lib/ohai/plugins/freebsd/hostname.rb @@ -20,7 +20,9 @@ Ohai.plugin do provides "hostname", "fqdn" collect_data do - hostname from("hostname -s") - fqdn from("hostname -f") + so = shell_out("hostname -s") + hostname so.stdout.split($/)[0] + so = shell_out("hostname -f") + fqdn so.stdout.split($/)[0] end end diff --git a/spec/unit/plugins/freebsd/hostname_spec.rb b/spec/unit/plugins/freebsd/hostname_spec.rb index b1afb212..19d4bd99 100644 --- a/spec/unit/plugins/freebsd/hostname_spec.rb +++ b/spec/unit/plugins/freebsd/hostname_spec.rb @@ -23,8 +23,8 @@ describe Ohai::System, "FreeBSD hostname plugin" do before(:each) do @plugin = get_plugin("freebsd/hostname") @plugin[:os] = "freebsd" - @plugin.stub(:from).with("hostname -s").and_return("katie") - @plugin.stub(:from).with("hostname -f").and_return("katie.bethell") + @plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", "")) + @plugin.stub(:shell_out).with("hostname -f").and_return(mock_shell_out(0, "katie.bethell", "")) end it_should_check_from("freebsd::hostname", "hostname", "hostname -s", "katie") |