spec/middleware/stop_server_spec.rb in vagrant-notify-0.0.1 vs spec/middleware/stop_server_spec.rb in vagrant-notify-0.1.0
- old
+ new
@@ -1,9 +1,11 @@
describe Vagrant::Notify::Middleware::StopServer do
- let(:halt_stack) { Vagrant.actions[:halt].send(:stack) }
- let(:server_pid) { '1234' }
- let(:local_data) { { 'vagrant-notify' => { 'pid' => server_pid } } }
+ let(:halt_stack) { Vagrant.actions[:halt].send(:stack) }
+ let(:suspend_stack) { Vagrant.actions[:halt].send(:stack) }
+ let(:server_pid) { '1234' }
+ let(:uuid) { @env[:vm].uuid.to_s }
+ let(:local_data) { { 'vagrant-notify' => { uuid => { 'pid' => server_pid } } } }
subject { described_class.new(@app, @env) }
before do
@app, @env = action_env(vagrant_env.vms.values.first.env)
@@ -13,10 +15,14 @@
it 'gets called when halting machine' do
halt_stack.should include([described_class, [], nil])
end
+ it 'gets called when suspending machine' do
+ suspend_stack.should include([described_class, [], nil])
+ end
+
context 'server is down' do
before { Process.stub(:getpgid).and_raise(Errno::ESRCH) }
it 'does not notify user about server stop' do
@env[:ui].should_not_receive(:info)
@@ -25,10 +31,10 @@
end
context 'server is up' do
before do
Process.stub(:getpgid => true)
- local_data['vagrant-notify'] = { 'pid' => server_pid }
+ local_data['vagrant-notify'] = { uuid => { 'pid' => server_pid } }
end
it 'notifies user that server is stopping' do
@env[:ui].should_receive(:info).with('Stopping notification server...')
subject.call(@env)