spec/unit/provider/group/pw_spec.rb in chef-10.34.6 vs spec/unit/provider/group/pw_spec.rb in chef-11.0.0.beta.0

- old
+ new

@@ -47,22 +47,20 @@ end describe "when creating a group" do it "should run pw groupadd with the return of set_options and set_members_option" do @new_resource.gid(23) - @provider.should_receive(:run_command).with({ :command => "pw groupadd wheel -g '23'" }).and_return(true) + @provider.should_receive(:run_command).with({ :command => "pw groupadd wheel -g '23' -M root,aj" }).and_return(true) @provider.create_group end end describe "when managing the group" do it "should run pw groupmod with the return of set_options" do @new_resource.gid(42) - @new_resource.members(["someone"]) - @provider.should_receive(:run_command).with({ :command => "pw groupmod wheel -g '42' -m someone" }).and_return(true) - @provider.should_receive(:run_command).with({ :command => "pw groupmod wheel -g '42' -d root,aj" }).and_return(true) + @provider.should_receive(:run_command).with({ :command => "pw groupmod wheel -g '42' -M root,aj" }).and_return(true) @provider.manage_group end end @@ -78,44 +76,49 @@ describe "with an empty members array in both the new and current resource" do before do @new_resource.stub!(:members).and_return([]) @current_resource.stub!(:members).and_return([]) end - + + it "should log an appropriate message" do + Chef::Log.should_receive(:debug).with("group[wheel] not changing group members, the group has no members") + @provider.set_members_option + end + it "should set no options" do - @provider.set_members_options.should eql([ ]) + @provider.set_members_option.should eql("") end end describe "with an empty members array in the new resource and existing members in the current resource" do before do @new_resource.stub!(:members).and_return([]) @current_resource.stub!(:members).and_return(["all", "your", "base"]) end it "should log an appropriate message" do - Chef::Log.should_receive(:debug).with("group[wheel] removing group members: all,your,base") - @provider.set_members_options + Chef::Log.should_receive(:debug).with("group[wheel] removing group members all, your, base") + @provider.set_members_option end it "should set the -d option with the members joined by ','" do - @provider.set_members_options.should eql([ " -d all,your,base" ]) + @provider.set_members_option.should eql(" -d all,your,base") end end describe "with supplied members array in the new resource and an empty members array in the current resource" do before do @new_resource.stub!(:members).and_return(["all", "your", "base"]) @current_resource.stub!(:members).and_return([]) end it "should log an appropriate debug message" do - Chef::Log.should_receive(:debug).with("group[wheel] adding group members: all,your,base") - @provider.set_members_options + Chef::Log.should_receive(:debug).with("group[wheel] setting group members to all, your, base") + @provider.set_members_option end it "should set the -M option with the members joined by ','" do - @provider.set_members_options.should eql([ " -m all,your,base" ]) + @provider.set_members_option.should eql(" -M all,your,base") end end end describe"load_current_resource" do