Sha256: 427e1f7a4b7f86d1a409925eff314817add4689fbb8224a5c7cb76d97fe8ebd3

Contents?: true

Size: 1.21 KB

Versions: 15

Compression:

Stored size: 1.21 KB

Contents

#!/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

Version data entries

15 entries across 15 versions & 1 rubygems

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