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
10
spec/ruby/library/rexml/text/append_spec.rb
Normal file
10
spec/ruby/library/rexml/text/append_spec.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#<<" do
|
||||
it "appends a string to this text node" do
|
||||
text = REXML::Text.new("foo")
|
||||
text << "bar"
|
||||
text.should == "foobar"
|
||||
end
|
||||
end
|
10
spec/ruby/library/rexml/text/clone_spec.rb
Normal file
10
spec/ruby/library/rexml/text/clone_spec.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#clone" do
|
||||
it "creates a copy of this node" do
|
||||
text = REXML::Text.new("foo")
|
||||
text.clone.should == "foo"
|
||||
text.clone.should == text
|
||||
end
|
||||
end
|
25
spec/ruby/library/rexml/text/comparison_spec.rb
Normal file
25
spec/ruby/library/rexml/text/comparison_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#<=>" do
|
||||
before :each do
|
||||
@first = REXML::Text.new("abc")
|
||||
@last = REXML::Text.new("def")
|
||||
end
|
||||
|
||||
it "returns -1 if lvalue is less than rvalue" do
|
||||
val = @first <=> @last
|
||||
val.should == -1
|
||||
end
|
||||
|
||||
it "returns -1 if lvalue is greater than rvalue" do
|
||||
val = @last <=> @first
|
||||
val.should == 1
|
||||
end
|
||||
|
||||
it "returns 0 if both values are equal" do
|
||||
tmp = REXML::Text.new("tmp")
|
||||
val = tmp <=> tmp
|
||||
val.should == 0
|
||||
end
|
||||
end
|
12
spec/ruby/library/rexml/text/empty_spec.rb
Normal file
12
spec/ruby/library/rexml/text/empty_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#empty?" do
|
||||
it "returns true if the text is empty" do
|
||||
REXML::Text.new("").empty?.should == true
|
||||
end
|
||||
|
||||
it "returns false if the text is not empty" do
|
||||
REXML::Text.new("some_text").empty?.should == false
|
||||
end
|
||||
end
|
24
spec/ruby/library/rexml/text/indent_text_spec.rb
Normal file
24
spec/ruby/library/rexml/text/indent_text_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#indent_text" do
|
||||
before :each do
|
||||
@t = REXML::Text.new("")
|
||||
end
|
||||
it "indents a string with default parameters" do
|
||||
@t.indent_text("foo").should == "\tfoo"
|
||||
end
|
||||
|
||||
it "accepts a custom indentation level as second argument" do
|
||||
@t.indent_text("foo", 2, "\t", true).should == "\t\tfoo"
|
||||
end
|
||||
|
||||
it "accepts a custom separator as third argument" do
|
||||
@t.indent_text("foo", 1, "\n", true).should == "\nfoo"
|
||||
end
|
||||
|
||||
it "accepts a fourth parameter to skip the first line" do
|
||||
@t.indent_text("foo", 1, "\t", false).should == "foo"
|
||||
end
|
||||
end
|
||||
|
8
spec/ruby/library/rexml/text/inspect_spec.rb
Normal file
8
spec/ruby/library/rexml/text/inspect_spec.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#inspect" do
|
||||
it "inspects the string attribute as a string" do
|
||||
REXML::Text.new("a text").inspect.should == "a text".inspect
|
||||
end
|
||||
end
|
49
spec/ruby/library/rexml/text/new_spec.rb
Normal file
49
spec/ruby/library/rexml/text/new_spec.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text.new" do
|
||||
|
||||
it "creates a Text child node with no parent" do
|
||||
t = REXML::Text.new("test")
|
||||
t.should be_kind_of(REXML::Child)
|
||||
t.should == "test"
|
||||
t.parent.should == nil
|
||||
end
|
||||
|
||||
it "respects whitespace if second argument is true" do
|
||||
t = REXML::Text.new("testing whitespace", true)
|
||||
t.should == "testing whitespace"
|
||||
t = REXML::Text.new(" ", true)
|
||||
t.should == " "
|
||||
end
|
||||
|
||||
it "receives a parent as third argument" do
|
||||
e = REXML::Element.new("root")
|
||||
t = REXML::Text.new("test", false, e)
|
||||
t.parent.should == e
|
||||
e.to_s.should == "<root>test</root>"
|
||||
end
|
||||
|
||||
it "expects escaped text if raw is true" do
|
||||
t = REXML::Text.new("<&>", false, nil, true)
|
||||
t.should == "<&>"
|
||||
|
||||
lambda{ REXML::Text.new("<&>", false, nil, true)}.should raise_error(Exception)
|
||||
end
|
||||
|
||||
it "uses raw value of the parent if raw is nil" do
|
||||
e1 = REXML::Element.new("root", nil, { raw: :all})
|
||||
lambda {REXML::Text.new("<&>", false, e1)}.should raise_error(Exception)
|
||||
|
||||
e2 = REXML::Element.new("root", nil, { raw: []})
|
||||
e2.raw.should be_false
|
||||
t1 = REXML::Text.new("<&>", false, e2)
|
||||
t1.should == "<&>"
|
||||
end
|
||||
|
||||
it "escapes the values if raw is false" do
|
||||
t = REXML::Text.new("<&>", false, nil, false)
|
||||
t.should == "<&>"
|
||||
end
|
||||
end
|
||||
|
8
spec/ruby/library/rexml/text/node_type_spec.rb
Normal file
8
spec/ruby/library/rexml/text/node_type_spec.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#node_type" do
|
||||
it "returns :text" do
|
||||
REXML::Text.new("test").node_type.should == :text
|
||||
end
|
||||
end
|
8
spec/ruby/library/rexml/text/normalize_spec.rb
Normal file
8
spec/ruby/library/rexml/text/normalize_spec.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text.normalize" do
|
||||
it "escapes a string with <, >, &, ' and \" " do
|
||||
REXML::Text.normalize("< > & \" '").should == "< > & " '"
|
||||
end
|
||||
end
|
13
spec/ruby/library/rexml/text/read_with_substitution_spec.rb
Normal file
13
spec/ruby/library/rexml/text/read_with_substitution_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text.read_with_substitution" do
|
||||
it "reads a text and escapes entities" do
|
||||
REXML::Text.read_with_substitution("< > & " '").should == "< > & \" '"
|
||||
end
|
||||
|
||||
it "accepts an regex for invalid expressions and raises an error if text matches" do
|
||||
lambda {REXML::Text.read_with_substitution("this is illegal", /illegal/)}.should raise_error(Exception)
|
||||
end
|
||||
end
|
||||
|
18
spec/ruby/library/rexml/text/to_s_spec.rb
Normal file
18
spec/ruby/library/rexml/text/to_s_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#to_s" do
|
||||
it "returns the string of this Text node" do
|
||||
u = REXML::Text.new("sean russell", false, nil, true)
|
||||
u.to_s.should == "sean russell"
|
||||
|
||||
t = REXML::Text.new("some test text")
|
||||
t.to_s.should == "some test text"
|
||||
end
|
||||
|
||||
it "escapes the text" do
|
||||
t = REXML::Text.new("& < >")
|
||||
t.to_s.should == "& < >"
|
||||
end
|
||||
end
|
||||
|
8
spec/ruby/library/rexml/text/unnormalize_spec.rb
Normal file
8
spec/ruby/library/rexml/text/unnormalize_spec.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text.unnormalize" do
|
||||
it "unescapes a string with the values defined in SETUTITSBUS" do
|
||||
REXML::Text.unnormalize("< > & " '").should == "< > & \" '"
|
||||
end
|
||||
end
|
37
spec/ruby/library/rexml/text/value_spec.rb
Normal file
37
spec/ruby/library/rexml/text/value_spec.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#value" do
|
||||
it "returns the text value of this node" do
|
||||
REXML::Text.new("test").value.should == "test"
|
||||
end
|
||||
|
||||
it "does not escape entities" do
|
||||
REXML::Text.new("& \"").value.should == "& \""
|
||||
end
|
||||
|
||||
it "follows the respect_whitespace attribute" do
|
||||
REXML::Text.new("test bar", false).value.should == "test bar"
|
||||
REXML::Text.new("test bar", true).value.should == "test bar"
|
||||
end
|
||||
|
||||
it "ignores the raw attribute" do
|
||||
REXML::Text.new("sean russell", false, nil, true).value.should == "sean russell"
|
||||
end
|
||||
end
|
||||
|
||||
describe "REXML::Text#value=" do
|
||||
before :each do
|
||||
@t = REXML::Text.new("new")
|
||||
end
|
||||
|
||||
it "sets the text of the node" do
|
||||
@t.value = "another text"
|
||||
@t.to_s.should == "another text"
|
||||
end
|
||||
|
||||
it "escapes entities" do
|
||||
@t.value = "<a>"
|
||||
@t.to_s.should == "<a>"
|
||||
end
|
||||
end
|
21
spec/ruby/library/rexml/text/wrap_spec.rb
Normal file
21
spec/ruby/library/rexml/text/wrap_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#wrap" do
|
||||
before :each do
|
||||
@t = REXML::Text.new("abc def")
|
||||
end
|
||||
|
||||
it "wraps the text at width" do
|
||||
@t.wrap("abc def", 3, false).should == "abc\ndef"
|
||||
end
|
||||
|
||||
it "returns the string if width is greater than the size of the string" do
|
||||
@t.wrap("abc def", 10, false).should == "abc def"
|
||||
end
|
||||
|
||||
it "takes a newline at the beginning option as the third parameter" do
|
||||
@t.wrap("abc def", 3, true).should == "\nabc\ndef"
|
||||
end
|
||||
end
|
||||
|
33
spec/ruby/library/rexml/text/write_with_substitution_spec.rb
Normal file
33
spec/ruby/library/rexml/text/write_with_substitution_spec.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require 'rexml/document'
|
||||
|
||||
describe "REXML::Text#write_with_substitution" do
|
||||
before :each do
|
||||
@t = REXML::Text.new("test")
|
||||
@f = tmp("rexml_spec")
|
||||
@file = File.open(@f, "w+")
|
||||
end
|
||||
|
||||
after :each do
|
||||
@file.close
|
||||
rm_r @f
|
||||
end
|
||||
|
||||
it "writes out the input to a String" do
|
||||
s = ""
|
||||
@t.write_with_substitution(s, "some text")
|
||||
s.should == "some text"
|
||||
end
|
||||
|
||||
it "writes out the input to an IO" do
|
||||
@t.write_with_substitution(@file, "some text")
|
||||
@file.rewind
|
||||
@file.gets.should == "some text"
|
||||
end
|
||||
|
||||
it "escapes characters" do
|
||||
@t.write_with_substitution(@file, "& < >")
|
||||
@file.rewind
|
||||
@file.gets.should == "& < >"
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue