summaryrefslogtreecommitdiff
path: root/spec/unit/plugins/linux/hostname_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/plugins/linux/hostname_spec.rb')
-rw-r--r--spec/unit/plugins/linux/hostname_spec.rb19
1 files changed, 10 insertions, 9 deletions
diff --git a/spec/unit/plugins/linux/hostname_spec.rb b/spec/unit/plugins/linux/hostname_spec.rb
index 0fe198ca..e3deeb26 100644
--- a/spec/unit/plugins/linux/hostname_spec.rb
+++ b/spec/unit/plugins/linux/hostname_spec.rb
@@ -19,12 +19,13 @@
require "spec_helper"
describe Ohai::System, "Linux hostname plugin" do
+ let(:plugin) { get_plugin("hostname") }
+
before do
- @plugin = get_plugin("hostname")
- allow(@plugin).to receive(:collect_os).and_return(:linux)
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
- allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", ""))
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
+ allow(plugin).to receive(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", ""))
+ allow(plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
end
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
@@ -35,16 +36,16 @@ describe Ohai::System, "Linux hostname plugin" do
describe "when domain name is unset" do
before do
- expect(@plugin).to receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
+ expect(plugin).to receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
end
it "does not raise an error" do
- expect { @plugin.run }.not_to raise_error
+ expect { plugin.run }.not_to raise_error
end
it "does not set fqdn" do
- @plugin.run
- expect(@plugin.fqdn).to eq(nil)
+ plugin.run
+ expect(plugin.fqdn).to eq(nil)
end
end