Sha256: df0a018588bd0f7695baa9d582bfaf70e5bbd40c477389ab714ea1ec825903e4

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

require 'spec_helper'

require 'vagrant-notify/action/stop_server'

describe Vagrant::Notify::Action::StopServer do
  let(:app)          { lambda { |env| } }
  let(:config)       { double(notify: double(enable: true)) }
  let(:communicator) { double(sudo: true) }
  let(:ui)           { double(success: true) }
  let(:machine)      { double(communicate: communicator, state: double(id: :running), ui: ui, config: config) }
  let(:env)          { {notify_data: {pid: pid, port: 1234}, machine: machine} }
  let(:pid)          { '42' }
  let(:port)         { described_class::PORT }

  subject { described_class.new(app, env) }

  before do
    Process.stub(kill: true)
    subject.call(env)
  end

  it 'kills the notification server' do
    Process.should have_received(:kill).with('KILL', pid.to_i).at_most(2).times
  end

  it "removes server PID from notify data" do
    env[:notify_data][:pid].should be_nil
  end

  it "removes server port from notify data" do
    env[:notify_data][:port].should be_nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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