|
129 | 129 | @new_resource = mock("Chef::Resource::Group", |
130 | 130 | :null_object => true, |
131 | 131 | :group_name => "aj", |
132 | | - :members => [ "all", "your", "base", "are", "belong", "to", "us" ] |
| 132 | + :members => [ "all", "your", "base" ] |
133 | 133 | ) |
134 | 134 | @new_resource.stub!(:to_s).and_return("group[aj]") |
135 | 135 | @provider = Chef::Provider::Group::Groupadd.new(@node, @new_resource) |
136 | 136 | @provider.stub!(:run_command).and_return(true) |
137 | 137 | end |
138 | 138 |
|
139 | | - it "should log an appropriate debug message" do |
140 | | - Chef::Log.should_receive(:debug).with("group[aj]: setting group members to all, your, base, are, belong, to, us") |
141 | | - @provider.modify_group_members |
| 139 | + describe "with an empty members array" do |
| 140 | + before do |
| 141 | + @new_resource.stub!(:members).and_return([]) |
| 142 | + end |
| 143 | + |
| 144 | + it "should log an appropriate message" do |
| 145 | + Chef::Log.should_receive(:debug).with("group[aj]: not changing group members, the group has no members") |
| 146 | + @provider.modify_group_members |
| 147 | + end |
142 | 148 | end |
143 | 149 |
|
144 | | - it "should run gpasswd with the members joined by ',' and the target group" do |
145 | | - @provider.should_receive(:run_command).with({:command => "gpasswd -M all,your,base,are,belong,to,us aj"}) |
146 | | - @provider.modify_group_members |
| 150 | + describe "with supplied members" do |
| 151 | + before do |
| 152 | + @new_resource.stub!(:members).and_return(["all", "your", "base"]) |
| 153 | + end |
| 154 | + |
| 155 | + it "should log an appropriate debug message" do |
| 156 | + Chef::Log.should_receive(:debug).with("group[aj]: setting group members to all, your, base") |
| 157 | + @provider.modify_group_members |
| 158 | + end |
| 159 | + |
| 160 | + it "should run gpasswd with the members joined by ',' followed by the target group" do |
| 161 | + @provider.should_receive(:run_command).with({:command => "gpasswd -M all,your,base aj"}) |
| 162 | + @provider.modify_group_members |
| 163 | + end |
147 | 164 | end |
148 | 165 | end |
149 | 166 |
|
|
0 commit comments