Sha256: fc7a5a45394d061e2f7dec4d8bbef2c7c1b18a60f19896dc6f04d281ed18eed2

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe EventedBluepill::ProcessConditions::MemUsage do
  before do
    @condition = EventedBluepill::ProcessConditions::MemUsage.new 'name', stub(:actual_pid => 0), :below => 2048
  end

  describe "#run" do
    it "must return current memory usage in kilobytes" do
      EventedBluepill::System.expects(:memory_usage).with(0).returns(3)
      @condition.run.must_equal 3072
    end
  end

  describe "#check" do
    it "must be true if value is below threshold" do
      @condition.check(0).must_equal true
    end

    it "must be false if value is above threshold" do
      @condition.check(4096).must_equal false
    end

    it "must be false if value is threshold" do
      @condition.check(2048).must_equal false
    end
  end

  describe "#format_value" do
    it "must return value as kilobyte if below one megabyte" do
      @condition.format_value(768 * 1024).must_equal '768.0KB'
    end

    it "must return value as megabyte if above one megabyte" do
      @condition.format_value(2048 * 1024).must_equal '2.0MB'
    end

    it "must round value" do
      @condition.format_value(2800 * 1024).must_equal '2.7MB'
    end

    it "must return value as megabyte if value is one megabyte" do
      @condition.format_value(1024 * 1024).must_equal '1.0MB'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
evented_bluepill-0.0.52 spec/mem_usage_spec.rb
evented_bluepill-0.0.51 spec/mem_usage_spec.rb
evented_bluepill-0.0.50 spec/mem_usage_spec.rb