X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Funit%2Fplugins%2Fmcollective%2Fdiscovery%2Fmc_spec.rb;fp=spec%2Funit%2Fplugins%2Fmcollective%2Fdiscovery%2Fmc_spec.rb;h=bcba8d3886be04468d65aed0eaba0c1233c5ca1b;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/spec/unit/plugins/mcollective/discovery/mc_spec.rb b/spec/unit/plugins/mcollective/discovery/mc_spec.rb new file mode 100644 index 0000000..bcba8d3 --- /dev/null +++ b/spec/unit/plugins/mcollective/discovery/mc_spec.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env rspec + +require 'spec_helper' + +require File.dirname(__FILE__) + '/../../../../../plugins/mcollective/discovery/mc.rb' + +module MCollective + class Discovery + describe Mc do + describe "#discover" do + before do + @reply = mock + @reply.stubs(:payload).returns({:senderid => "rspec"}) + + @client = mock + @client.stubs(:sendreq) + @client.stubs(:unsubscribe) + @client.stubs(:receive).returns(@reply) + + Log.stubs(:debug) + end + + it "should send the ping request via the supplied client" do + @client.expects(:sendreq).with("ping", "discovery", Util.empty_filter).returns("123456") + Mc.discover(Util.empty_filter, 1, 1, @client) + end + + it "should stop early if a limit is supplied" do + @client.stubs(:receive).returns(@reply).times(10) + Mc.discover(Util.empty_filter, 1, 10, @client).should == ("rspec," * 10).split(",") + end + + it "should unsubscribe from the discovery reply source" do + @client.expects(:unsubscribe).with("discovery", :reply) + Mc.discover(Util.empty_filter, 1, 10, @client).should == ("rspec," * 10).split(",") + end + end + end + end +end