Sha256: 6b087f34cac779661273328b16a0d204df399e5a30c1318a2aaabd53658cffe4

Contents?: true

Size: 1.94 KB

Versions: 28

Compression:

Stored size: 1.94 KB

Contents

require 'spec_helper'

describe LitmusPaper::Metric::AvailableMemory do
  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

    it "multiplies weight by memory available when handling floating point values" do
      facter = StubFacter.new({"memorytotal" => "2.0 GB", "memoryfree" => "1.8 GB"})
      memory = LitmusPaper::Metric::AvailableMemory.new(50, facter)
      memory.current_health.should == 44
    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 "handles floating point values properly" do
        facter = StubFacter.new("memorytotal" => "1.80 GB")
        memory = LitmusPaper::Metric::AvailableMemory.new(50, facter)
        memory.memory_total.should == 1932735283
      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

      it "handles floating point values properly" do
        facter = StubFacter.new("memoryfree" => "1.80 GB")
        memory = LitmusPaper::Metric::AvailableMemory.new(50, facter)
        memory.memory_free.should == 1932735283
      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

28 entries across 28 versions & 1 rubygems

Version Path
litmus_paper-0.9.1 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.9.0 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.8.9 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.8.8 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.8.7 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.8.6 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.8.5 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.8.4 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.8.3 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.8.2 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.8.1 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.8.0 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.7.9 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.7.5 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.7.4 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.7.3 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.7.2 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.7.1 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.7.0 spec/litmus_paper/metric/available_memory_spec.rb
litmus_paper-0.6.3 spec/litmus_paper/metric/available_memory_spec.rb