10 @config.stubs(:identity).returns("rspec")
11 @config.stubs(:main_collective).returns("main_collective")
12 Config.stubs(:instance).returns(@config)
18 it "should provide access the main configuration class" do
19 @reg.config.should == @config
24 describe "#identity" do
25 it "should return the correct identity" do
26 @reg.config.identity.should == "rspec"
30 describe "#msg_filter" do
31 it "should target the registration agent" do
32 @reg.msg_filter["agent"].should == ["registration"]
36 describe "#target_collective" do
37 it "should return the configured registration_collective" do
38 @config.expects(:registration_collective).returns("registration").once
39 @config.expects(:collectives).returns(["main_collective", "registration"]).once
40 @reg.target_collective.should == "registration"
43 it "should use the main collective if registration collective is not valid" do
44 @config.expects(:registration_collective).returns("registration").once
45 @config.expects(:collectives).returns(["main_collective"]).once
47 Log.expects(:warn).with("Sending registration to main_collective: registration is not a valid collective").once
49 @reg.target_collective.should == "main_collective"
53 describe "#publish" do
54 it "should skip registration for empty messages" do
55 Log.expects(:debug).with("Skipping registration due to nil body")
59 it "should publish via the message object" do
61 message.expects(:encode!)
62 message.expects(:publish)
63 message.expects(:requestid).returns("123")
64 message.expects(:collective).returns("mcollective")
66 Message.expects(:new).returns(message)
68 Log.expects(:debug).with("Sending registration 123 to collective mcollective")
70 @reg.expects(:target_collective).returns("mcollective")
72 @reg.publish("message")