Sha256: 711ed3869cac127bb5a45b535b154495da319b5620387d9599aef8997353d4c5

Contents?: true

Size: 1.24 KB

Versions: 24

Compression:

Stored size: 1.24 KB

Contents

require 'epitools'

describe Sys::ProcessInfo do

  specify "OS type" do
    proc { Sys.os }.should_not raise_error
    proc { Sys.linux? }.should_not raise_error
    proc { Sys.mac? }.should_not raise_error
    proc { Sys.darwin? }.should_not raise_error
    proc { Sys.bsd? }.should_not raise_error
    proc { Sys.windows? }.should_not raise_error

    %w[Linux Windows Darwin BSD].include?(Sys.os).should == true

    [:linux?, :mac?, :windows?, :bsd?].any? { |os| Sys.send(os) }.should == true
  end


  specify "list all processes" do
    # Sys.ps.should_not be_blank
    procs = Sys.ps

    procs.first.state.is_a?(Array).should == true

    pids = procs.map{ |process| process.pid }

    p2s = Hash[ *Sys.ps(*pids).map { |process| [process.pid, process] }.flatten ]
    matches = 0
    procs.each do |p1|
      if p2 = p2s[p1.pid]
        matches += 1
        p1.command.should == p2.command
      end
    end

    matches.should > 1
  end

  specify "cross-platform methods" do
    Sys.cross_platform_method(:cross_platform_test)
    proc { Sys.cross_platform_test }.should raise_error(NotImplementedError)
  end

  specify "network interfaces" do
    Sys.interfaces.should_not be_blank
  end

  specify "mounts" do
    Sys.mounts.should_not be_blank
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
epitools-0.5.110 spec/sys_spec.rb
epitools-0.5.109 spec/sys_spec.rb
epitools-0.5.108 spec/sys_spec.rb
epitools-0.5.107 spec/sys_spec.rb