summaryrefslogtreecommitdiff
path: root/spec/unit/plugins/darwin/hostname_spec.rb
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2021-04-09 10:18:43 -0700
committerTim Smith <tsmith84@gmail.com>2021-04-09 10:31:17 -0700
commit7ed583a40d4a6646f9f9c55f164060ad766ab5af (patch)
treeba610bbfeb363219469f3463929d8d11f8c0cbf1 /spec/unit/plugins/darwin/hostname_spec.rb
parent1dfbd15afb830f8aa8959ea9e79ed2648d3c2997 (diff)
downloadohai-macos_hostname.tar.gz
Use scutil to get hostname and computernamemacos_hostname
Fetch the hostname and computername in a more macOS way. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec/unit/plugins/darwin/hostname_spec.rb')
-rw-r--r--spec/unit/plugins/darwin/hostname_spec.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/spec/unit/plugins/darwin/hostname_spec.rb b/spec/unit/plugins/darwin/hostname_spec.rb
index 831781a3..e16c758a 100644
--- a/spec/unit/plugins/darwin/hostname_spec.rb
+++ b/spec/unit/plugins/darwin/hostname_spec.rb
@@ -22,14 +22,13 @@ describe Ohai::System, "Darwin hostname plugin" do
before do
@plugin = get_plugin("hostname")
allow(@plugin).to receive(:collect_os).and_return(:darwin)
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(@plugin).to receive(:shell_out).with("scutil --get HostName").and_return(mock_shell_out(0, "katie", ""))
+ allow(@plugin).to receive(:shell_out).with("scutil --get ComputerName").and_return(mock_shell_out(0, "katie.local", ""))
allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
end
- it_should_check_from("darwin::hostname", "hostname", "hostname -s", "katie")
-
- it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
+ it_should_check_from("darwin::hostname", "hostname", "scutil --get HostName", "katie")
+ it_should_check_from("darwin::hostname", "machinename", "scutil --get ComputerName", "katie.local")
it "uses #resolve_fqdn to find the fqdn" do
@plugin.run