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
7
spec/ruby/library/rexml/attributes/add_spec.rb
Normal file
7
spec/ruby/library/rexml/attributes/add_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/add', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#add" do
|
||||
it_behaves_like :rexml_attribute_add, :add
|
||||
end
|
7
spec/ruby/library/rexml/attributes/append_spec.rb
Normal file
7
spec/ruby/library/rexml/attributes/append_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/add', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#<<" do
|
||||
it_behaves_like :rexml_attribute_add, :<<
|
||||
end
|
31
spec/ruby/library/rexml/attributes/delete_all_spec.rb
Normal file
31
spec/ruby/library/rexml/attributes/delete_all_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#delete_all" do
|
||||
before :each do
|
||||
@e = REXML::Element.new("root")
|
||||
end
|
||||
|
||||
it "deletes all attributes that match name" do
|
||||
uri = REXML::Attribute.new("uri", "http://something")
|
||||
@e.attributes << uri
|
||||
@e.attributes.delete_all("uri")
|
||||
@e.attributes.should be_empty
|
||||
@e.attributes["uri"].should == nil
|
||||
end
|
||||
|
||||
it "deletes all attributes that match name with a namespace" do
|
||||
ns_uri = REXML::Attribute.new("xmlns:uri", "http://something_here_too")
|
||||
@e.attributes << ns_uri
|
||||
@e.attributes.delete_all("xmlns:uri")
|
||||
@e.attributes.should be_empty
|
||||
@e.attributes["xmlns:uri"].should == nil
|
||||
end
|
||||
|
||||
it "returns the removed attribute" do
|
||||
uri = REXML::Attribute.new("uri", "http://something_here_too")
|
||||
@e.attributes << uri
|
||||
attrs = @e.attributes.delete_all("uri")
|
||||
attrs.first.should == uri
|
||||
end
|
||||
end
|
27
spec/ruby/library/rexml/attributes/delete_spec.rb
Normal file
27
spec/ruby/library/rexml/attributes/delete_spec.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#delete" do
|
||||
before :each do
|
||||
@e = REXML::Element.new("root")
|
||||
@name = REXML::Attribute.new("name", "Pepe")
|
||||
end
|
||||
|
||||
it "takes an attribute name and deletes the attribute" do
|
||||
@e.attributes.delete("name")
|
||||
@e.attributes["name"].should be_nil
|
||||
@e.attributes.should be_empty
|
||||
end
|
||||
|
||||
it "takes an Attribute and deletes it" do
|
||||
@e.attributes.delete(@name)
|
||||
@e.attributes["name"].should be_nil
|
||||
@e.attributes.should be_empty
|
||||
end
|
||||
|
||||
it "returns the element with the attribute removed" do
|
||||
ret_val = @e.attributes.delete(@name)
|
||||
ret_val.should == @e
|
||||
ret_val.attributes.should be_empty
|
||||
end
|
||||
end
|
25
spec/ruby/library/rexml/attributes/each_attribute_spec.rb
Normal file
25
spec/ruby/library/rexml/attributes/each_attribute_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#each_attribute" do
|
||||
it "iterates over the attributes yielding actual Attribute objects" do
|
||||
e = REXML::Element.new("root")
|
||||
name = REXML::Attribute.new("name", "Joe")
|
||||
ns_uri = REXML::Attribute.new("xmlns:ns", "http://some_uri")
|
||||
e.add_attribute name
|
||||
e.add_attribute ns_uri
|
||||
|
||||
attributes = []
|
||||
|
||||
e.attributes.each_attribute do |attr|
|
||||
attributes << attr
|
||||
end
|
||||
|
||||
attributes = attributes.sort_by {|a| a.name }
|
||||
attributes.first.should == name
|
||||
attributes.last.should == ns_uri
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
25
spec/ruby/library/rexml/attributes/each_spec.rb
Normal file
25
spec/ruby/library/rexml/attributes/each_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#each" do
|
||||
before :each do
|
||||
@e = REXML::Element.new("root")
|
||||
@name = REXML::Attribute.new("name", "Joe")
|
||||
@ns_uri = REXML::Attribute.new("xmlns:ns", "http://some_uri")
|
||||
@e.add_attribute @name
|
||||
@e.add_attribute @ns_uri
|
||||
end
|
||||
|
||||
it "iterates over the attributes yielding expanded-name/value" do
|
||||
attributes = []
|
||||
@e.attributes.each do |attr|
|
||||
attr.should be_kind_of(Array)
|
||||
attributes << attr
|
||||
end
|
||||
attributes = attributes.sort_by {|a| a.first }
|
||||
attributes.first.should == ["name", "Joe"]
|
||||
attributes.last.should == ["xmlns:ns", "http://some_uri"]
|
||||
end
|
||||
end
|
||||
|
||||
|
19
spec/ruby/library/rexml/attributes/element_reference_spec.rb
Normal file
19
spec/ruby/library/rexml/attributes/element_reference_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#[]" do
|
||||
before :each do
|
||||
@e = REXML::Element.new("root")
|
||||
@lang = REXML::Attribute.new("language", "english")
|
||||
@e.attributes << @lang
|
||||
end
|
||||
|
||||
it "returns the value of an attribute" do
|
||||
@e.attributes["language"].should == "english"
|
||||
end
|
||||
|
||||
it "returns nil if the attribute does not exist" do
|
||||
@e.attributes["chunky bacon"].should == nil
|
||||
end
|
||||
end
|
||||
|
26
spec/ruby/library/rexml/attributes/element_set_spec.rb
Normal file
26
spec/ruby/library/rexml/attributes/element_set_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#[]=" do
|
||||
before :each do
|
||||
@e = REXML::Element.new("song")
|
||||
@name = REXML::Attribute.new("name", "Holy Smoke!")
|
||||
@e.attributes << @name
|
||||
end
|
||||
|
||||
it "sets an attribute" do
|
||||
@e.attributes["author"] = "_why's foxes"
|
||||
@e.attributes["author"].should == "_why's foxes"
|
||||
end
|
||||
|
||||
it "overwrites an existing attribute" do
|
||||
@e.attributes["name"] = "Chunky Bacon"
|
||||
@e.attributes["name"].should == "Chunky Bacon"
|
||||
end
|
||||
|
||||
it "deletes an attribute is value is nil" do
|
||||
@e.attributes["name"] = nil
|
||||
@e.attributes.length.should == 0
|
||||
end
|
||||
end
|
||||
|
14
spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb
Normal file
14
spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#get_attribute_ns" do
|
||||
it "returns an attribute by name and namespace" do
|
||||
e = REXML::Element.new("root")
|
||||
attr = REXML::Attribute.new("xmlns:ns", "http://some_url")
|
||||
e.attributes << attr
|
||||
attr.prefix.should == "xmlns"
|
||||
# This might be a bug in Attribute, commenting until those specs
|
||||
# are ready
|
||||
# e.attributes.get_attribute_ns(attr.prefix, "name").should == "http://some_url"
|
||||
end
|
||||
end
|
29
spec/ruby/library/rexml/attributes/get_attribute_spec.rb
Normal file
29
spec/ruby/library/rexml/attributes/get_attribute_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#get_attribute" do
|
||||
before :each do
|
||||
@e = REXML::Element.new("root")
|
||||
@name = REXML::Attribute.new("name", "Dave")
|
||||
@e.attributes << @name
|
||||
end
|
||||
|
||||
it "fetches an attributes" do
|
||||
@e.attributes.get_attribute("name").should == @name
|
||||
end
|
||||
|
||||
it "fetches an namespaced attribute" do
|
||||
ns_name = REXML::Attribute.new("im:name", "Murray")
|
||||
@e.attributes << ns_name
|
||||
@e.attributes.get_attribute("name").should == @name
|
||||
@e.attributes.get_attribute("im:name").should == ns_name
|
||||
end
|
||||
|
||||
it "returns an Attribute" do
|
||||
@e.attributes.get_attribute("name").should be_kind_of(REXML::Attribute)
|
||||
end
|
||||
|
||||
it "returns nil if it attribute does not exist" do
|
||||
@e.attributes.get_attribute("fake").should be_nil
|
||||
end
|
||||
end
|
18
spec/ruby/library/rexml/attributes/initialize_spec.rb
Normal file
18
spec/ruby/library/rexml/attributes/initialize_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#initialize" do
|
||||
it "is auto initialized by Element" do
|
||||
e = REXML::Element.new "root"
|
||||
e.attributes.should be_kind_of(REXML::Attributes)
|
||||
|
||||
e.attributes << REXML::Attribute.new("name", "Paul")
|
||||
e.attributes["name"].should == "Paul"
|
||||
end
|
||||
|
||||
it "receives a parent node" do
|
||||
e = REXML::Element.new "root"
|
||||
e.attributes << REXML::Attribute.new("name", "Vic")
|
||||
e.attributes["name"].should == "Vic"
|
||||
end
|
||||
end
|
7
spec/ruby/library/rexml/attributes/length_spec.rb
Normal file
7
spec/ruby/library/rexml/attributes/length_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/length', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#length" do
|
||||
it_behaves_like :rexml_attribute_length, :length
|
||||
end
|
6
spec/ruby/library/rexml/attributes/namespaces_spec.rb
Normal file
6
spec/ruby/library/rexml/attributes/namespaces_spec.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#namespaces" do
|
||||
it "needs to be reviewed for spec completeness"
|
||||
end
|
24
spec/ruby/library/rexml/attributes/prefixes_spec.rb
Normal file
24
spec/ruby/library/rexml/attributes/prefixes_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#prefixes" do
|
||||
before :each do
|
||||
@e = REXML::Element.new("root")
|
||||
a1 = REXML::Attribute.new("xmlns:a", "bar")
|
||||
a2 = REXML::Attribute.new("xmlns:b", "bla")
|
||||
a3 = REXML::Attribute.new("xmlns:c", "baz")
|
||||
@e.attributes << a1
|
||||
@e.attributes << a2
|
||||
@e.attributes << a3
|
||||
|
||||
@e.attributes << REXML::Attribute.new("xmlns", "foo")
|
||||
end
|
||||
|
||||
it "returns an array with the prefixes of each attribute" do
|
||||
@e.attributes.prefixes.sort.should == ["a", "b", "c"]
|
||||
end
|
||||
|
||||
it "does not include the default namespace" do
|
||||
@e.attributes.prefixes.include?("xmlns").should == false
|
||||
end
|
||||
end
|
17
spec/ruby/library/rexml/attributes/shared/add.rb
Normal file
17
spec/ruby/library/rexml/attributes/shared/add.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
describe :rexml_attribute_add, shared: true do
|
||||
before :each do
|
||||
@e = REXML::Element.new("root")
|
||||
@attr = REXML::Attributes.new(@e)
|
||||
@name = REXML::Attribute.new("name", "Joe")
|
||||
end
|
||||
|
||||
it "adds an attribute" do
|
||||
@attr.send(@method, @name)
|
||||
@attr["name"].should == "Joe"
|
||||
end
|
||||
|
||||
it "replaces an existing attribute" do
|
||||
@attr.send(@method, REXML::Attribute.new("name", "Bruce"))
|
||||
@attr["name"].should == "Bruce"
|
||||
end
|
||||
end
|
13
spec/ruby/library/rexml/attributes/shared/length.rb
Normal file
13
spec/ruby/library/rexml/attributes/shared/length.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.expand_path('../../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe :rexml_attribute_length, shared: true do
|
||||
it "returns the number of attributes" do
|
||||
e = REXML::Element.new("root")
|
||||
e.attributes.send(@method).should == 0
|
||||
|
||||
e.attributes << REXML::Attribute.new("name", "John")
|
||||
e.attributes << REXML::Attribute.new("another_name", "Leo")
|
||||
e.attributes.send(@method).should == 2
|
||||
end
|
||||
end
|
7
spec/ruby/library/rexml/attributes/size_spec.rb
Normal file
7
spec/ruby/library/rexml/attributes/size_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/length', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#size" do
|
||||
it_behaves_like :rexml_attribute_length, :size
|
||||
end
|
20
spec/ruby/library/rexml/attributes/to_a_spec.rb
Normal file
20
spec/ruby/library/rexml/attributes/to_a_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Attributes#to_a" do
|
||||
it "returns an array with the attributes" do
|
||||
e = REXML::Element.new("root")
|
||||
name = REXML::Attribute.new("name", "Dave")
|
||||
last = REXML::Attribute.new("last_name", "Murray")
|
||||
|
||||
e.attributes << name
|
||||
e.attributes << last
|
||||
|
||||
e.attributes.to_a.sort{|a,b|a.to_s<=>b.to_s}.should == [name, last]
|
||||
end
|
||||
|
||||
it "returns an empty array if it has no attributes" do
|
||||
REXML::Element.new("root").attributes.to_a.should == []
|
||||
end
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue