mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
75bfc6440d
commit
1d15d5f080
4370 changed files with 0 additions and 0 deletions
21
spec/ruby/library/rexml/node/each_recursive_spec.rb
Normal file
21
spec/ruby/library/rexml/node/each_recursive_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Node#each_recursive" do
|
||||
before :each do
|
||||
@doc = REXML::Document.new
|
||||
@doc << REXML::XMLDecl.new
|
||||
@root = REXML::Element.new "root"
|
||||
@child1 = REXML::Element.new "child1"
|
||||
@child2 = REXML::Element.new "child2"
|
||||
@root << @child1
|
||||
@root << @child2
|
||||
@doc << @root
|
||||
end
|
||||
|
||||
it "visits all subnodes of self" do
|
||||
nodes = []
|
||||
@doc.each_recursive { |node| nodes << node}
|
||||
nodes.should == [@root, @child1, @child2]
|
||||
end
|
||||
end
|
25
spec/ruby/library/rexml/node/find_first_recursive_spec.rb
Normal file
25
spec/ruby/library/rexml/node/find_first_recursive_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Node#find_first_recursive" do
|
||||
before :each do
|
||||
@e = REXML::Element.new("root")
|
||||
@node1 = REXML::Element.new("node")
|
||||
@node2 = REXML::Element.new("another node")
|
||||
@subnode = REXML::Element.new("another node")
|
||||
@node1 << @subnode
|
||||
@e << @node1
|
||||
@e << @node2
|
||||
end
|
||||
|
||||
it "finds the first element that matches block" do
|
||||
found = @e.find_first_recursive { |n| n.to_s == "<node><another node/></node>"}
|
||||
found.should == @node1
|
||||
end
|
||||
|
||||
it "visits the nodes in preorder" do
|
||||
found = @e.find_first_recursive { |n| n.to_s == "<another node/>"}
|
||||
found.should == @subnode
|
||||
found.should_not == @node2
|
||||
end
|
||||
end
|
15
spec/ruby/library/rexml/node/index_in_parent_spec.rb
Normal file
15
spec/ruby/library/rexml/node/index_in_parent_spec.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Node#index_in_parent" do
|
||||
it "returns the index (starting from 1) of self in parent" do
|
||||
e = REXML::Element.new("root")
|
||||
node1 = REXML::Element.new("node")
|
||||
node2 = REXML::Element.new("another node")
|
||||
e << node1
|
||||
e << node2
|
||||
|
||||
node1.index_in_parent.should == 1
|
||||
node2.index_in_parent.should == 2
|
||||
end
|
||||
end
|
21
spec/ruby/library/rexml/node/next_sibling_node_spec.rb
Normal file
21
spec/ruby/library/rexml/node/next_sibling_node_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Node#next_sibling_node" do
|
||||
before :each do
|
||||
@e = REXML::Element.new("root")
|
||||
@node1 = REXML::Element.new("node")
|
||||
@node2 = REXML::Element.new("another node")
|
||||
@e << @node1
|
||||
@e << @node2
|
||||
end
|
||||
|
||||
it "returns the next child node in parent" do
|
||||
@node1.next_sibling_node.should == @node2
|
||||
end
|
||||
|
||||
it "returns nil if there are no more child nodes next" do
|
||||
@node2.next_sibling_node.should == nil
|
||||
@e.next_sibling_node.should == nil
|
||||
end
|
||||
end
|
21
spec/ruby/library/rexml/node/parent_spec.rb
Normal file
21
spec/ruby/library/rexml/node/parent_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Node#parent?" do
|
||||
it "returns true for Elements" do
|
||||
e = REXML::Element.new("foo")
|
||||
e.parent?.should == true
|
||||
end
|
||||
|
||||
it "returns true for Documents" do
|
||||
e = REXML::Document.new
|
||||
e.parent?.should == true
|
||||
end
|
||||
|
||||
# This includes attributes, CDatas and declarations.
|
||||
it "returns false for Texts" do
|
||||
e = REXML::Text.new("foo")
|
||||
e.parent?.should == false
|
||||
end
|
||||
end
|
||||
|
21
spec/ruby/library/rexml/node/previous_sibling_node_spec.rb
Normal file
21
spec/ruby/library/rexml/node/previous_sibling_node_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Node#previous_sibling_node" do
|
||||
before :each do
|
||||
@e = REXML::Element.new("root")
|
||||
@node1 = REXML::Element.new("node")
|
||||
@node2 = REXML::Element.new("another node")
|
||||
@e << @node1
|
||||
@e << @node2
|
||||
end
|
||||
|
||||
it "returns the previous child node in parent" do
|
||||
@node2.previous_sibling_node.should == @node1
|
||||
end
|
||||
|
||||
it "returns nil if there are no more child nodes before" do
|
||||
@node1.previous_sibling_node.should == nil
|
||||
@e.previous_sibling_node.should == nil
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue