Sha256: 56563743569d44a14dbd740c08dff3f831c1629f319da1c3c51bb026fd09ac40

Contents?: true

Size: 1.26 KB

Versions: 15

Compression:

Stored size: 1.26 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Actions::ShowProcessInformation do
  context '#initialize' do
    it 'requires a pid or a pid file' do
      expect {
        Actions::ShowProcessInformation.new($$)
      }.not_to raise_error

      file = create_file 'pid_file', '1'

      expect {
        Actions::ShowProcessInformation.new(::File.new(file))
      }.not_to raise_error
    end
  end

  context '#run' do
    it 'gathers information about a running process' do
      result = capture(:stdout) do
        Actions::ShowProcessInformation.new($$).run
      end

      expect(result).to include('pid')
      expect(result).to include($$.to_s)
    end

    it 'reports an error if process cannot be found' do
      result = capture(:stdout) do
        Actions::ShowProcessInformation.new(99999999999).run
      end

      expect(result).to include('Process "99999999999" cannot be found. It is not a running process.')
    end

    it 'reports an error if process cannot be found and gives a hint if pid file was used.' do
      result = capture(:stdout) do
        Actions::ShowProcessInformation.new('/path/not/exist').run
      end

      expect(result).to include('Pid-file /path/not/exist cannot be found. Please choose a correct path and try again.')
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
local_pac-0.10.2 spec/actions/show_process_information_spec.rb
local_pac-0.10.1 spec/actions/show_process_information_spec.rb
local_pac-0.10.0 spec/actions/show_process_information_spec.rb
local_pac-0.9.0 spec/actions/show_process_information_spec.rb
local_pac-0.7.0 spec/actions/show_process_information_spec.rb
local_pac-0.6.3 spec/actions/show_process_information_spec.rb
local_pac-0.6.2 spec/actions/show_process_information_spec.rb
local_pac-0.6.1 spec/actions/show_process_information_spec.rb
local_pac-0.5.0 spec/actions/show_process_information_spec.rb
local_pac-0.4.0 spec/actions/show_process_information_spec.rb
local_pac-0.3.0 spec/actions/show_process_information_spec.rb
local_pac-0.2.3 spec/actions/show_process_information_spec.rb
local_pac-0.2.2 spec/actions/show_process_information_spec.rb
local_pac-0.2.1 spec/actions/show_process_information_spec.rb
local_pac-0.2.0 spec/actions/show_process_information_spec.rb