spec/unit/plugins/hostname_spec.rb in ohai-7.0.0.rc.0 vs spec/unit/plugins/hostname_spec.rb in ohai-7.0.0.rc.1

- old
+ new

@@ -69,6 +69,36 @@ it "should set the [short] hostname to everything before the first dot of the fqdn" do @plugin.run @plugin[:hostname].should == "katie" end end + + context "hostname --fqdn when it returns empty string" do + before(:each) do + @plugin.stub(:collect_os).and_return(:linux) + @plugin.stub(:shell_out).with("hostname -s").and_return( + mock_shell_out(0, "katie", "")) + @plugin.stub(:shell_out).with("hostname --fqdn").and_return( + mock_shell_out(0, "", ""), mock_shell_out(0, "katie.local", "")) + end + + it "should be called twice" do + @plugin.run + @plugin[:fqdn].should == "katie.local" + end + end + + context "hostname --fqdn when it works" do + before(:each) do + @plugin.stub(:collect_os).and_return(:linux) + @plugin.stub(:shell_out).with("hostname -s").and_return( + mock_shell_out(0, "katie", "")) + @plugin.stub(:shell_out).with("hostname --fqdn").and_return( + mock_shell_out(0, "katie.local", "")) + end + + it "should be not be called twice" do + @plugin.run + @plugin[:fqdn].should == "katie.local" + end + end end