Sha256: 257bdfc7b0b748949972437106235b2a0b51c8b559d95e29092f8b166804a6d8

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe LitmusPaper::Metric::AvailableMemory do
  run_in_reactor

  describe "#current_health" do
    it "multiplies weight by memory available" do
      facter = StubFacter.new({"memorytotal" => "10 GB", "memoryfree" => "5 GB"})
      memory = LitmusPaper::Metric::AvailableMemory.new(50, facter)
      memory.current_health.should == 25
    end

    describe "#memory_total" do
      it "is a positive integer" do
        metric = LitmusPaper::Metric::AvailableMemory.new(50)
        metric.memory_total.should > 1_000
      end

      it "is cached" do
        Facter.should_receive(:value).once.and_return("10 MB")
        metric = LitmusPaper::Metric::AvailableMemory.new(50)
        metric.memory_total
        metric.memory_total
        metric.memory_total
      end
    end

    describe "#memory_free" do
      it "is a positive integer" do
        metric = LitmusPaper::Metric::AvailableMemory.new(50)
        metric.memory_free.should > 100
      end
    end

    describe "#to_s" do
      it "is the name of the check and the max weight" do
        metric = LitmusPaper::Metric::AvailableMemory.new(50)
        metric.to_s.should == "Metric::AvailableMemory(50)"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
litmus_paper-0.2.1 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.2.0 spec/litmus_paper/metric/available_memory_spec.rb