diff --git a/spec/node_spec.cr b/spec/node_spec.cr index 2b8f28a..ff6b3fb 100644 --- a/spec/node_spec.cr +++ b/spec/node_spec.cr @@ -211,15 +211,15 @@ describe Myhtml::Node do parser.root!.data.null?.should eq true end - describe "#append" do + describe "#append_child" do it "adds a node at the end" do tree = Myhtml::Tree.new parent = tree.create_node(:div) child = tree.create_node(:a) grandchild = tree.create_node(:span) - parent.append(child) - child.append(grandchild) + parent.append_child(child) + child.append_child(grandchild) parent.to_html.should eq("
") parent.children.first.tag_sym.should eq(:a) @@ -227,21 +227,21 @@ describe Myhtml::Node do end end - describe "#before" do + describe "#insert_before" do it "adds a node just prior to this node" do document = Myhtml::Parser.new("
") main = document.css("main").first tree = Myhtml::Tree.new header = tree.create_node(:header) - main.before(header) + main.insert_before(header) body_html = "
" document.body!.to_html.should eq body_html end end - describe "#after" do + describe "#insert_after" do it "adds a node just following this node" do html_string = "
" document = Myhtml::Parser.new(html_string) @@ -249,7 +249,7 @@ describe Myhtml::Node do tree = Myhtml::Tree.new main = tree.create_node(:main) - header.after(main) + header.insert_after(main) body_html = "
" document.body!.to_html.should eq body_html diff --git a/src/myhtml/node.cr b/src/myhtml/node.cr index aeb9e26..34f6ce8 100644 --- a/src/myhtml/node.cr +++ b/src/myhtml/node.cr @@ -138,16 +138,16 @@ struct Myhtml::Node end end - def append(child : Node) + def append_child(child : Node) Lib.tree_node_add_child(raw_node, child.raw_node) end - def before(node preceding : Node) - Lib.tree_node_insert_before(raw_node, preceding.raw_node) + def insert_before(node : Node) + Lib.tree_node_insert_before(raw_node, node.raw_node) end - def after(node following : Node) - Lib.tree_node_insert_after(raw_node, following.raw_node) + def insert_after(node : Node) + Lib.tree_node_insert_after(raw_node, node.raw_node) end private class IOWrapper