|
491 | 491 | end |
492 | 492 | end |
493 | 493 |
|
| 494 | + describe "update_from!" do |
| 495 | + before(:each) do |
| 496 | + @node.name("orig") |
| 497 | + @node.chef_environment("dev") |
| 498 | + @node.default_attrs = { "one" => { "two" => "three", "four" => "five", "eight" => "nine" } } |
| 499 | + @node.override_attrs = { "one" => { "two" => "three", "four" => "six" } } |
| 500 | + @node.normal_attrs = { "one" => { "two" => "seven" } } |
| 501 | + @node.run_list << "role[marxist]" |
| 502 | + @node.run_list << "role[leninist]" |
| 503 | + @node.run_list << "recipe[stalinist]" |
| 504 | + |
| 505 | + @example = Chef::Node.new() |
| 506 | + @example.name("newname") |
| 507 | + @example.chef_environment("prod") |
| 508 | + @example.default_attrs = { "alpha" => { "bravo" => "charlie", "delta" => "echo" } } |
| 509 | + @example.override_attrs = { "alpha" => { "bravo" => "foxtrot", "delta" => "golf" } } |
| 510 | + @example.normal_attrs = { "alpha" => { "bravo" => "hotel" } } |
| 511 | + @example.run_list << "role[comedy]" |
| 512 | + @example.run_list << "role[drama]" |
| 513 | + @example.run_list << "recipe[mystery]" |
| 514 | + end |
| 515 | + |
| 516 | + it "allows update of everything except name" do |
| 517 | + @node.update_from!(@example) |
| 518 | + @node.name.should == "orig" |
| 519 | + @node.chef_environment.should == @example.chef_environment |
| 520 | + @node.default_attrs.should == @example.default_attrs |
| 521 | + @node.override_attrs.should == @example.override_attrs |
| 522 | + @node.normal_attrs.should == @example.normal_attrs |
| 523 | + @node.run_list.should == @example.run_list |
| 524 | + end |
| 525 | + |
| 526 | + it "should not update the name of the node" do |
| 527 | + @node.should_not_receive(:name).with(@example.name) |
| 528 | + @node.update_from!(@example) |
| 529 | + end |
| 530 | + end |
| 531 | + |
494 | 532 | describe "to_hash" do |
495 | 533 | it "should serialize itself as a hash" do |
496 | 534 | @node.chef_environment("dev") |
|
0 commit comments