summaryrefslogtreecommitdiff
path: root/spec/ruby/library/rexml/attribute
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-01-12 08:14:26 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2020-01-12 12:28:29 +0900
commite61cab3a367c4040a2a487dd893c7be9a37889a9 (patch)
treec6ea3e3c929fcb5fd17197abea387173912f624b /spec/ruby/library/rexml/attribute
parent83240f315a10b42b53c3b62c1fbc428f97912665 (diff)
Ignore rexml examples on ruby/spec
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2832
Diffstat (limited to 'spec/ruby/library/rexml/attribute')
-rw-r--r--spec/ruby/library/rexml/attribute/clone_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attribute/element_spec.rb33
-rw-r--r--spec/ruby/library/rexml/attribute/equal_value_spec.rb25
-rw-r--r--spec/ruby/library/rexml/attribute/hash_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attribute/initialize_spec.rb45
-rw-r--r--spec/ruby/library/rexml/attribute/inspect_spec.rb29
-rw-r--r--spec/ruby/library/rexml/attribute/namespace_spec.rb39
-rw-r--r--spec/ruby/library/rexml/attribute/node_type_spec.rb15
-rw-r--r--spec/ruby/library/rexml/attribute/prefix_spec.rb25
-rw-r--r--spec/ruby/library/rexml/attribute/remove_spec.rb31
-rw-r--r--spec/ruby/library/rexml/attribute/to_s_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attribute/to_string_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attribute/value_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attribute/write_spec.rb35
-rw-r--r--spec/ruby/library/rexml/attribute/xpath_spec.rb27
15 files changed, 225 insertions, 180 deletions
diff --git a/spec/ruby/library/rexml/attribute/clone_spec.rb b/spec/ruby/library/rexml/attribute/clone_spec.rb
index 9a4a4079e1..44c8ddebcc 100644
--- a/spec/ruby/library/rexml/attribute/clone_spec.rb
+++ b/spec/ruby/library/rexml/attribute/clone_spec.rb
@@ -1,11 +1,14 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#clone" do
- it "returns a copy of this Attribute" do
- orig = REXML::Attribute.new("name", "value&&")
- orig.should == orig.clone
- orig.clone.to_s.should == orig.to_s
- orig.clone.to_string.should == orig.to_string
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
+
+ describe "REXML::Attribute#clone" do
+ it "returns a copy of this Attribute" do
+ orig = REXML::Attribute.new("name", "value&&")
+ orig.should == orig.clone
+ orig.clone.to_s.should == orig.to_s
+ orig.clone.to_string.should == orig.to_string
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/element_spec.rb b/spec/ruby/library/rexml/attribute/element_spec.rb
index 832e7e9a41..4fc4d9ed58 100644
--- a/spec/ruby/library/rexml/attribute/element_spec.rb
+++ b/spec/ruby/library/rexml/attribute/element_spec.rb
@@ -1,23 +1,26 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#element" do
- it "returns the parent element" do
- e = REXML::Element.new "root"
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- REXML::Attribute.new("name", "value", e).element.should == e
- REXML::Attribute.new("name", "default_constructor").element.should == nil
+ describe "REXML::Attribute#element" do
+ it "returns the parent element" do
+ e = REXML::Element.new "root"
+
+ REXML::Attribute.new("name", "value", e).element.should == e
+ REXML::Attribute.new("name", "default_constructor").element.should == nil
+ end
end
-end
-describe "REXML::Attribute#element=" do
- it "sets the parent element" do
- e = REXML::Element.new "root"
- f = REXML::Element.new "temp"
- a = REXML::Attribute.new("name", "value", e)
- a.element.should == e
+ describe "REXML::Attribute#element=" do
+ it "sets the parent element" do
+ e = REXML::Element.new "root"
+ f = REXML::Element.new "temp"
+ a = REXML::Attribute.new("name", "value", e)
+ a.element.should == e
- a.element = f
- a.element.should == f
+ a.element = f
+ a.element.should == f
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/equal_value_spec.rb b/spec/ruby/library/rexml/attribute/equal_value_spec.rb
index 8bf2c0a3a1..a51e1cc390 100644
--- a/spec/ruby/library/rexml/attribute/equal_value_spec.rb
+++ b/spec/ruby/library/rexml/attribute/equal_value_spec.rb
@@ -1,18 +1,21 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#==" do
- it "returns true if other has equal name and value" do
- a1 = REXML::Attribute.new("foo", "bar")
- a1.should == a1.clone
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- a2 = REXML::Attribute.new("foo", "bar")
- a1.should == a2
+ describe "REXML::Attribute#==" do
+ it "returns true if other has equal name and value" do
+ a1 = REXML::Attribute.new("foo", "bar")
+ a1.should == a1.clone
- a3 = REXML::Attribute.new("foo", "bla")
- a1.should_not == a3
+ a2 = REXML::Attribute.new("foo", "bar")
+ a1.should == a2
- a4 = REXML::Attribute.new("baz", "bar")
- a1.should_not == a4
+ a3 = REXML::Attribute.new("foo", "bla")
+ a1.should_not == a3
+
+ a4 = REXML::Attribute.new("baz", "bar")
+ a1.should_not == a4
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/hash_spec.rb b/spec/ruby/library/rexml/attribute/hash_spec.rb
index dd71b28108..544cb39515 100644
--- a/spec/ruby/library/rexml/attribute/hash_spec.rb
+++ b/spec/ruby/library/rexml/attribute/hash_spec.rb
@@ -1,13 +1,16 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#hash" do
- # These are not really complete, any idea on how to make them more
- # "testable" will be appreciated.
- it "returns a hashcode made of the name and value of self" do
- a = REXML::Attribute.new("name", "value")
- a.hash.should be_kind_of(Numeric)
- b = REXML::Attribute.new(a)
- a.hash.should == b.hash
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
+
+ describe "REXML::Attribute#hash" do
+ # These are not really complete, any idea on how to make them more
+ # "testable" will be appreciated.
+ it "returns a hashcode made of the name and value of self" do
+ a = REXML::Attribute.new("name", "value")
+ a.hash.should be_kind_of(Numeric)
+ b = REXML::Attribute.new(a)
+ a.hash.should == b.hash
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/initialize_spec.rb b/spec/ruby/library/rexml/attribute/initialize_spec.rb
index 9f5e30c517..84c17d8b7c 100644
--- a/spec/ruby/library/rexml/attribute/initialize_spec.rb
+++ b/spec/ruby/library/rexml/attribute/initialize_spec.rb
@@ -1,29 +1,32 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#initialize" do
- before :each do
- @e = REXML::Element.new "root"
- @name = REXML::Attribute.new("name", "Nicko")
- @e.add_attribute @name
- end
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- it "receives two strings for name and value" do
- @e.attributes["name"].should == "Nicko"
- @e.add_attribute REXML::Attribute.new("last_name", nil)
- @e.attributes["last_name"].should == ""
- end
+ describe "REXML::Attribute#initialize" do
+ before :each do
+ @e = REXML::Element.new "root"
+ @name = REXML::Attribute.new("name", "Nicko")
+ @e.add_attribute @name
+ end
- it "receives an Attribute and clones it" do
- copy = REXML::Attribute.new(@name)
- copy.should == @name
- end
+ it "receives two strings for name and value" do
+ @e.attributes["name"].should == "Nicko"
+ @e.add_attribute REXML::Attribute.new("last_name", nil)
+ @e.attributes["last_name"].should == ""
+ end
+
+ it "receives an Attribute and clones it" do
+ copy = REXML::Attribute.new(@name)
+ copy.should == @name
+ end
- it "receives a parent node" do
- last_name = REXML::Attribute.new("last_name", "McBrain", @e)
- last_name.element.should == @e
+ it "receives a parent node" do
+ last_name = REXML::Attribute.new("last_name", "McBrain", @e)
+ last_name.element.should == @e
- last_name = REXML::Attribute.new(@name, @e)
- last_name.element.should == @e
+ last_name = REXML::Attribute.new(@name, @e)
+ last_name.element.should == @e
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/inspect_spec.rb b/spec/ruby/library/rexml/attribute/inspect_spec.rb
index 632b477cca..ffacf78de8 100644
--- a/spec/ruby/library/rexml/attribute/inspect_spec.rb
+++ b/spec/ruby/library/rexml/attribute/inspect_spec.rb
@@ -1,19 +1,22 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#inspect" do
- it "returns the name and value as a string" do
- a = REXML::Attribute.new("my_name", "my_value")
- a.inspect.should == "my_name='my_value'"
- end
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- it "accepts attributes with no value" do
- a = REXML::Attribute.new("my_name")
- a.inspect.should == "my_name=''"
- end
+ describe "REXML::Attribute#inspect" do
+ it "returns the name and value as a string" do
+ a = REXML::Attribute.new("my_name", "my_value")
+ a.inspect.should == "my_name='my_value'"
+ end
+
+ it "accepts attributes with no value" do
+ a = REXML::Attribute.new("my_name")
+ a.inspect.should == "my_name=''"
+ end
- it "does not escape text" do
- a = REXML::Attribute.new("name", "<>")
- a.inspect.should == "name='<>'"
+ it "does not escape text" do
+ a = REXML::Attribute.new("name", "<>")
+ a.inspect.should == "name='<>'"
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/namespace_spec.rb b/spec/ruby/library/rexml/attribute/namespace_spec.rb
index 9d50770735..9b0ff1e9c2 100644
--- a/spec/ruby/library/rexml/attribute/namespace_spec.rb
+++ b/spec/ruby/library/rexml/attribute/namespace_spec.rb
@@ -1,24 +1,27 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#namespace" do
- it "returns the namespace url" do
- e = REXML::Element.new("root")
- e.add_attribute REXML::Attribute.new("xmlns:ns", "http://some_uri")
- e.namespace("ns").should == "http://some_uri"
- end
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- it "returns nil if namespace is not defined" do
- e = REXML::Element.new("root")
- e.add_attribute REXML::Attribute.new("test", "value")
- e.namespace("test").should == nil
- e.namespace("ns").should == nil
- end
+ describe "REXML::Attribute#namespace" do
+ it "returns the namespace url" do
+ e = REXML::Element.new("root")
+ e.add_attribute REXML::Attribute.new("xmlns:ns", "http://some_uri")
+ e.namespace("ns").should == "http://some_uri"
+ end
+
+ it "returns nil if namespace is not defined" do
+ e = REXML::Element.new("root")
+ e.add_attribute REXML::Attribute.new("test", "value")
+ e.namespace("test").should == nil
+ e.namespace("ns").should == nil
+ end
- it "defaults arg to nil" do
- e = REXML::Element.new("root")
- e.add_attribute REXML::Attribute.new("xmlns:ns", "http://some_uri")
- e.namespace.should == ""
- e.namespace("ns").should == "http://some_uri"
+ it "defaults arg to nil" do
+ e = REXML::Element.new("root")
+ e.add_attribute REXML::Attribute.new("xmlns:ns", "http://some_uri")
+ e.namespace.should == ""
+ e.namespace("ns").should == "http://some_uri"
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/node_type_spec.rb b/spec/ruby/library/rexml/attribute/node_type_spec.rb
index 664d7cfa03..f2ba0af839 100644
--- a/spec/ruby/library/rexml/attribute/node_type_spec.rb
+++ b/spec/ruby/library/rexml/attribute/node_type_spec.rb
@@ -1,10 +1,13 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#node_type" do
- it "always returns :attribute" do
- attr = REXML::Attribute.new("foo", "bar")
- attr.node_type.should == :attribute
- REXML::Attribute.new(attr).node_type.should == :attribute
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
+
+ describe "REXML::Attribute#node_type" do
+ it "always returns :attribute" do
+ attr = REXML::Attribute.new("foo", "bar")
+ attr.node_type.should == :attribute
+ REXML::Attribute.new(attr).node_type.should == :attribute
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/prefix_spec.rb b/spec/ruby/library/rexml/attribute/prefix_spec.rb
index 2a47f74ad1..0eee50de33 100644
--- a/spec/ruby/library/rexml/attribute/prefix_spec.rb
+++ b/spec/ruby/library/rexml/attribute/prefix_spec.rb
@@ -1,18 +1,21 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#prefix" do
- it "returns the namespace of the Attribute" do
- ans = REXML::Attribute.new("ns:someattr", "some_value")
- out = REXML::Attribute.new("out:something", "some_other_value")
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- ans.prefix.should == "ns"
- out.prefix.should == "out"
- end
+ describe "REXML::Attribute#prefix" do
+ it "returns the namespace of the Attribute" do
+ ans = REXML::Attribute.new("ns:someattr", "some_value")
+ out = REXML::Attribute.new("out:something", "some_other_value")
+
+ ans.prefix.should == "ns"
+ out.prefix.should == "out"
+ end
- it "returns an empty string for Attributes with no prefixes" do
- attr = REXML::Attribute.new("foo", "bar")
+ it "returns an empty string for Attributes with no prefixes" do
+ attr = REXML::Attribute.new("foo", "bar")
- attr.prefix.should == ""
+ attr.prefix.should == ""
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/remove_spec.rb b/spec/ruby/library/rexml/attribute/remove_spec.rb
index 08d22cb6ba..c7a9904eb8 100644
--- a/spec/ruby/library/rexml/attribute/remove_spec.rb
+++ b/spec/ruby/library/rexml/attribute/remove_spec.rb
@@ -1,20 +1,23 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#remove" do
- before :each do
- @e = REXML::Element.new "Root"
- @attr = REXML::Attribute.new("foo", "bar")
- end
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- it "deletes this Attribute from parent" do
- @e.add_attribute(@attr)
- @e.attributes["foo"].should_not == nil
- @attr.remove
- @e.attributes["foo"].should == nil
- end
+ describe "REXML::Attribute#remove" do
+ before :each do
+ @e = REXML::Element.new "Root"
+ @attr = REXML::Attribute.new("foo", "bar")
+ end
+
+ it "deletes this Attribute from parent" do
+ @e.add_attribute(@attr)
+ @e.attributes["foo"].should_not == nil
+ @attr.remove
+ @e.attributes["foo"].should == nil
+ end
- it "does not anything if element has no parent" do
- -> {@attr.remove}.should_not raise_error(Exception)
+ it "does not anything if element has no parent" do
+ -> {@attr.remove}.should_not raise_error(Exception)
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/to_s_spec.rb b/spec/ruby/library/rexml/attribute/to_s_spec.rb
index e1ce48ec33..00e7e96648 100644
--- a/spec/ruby/library/rexml/attribute/to_s_spec.rb
+++ b/spec/ruby/library/rexml/attribute/to_s_spec.rb
@@ -1,14 +1,17 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#to_s" do
- it "returns the value of the Attribute" do
- REXML::Attribute.new("name", "some_value").to_s.should == "some_value"
- end
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
+
+ describe "REXML::Attribute#to_s" do
+ it "returns the value of the Attribute" do
+ REXML::Attribute.new("name", "some_value").to_s.should == "some_value"
+ end
- it "returns the escaped value if it was created from Attribute" do
- orig = REXML::Attribute.new("name", "<&>")
- copy = REXML::Attribute.new(orig)
- copy.to_s.should == "&lt;&amp;&gt;"
+ it "returns the escaped value if it was created from Attribute" do
+ orig = REXML::Attribute.new("name", "<&>")
+ copy = REXML::Attribute.new(orig)
+ copy.to_s.should == "&lt;&amp;&gt;"
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/to_string_spec.rb b/spec/ruby/library/rexml/attribute/to_string_spec.rb
index 420913afeb..f26c5b85f0 100644
--- a/spec/ruby/library/rexml/attribute/to_string_spec.rb
+++ b/spec/ruby/library/rexml/attribute/to_string_spec.rb
@@ -1,14 +1,17 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#to_string" do
- it "returns the attribute as XML" do
- attr = REXML::Attribute.new("name", "value")
- attr_empty = REXML::Attribute.new("name")
- attr_ns = REXML::Attribute.new("xmlns:ns", "http://uri")
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- attr.to_string.should == "name='value'"
- attr_empty.to_string.should == "name=''"
- attr_ns.to_string.should == "xmlns:ns='http://uri'"
+ describe "REXML::Attribute#to_string" do
+ it "returns the attribute as XML" do
+ attr = REXML::Attribute.new("name", "value")
+ attr_empty = REXML::Attribute.new("name")
+ attr_ns = REXML::Attribute.new("xmlns:ns", "http://uri")
+
+ attr.to_string.should == "name='value'"
+ attr_empty.to_string.should == "name=''"
+ attr_ns.to_string.should == "xmlns:ns='http://uri'"
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/value_spec.rb b/spec/ruby/library/rexml/attribute/value_spec.rb
index 7763976881..cf6d1deef4 100644
--- a/spec/ruby/library/rexml/attribute/value_spec.rb
+++ b/spec/ruby/library/rexml/attribute/value_spec.rb
@@ -1,14 +1,17 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#value" do
- it "returns the value of the Attribute unnormalized" do
- attr = REXML::Attribute.new("name", "value")
- attr_ents = REXML::Attribute.new("name", "<&>")
- attr_empty = REXML::Attribute.new("name")
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- attr.value.should == "value"
- attr_ents.value.should == "<&>"
- attr_empty.value.should == ""
+ describe "REXML::Attribute#value" do
+ it "returns the value of the Attribute unnormalized" do
+ attr = REXML::Attribute.new("name", "value")
+ attr_ents = REXML::Attribute.new("name", "<&>")
+ attr_empty = REXML::Attribute.new("name")
+
+ attr.value.should == "value"
+ attr_ents.value.should == "<&>"
+ attr_empty.value.should == ""
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/write_spec.rb b/spec/ruby/library/rexml/attribute/write_spec.rb
index 7ada7460f9..f69689e724 100644
--- a/spec/ruby/library/rexml/attribute/write_spec.rb
+++ b/spec/ruby/library/rexml/attribute/write_spec.rb
@@ -1,23 +1,26 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#write" do
- before :each do
- @attr = REXML::Attribute.new("name", "Charlotte")
- @s = ""
- end
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- it "writes the name and value to output" do
- @attr.write(@s)
- @s.should == "name='Charlotte'"
- end
+ describe "REXML::Attribute#write" do
+ before :each do
+ @attr = REXML::Attribute.new("name", "Charlotte")
+ @s = ""
+ end
+
+ it "writes the name and value to output" do
+ @attr.write(@s)
+ @s.should == "name='Charlotte'"
+ end
- it "currently ignores the second argument" do
- @attr.write(@s, 3)
- @s.should == "name='Charlotte'"
+ it "currently ignores the second argument" do
+ @attr.write(@s, 3)
+ @s.should == "name='Charlotte'"
- @s = ""
- @attr.write(@s, "foo")
- @s.should == "name='Charlotte'"
+ @s = ""
+ @attr.write(@s, "foo")
+ @s.should == "name='Charlotte'"
+ end
end
end
diff --git a/spec/ruby/library/rexml/attribute/xpath_spec.rb b/spec/ruby/library/rexml/attribute/xpath_spec.rb
index 8335e0a8ef..945e76280f 100644
--- a/spec/ruby/library/rexml/attribute/xpath_spec.rb
+++ b/spec/ruby/library/rexml/attribute/xpath_spec.rb
@@ -1,19 +1,22 @@
require_relative '../../../spec_helper'
-require 'rexml/document'
-describe "REXML::Attribute#xpath" do
+ruby_version_is ''...'2.8' do
+ require 'rexml/document'
- before :each do
- @e = REXML::Element.new "root"
- @attr = REXML::Attribute.new("year", "1989")
- end
+ describe "REXML::Attribute#xpath" do
- it "returns the path for Attribute" do
- @e.add_attribute @attr
- @attr.xpath.should == "root/@year"
- end
+ before :each do
+ @e = REXML::Element.new "root"
+ @attr = REXML::Attribute.new("year", "1989")
+ end
+
+ it "returns the path for Attribute" do
+ @e.add_attribute @attr
+ @attr.xpath.should == "root/@year"
+ end
- it "raises an error if attribute has no parent" do
- -> { @attr.xpath }.should raise_error(Exception)
+ it "raises an error if attribute has no parent" do
+ -> { @attr.xpath }.should raise_error(Exception)
+ end
end
end