Sha256: c705f4b5febc5d7c66539ce797e491a2952bf7f5c7648d9bf2ad46c33e2ec14c

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

require 'spec_helper'

require 'vagrant-notify/action/server_is_running'

describe Vagrant::Notify::Action::ServerIsRunning do
  let(:app) { lambda { |env| } }
  let(:env) { {notify_data: {pid: pid, bind_ip: "127.0.0.1"}} }

  subject { described_class.new(app, env) }

  context 'when pid is not set' do
    let(:pid) { nil }

    it 'sets the result to false' do
      env[:result].should be_falsey
    end
  end

  context 'when pid is set' do
    let(:pid) { '12345' }

    context 'and is valid' do
      before do
        Process.stub(:getpgid => true)
        subject.call(env)
      end

      it 'sets the result to true' do
        env[:result].should be_truthy
      end
    end

    context 'and is invalid' do
      before do
        Process.stub(:getpgid).and_raise(Errno::ESRCH)
        subject.call(env)
      end

      it 'sets the result to false' do
        env[:result].should be_falsey
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-notify-0.6.1 spec/action/server_is_running_spec.rb