Skip to content

Commit 86339ca

Browse files
Dan Princealgorist
authored andcommitted
Update the node_edit_spec.rb and role_edit_spec.rb spec tests
to run correctly when knife doesn't save unchanged objects.
1 parent 2424bfe commit 86339ca

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

‎chef/spec/unit/knife/node_edit_spec.rb‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,19 @@
4747

4848
it "should save the edited node data" do
4949
pansy = Chef::Node.new
50+
@node.name("new_node_name")
5051
@knife.should_receive(:edit_data).with(@node).and_return(pansy)
5152
pansy.should_receive(:save)
5253
@knife.run
5354
end
5455

56+
it "should not save the unedited node data" do
57+
pansy = Chef::Node.new
58+
@knife.should_receive(:edit_data).with(@node).and_return(pansy)
59+
pansy.should_not_receive(:save)
60+
@knife.run
61+
end
62+
5563
it "should not print the node" do
5664
@knife.should_not_receive(:output).with("poop")
5765
@knife.run

‎chef/spec/unit/knife/role_edit_spec.rb‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,36 @@
3939
@knife.run
4040
end
4141

42-
it "should edit the node data" do
42+
it "should edit the role data" do
4343
@knife.should_receive(:edit_data).with(@role)
4444
@knife.run
4545
end
4646

47-
it "should save the edited node data" do
47+
it "should save the edited role data" do
4848
pansy = Chef::Role.new
49+
50+
@role.name("new_role_name")
4951
@knife.should_receive(:edit_data).with(@role).and_return(pansy)
5052
pansy.should_receive(:save)
5153
@knife.run
5254
end
5355

54-
it "should not print the node" do
56+
it "should not save the unedited role data" do
57+
pansy = Chef::Role.new
58+
59+
@knife.should_receive(:edit_data).with(@role).and_return(pansy)
60+
pansy.should_not_receive(:save)
61+
@knife.run
62+
63+
end
64+
65+
it "should not print the role" do
5566
@knife.should_not_receive(:output)
5667
@knife.run
5768
end
5869

5970
describe "with -p or --print-after" do
60-
it "should pretty print the node, formatted for display" do
71+
it "should pretty print the role, formatted for display" do
6172
@knife.config[:print_after] = true
6273
@knife.should_receive(:output).with(@role)
6374
@knife.run

0 commit comments

Comments
 (0)