Sha256: d3b728013d904c352bf17d8f40255009618fa4c4a12474855cea3e8ab86b0903

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

# -*- encoding : utf-8 -*-
require File.dirname(__FILE__) + '/spec_helper'

describe "Eye::SystemResources" do
    
  it "should get memory" do
    x = Eye::SystemResources.memory($$)
    x.should > 100
    x.should < 300_000
  end

  it "should get cpu" do
    x = Eye::SystemResources.cpu($$)
    x.should >= 0
    x.should < 100
  end

  it "should get start time" do
    x = Eye::SystemResources.start_time($$)
    x.length.should >= 5
  end

  it "should get childs" do
    x = Eye::SystemResources.childs($$)
    x.is_a?(Array).should == true
    x.first.should > 0
    x.size.should > 0
    x.all?{|c| c > 0 }.should == true
  end

  it "should get cmd" do
    Eye::Control.set_proc_line
    x = Eye::SystemResources.cmd($$)
    x.should match(/eye/)    
  end

  it "should cache and update when interval" do
    silence_warnings{ Eye::SystemResources::PsAxActor::UPDATE_INTERVAL = 2 }

    x1 = Eye::SystemResources.cmd($$)
    x2 = Eye::SystemResources.cmd($$)
    x1.should == x2

    sleep 1
    x3 = Eye::SystemResources.cmd($$)
    x1.should == x3

    # change the cmd
    $0 = "ruby rspec ..."

    sleep 1.5
    x4 = Eye::SystemResources.cmd($$)
    x1.should == x4 # first value is old

    x5 = Eye::SystemResources.cmd($$)
    x1.should_not == x5 # seconds is new
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eye-0.1.11 spec/system_resources_spec.rb