spec/beaker/hypervisor/vagrant_spec.rb in beaker-1.0.0 vs spec/beaker/hypervisor/vagrant_spec.rb in beaker-1.0.1.pre
- old
+ new
@@ -64,12 +64,16 @@
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/root/.vagrant.d/insecure_private_key
IdentitiesOnly yes")
+ wait_thr = OpenStruct.new
+ state = mock( 'state' )
+ state.stub( :success? ).and_return( true )
+ wait_thr.value = state
- Open3.stub( :popen3 ).with( 'vagrant', 'ssh-config', host.name ).and_return( [ "", out ])
+ Open3.stub( :popen3 ).with( 'vagrant', 'ssh-config', host.name ).and_return( [ "", out, "", wait_thr ])
file = double( 'file' )
file.stub( :path ).and_return( '/path/sshconfig' )
file.stub( :rewind ).and_return( true )
@@ -80,25 +84,44 @@
expect( host['ssh'] ).to be === { :config => file.path }
expect( host['user']).to be === 'root'
end
- it "can provision a set of hosts" do
+ describe "provisioning and cleanup" do
- vagrant.should_receive( :make_vfile ).with( @hosts ).once
+ before :each do
+ FakeFS.activate!
+ vagrant.should_receive( :vagrant_cmd ).with( "up" ).once
+ @hosts.each do |host|
+ host_prev_name = host['user']
+ vagrant.should_receive( :set_ssh_config ).with( host, 'vagrant' ).once
+ vagrant.should_receive( :copy_ssh_to_root ).with( host ).once
+ vagrant.should_receive( :set_ssh_config ).with( host, host_prev_name ).once
+ end
+ vagrant.should_receive( :hack_etc_hosts ).with( @hosts ).once
+ end
- vagrant.should_receive( :vagrant_cmd ).with( "halt" ).once
- vagrant.should_receive( :vagrant_cmd ).with( "up" ).once
- @hosts.each do |host|
- host_prev_name = host['user']
- vagrant.should_receive( :set_ssh_config ).with( host, 'vagrant' ).once
- vagrant.should_receive( :copy_ssh_to_root ).with( host ).once
- vagrant.should_receive( :set_ssh_config ).with( host, host_prev_name ).once
+ it "can provision a set of hosts" do
+ vagrant.should_receive( :make_vfile ).with( @hosts ).once
+ vagrant.should_receive( :vagrant_cmd ).with( "destroy --force" ).never
+ vagrant.provision
end
- vagrant.should_receive( :hack_etc_hosts ).with( @hosts ).once
+ it "destroys an existing set of hosts before provisioning" do
+ vagrant.make_vfile(@hosts)
+ vagrant.should_receive(:vagrant_cmd).with("destroy --force").once
+ vagrant.provision
+ end
- vagrant.provision
+ it "can cleanup" do
+ vagrant.should_receive( :vagrant_cmd ).with( "destroy --force" ).once
+ FileUtils.should_receive( :rm_rf ).once
+
+ vagrant.provision
+ vagrant.cleanup
+
+ end
+
end
end
end