8 describe "#initialize" do
9 it "should set the correct instance variables and call the startup hook" do
10 Base.any_instance.expects(:startup_hook).once
11 base = Base.new("value", [], "%s%s", "rspec")
12 base.name.should == "MCollective::Aggregate::Base"
13 base.output_name.should == "value"
14 base.aggregate_format.should == "%s%s"
15 base.action.should == "rspec"
19 describe "#startup_hook and #process_result" do
20 it "should raise an exception for an unimplemented startup_hook method " do
22 base = Base.new("value", [], "", "rspec")
23 }.to raise_error(RuntimeError, "'startup_hook' method of function class MCollective::Aggregate::Base has not yet been implemented")
26 it "should raise an exception for an unimplemented process_result method" do
27 Base.any_instance.stubs(:startup_hook)
28 base = Base.new("value", [], "", "rspec")
31 }.to raise_error(RuntimeError,"'process_result' method of function class MCollective::Aggregate::Base has not yet been implemented")
35 describe "summarize" do
36 it "should raise and exception if the result type has not been set" do
37 Base.any_instance.stubs(:startup_hook)
38 base = Base.new("value", [], "", "rspec")
41 }.to raise_error(RuntimeError, "Result type is not set while trying to summarize aggregate function results")
44 it "should return the correct result class if result type has been set" do
46 result_object.stubs(:new)
48 Base.any_instance.stubs(:startup_hook)
49 base = Base.new("value", [], "", "rspec")
50 base.result[:type] = :result_type
51 base.expects(:result_class).with(:result_type).returns(result_object)