Skip to content

Commit

Permalink
Merge 296b5b0 into b5e62c4
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Jun 7, 2019
2 parents b5e62c4 + 296b5b0 commit 431690d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/cfa/augeas_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ def replace_entry(old_entry)
@data.insert(index, new_entry)
# the entry is not yet in the tree
if old_entry[:operation] == :add
key = old_entry[:key]
@data.delete_if { |d| d[:key] == key }
else
old_entry[:operation] = :remove
Expand Down
11 changes: 11 additions & 0 deletions spec/augeas_tree_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@
tree["new_cool_key"] = "Ever cooler value"
expect(tree["new_cool_key"]).to eq "Ever cooler value"
end

it "adds a new key and then overwrites it with a different kind" do
tree["shopping_cart"] = "orange"

subtree = CFA::AugeasTree.new
subtree["item"] = "orange"
subtree["note"] = "paint, not fruit"
tree["shopping_cart"] = subtree

expect(tree["shopping_cart"]["item"]).to eq "orange"
end
end

describe "#add" do
Expand Down

0 comments on commit 431690d

Please sign in to comment.