Sha256: 83d57f316e8596ba8d5bc83ab8ec1a8a15d1c0cd183acc982151ecae181f18f9

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

module Database
  module Master
    def db
      nodes.inject(0) {|i,inst| i * inst.db} / nodes.size
    end
  end
  module Remote
    def db
      5.0
    end
  end
end

PoolParty.register_monitor Database

describe "monitors (random, to spec the inclusion)" do
  describe "when included" do
    before(:each) do      
      stub_option_load
      @master = Master.new
      @instance = RemoteInstance.new
    end
    it "should include them in the Monitors module" do
      @master.methods.include?("db").should == true
    end
    it "should also include the new methods in the remote model" do
      @instance.methods.include?("db").should == true
    end
    describe "master" do
      before(:each) do
        @master.stub!(:list_of_nonterminated_instances).and_return(
        [{:instance_id => "i-abcdde1"}]
        )
      end
      it "should try to collect the cpu for the entire set of remote instances when calling cpu" do
        @master.nodes.should_receive(:inject).once.and_return 5.0
        @master.db.should == 5.0
      end
    end
    describe "remote instance" do
      it "should try to run into the remote instance" do
        @instance.db.should == 5.0
      end
      it "should be able to find the exact amount of time the processor has been up" do
        @instance.db.round_to(2).should == 5.0
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
auser-poolparty-0.1.1 spec/monitors/misc_monitor_spec.rb
auser-poolparty-0.1.2 spec/monitors/misc_monitor_spec.rb
jtzemp-poolparty-0.1.2 spec/monitors/misc_monitor_spec.rb