diff --git a/lib/vagrant-lxc/container.rb b/lib/vagrant-lxc/container.rb index a97ea8a..9f14cc4 100644 --- a/lib/vagrant-lxc/container.rb +++ b/lib/vagrant-lxc/container.rb @@ -28,6 +28,7 @@ module Vagrant def start lxc :start, '-d', '--name', @machine.id + wait_until :running end def halt diff --git a/spec/unit/container_spec.rb b/spec/unit/container_spec.rb index 8a99eff..e1daaee 100644 --- a/spec/unit/container_spec.rb +++ b/spec/unit/container_spec.rb @@ -15,7 +15,7 @@ describe Vagrant::LXC::Container do subject.lxc :command, '--state', 'RUNNING' end - it 'prepends sudo for execution' do + it 'prepends sudo' do args[0].should == 'sudo' end @@ -73,22 +73,20 @@ describe Vagrant::LXC::Container do end describe 'start' do - let(:last_command) { @last_command } - let(:machine_id) { 'random-machine-id' } - let(:machine) { fire_double('Vagrant::Machine', id: machine_id) } + let(:machine_id) { 'random-machine-id' } + let(:machine) { fire_double('Vagrant::Machine', id: machine_id) } before do - subject.stub(:lxc) do |*cmds| - @last_command = cmds.join(' ') - mock(exit_code: 0, stdout: '') - end + subject.stub(lxc: true, wait_until: true) subject.start end it 'calls lxc-start with the right arguments' do - last_command.should =~ /^start/ - last_command.should include "--name #{machine_id}" - last_command.should include '-d' + subject.should have_received(:lxc).with(:start, '-d', '--name', machine.id) + end + + it 'waits for container state to be RUNNING' do + subject.should have_received(:wait_until).with(:running) end end end