vagrant/test/unit/plugins/guests/bsd/cap/halt_test.rb

37 lines
801 B
Ruby
Raw Normal View History

require_relative "../../../../base"
describe "VagrantPlugins::GuestBSD::Cap::Halt" do
let(:caps) do
VagrantPlugins::GuestBSD::Plugin
.components
.guest_capabilities[:bsd]
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
2016-06-23 01:35:19 +00:00
comm.expect_command("/sbin/shutdown -p now")
cap.halt(machine)
end
it "ignores an IOError" do
2016-06-23 01:35:19 +00:00
comm.stub_command("/sbin/shutdown -p now", raise: IOError)
expect {
cap.halt(machine)
}.to_not raise_error
end
end
end