Sha256: 5795820025b95a46dd633dcd7fef3a98dd9261de98edc536528049227f158090

Contents?: true

Size: 1.5 KB

Versions: 15

Compression:

Stored size: 1.5 KB

Contents

#!/usr/bin/env rspec

require 'spec_helper'
require File.dirname(__FILE__) + "/../../../../../plugins/mcollective/aggregate/average.rb"

module MCollective
  class Aggregate
    describe Average do
      describe "#startup_hook" do
        it "should set the correct result hash" do
          result = Average.new(:test, [], "%d", :test_action)
          result.result.should == {:value => 0, :type => :numeric, :output => :test}
          result.aggregate_format.should == "%d"
        end

        it "should set a defauly aggregate_format if one isn't defined" do
          result = Average.new(:test, [], nil, :test_action)
          result.aggregate_format.should == "Average of test: %f"
        end
      end

      describe "#process_result" do
        it "should add the reply value to the result hash" do
          average = Average.new([:test], [], "%d", :test_action)
          average.process_result(1, {:test => 1})
          average.result[:value].should == 1
        end
      end

      describe "#summarize" do
        it "should calculate the average and return a result class" do
          result_obj = mock
          result_obj.stubs(:new).returns(:success)

          average = Average.new([:test], [], "%d", :test_action)
          average.process_result(10, {:test => 10})
          average.process_result(20, {:test => 20})
          average.stubs(:result_class).returns(result_obj)
          average.summarize.should == :success
          average.result[:value].should == 15
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mcollective-client-2.7.0 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.6.1 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.6.0 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.5.3 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.5.2 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.5.1 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.5.0 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.5.0.rc1 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.4.1 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.4.0 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.2.4 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.2.3 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.2.2 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.2.1 spec/unit/plugins/mcollective/aggregate/average_spec.rb
mcollective-client-2.2.0 spec/unit/plugins/mcollective/aggregate/average_spec.rb