From c98deee116d87c231512c36f31def60d1a35ab13 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 6 Jun 2016 10:45:28 -0400 Subject: [PATCH] guests/suse: Add tests for halt --- .../unit/plugins/guests/suse/cap/halt_test.rb | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/unit/plugins/guests/suse/cap/halt_test.rb diff --git a/test/unit/plugins/guests/suse/cap/halt_test.rb b/test/unit/plugins/guests/suse/cap/halt_test.rb new file mode 100644 index 000000000..acce6536d --- /dev/null +++ b/test/unit/plugins/guests/suse/cap/halt_test.rb @@ -0,0 +1,36 @@ +require_relative "../../../../base" + +describe "VagrantPlugins::GuestSUSE::Cap::Halt" do + let(:caps) do + VagrantPlugins::GuestSUSE::Plugin + .components + .guest_capabilities[:suse] + end + + let(:machine) { double("machine") } + let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } + + before do + allow(machine).to receive(:communicate).and_return(comm) + end + + after do + comm.verify_expectations! + end + + describe ".halt" do + let(:cap) { caps.get(:halt) } + + it "runs the shutdown command" do + comm.expect_command("/sbin/shutdown -h now") + cap.halt(machine) + end + + it "does not raise an IOError" do + comm.stub_command("shutdown -h now", raise: IOError) + expect { + cap.halt(machine) + }.to_not raise_error + end + end +end