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
28
spec/ruby/library/readline/history/append_spec.rb
Normal file
28
spec/ruby/library/readline/history/append_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY.<<" do
|
||||
it "appends the given Object to the history" do
|
||||
Readline::HISTORY << "1"
|
||||
Readline::HISTORY.size.should == 1
|
||||
|
||||
Readline::HISTORY << "2"
|
||||
Readline::HISTORY.size.should == 2
|
||||
|
||||
Readline::HISTORY.pop.should == "2"
|
||||
Readline::HISTORY.pop.should == "1"
|
||||
end
|
||||
|
||||
it "tries to convert the passed Object to a String using #to_str" do
|
||||
obj = mock("Converted to String")
|
||||
obj.should_receive(:to_str).and_return("converted")
|
||||
|
||||
Readline::HISTORY << obj
|
||||
Readline::HISTORY.pop.should == "converted"
|
||||
end
|
||||
|
||||
it "raises a TypeError when the passed Object can't be converted to a String" do
|
||||
lambda { Readline::HISTORY << mock("Object") }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
end
|
45
spec/ruby/library/readline/history/delete_at_spec.rb
Normal file
45
spec/ruby/library/readline/history/delete_at_spec.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY.delete_at" do
|
||||
it "deletes and returns the history entry at the specified index" do
|
||||
Readline::HISTORY.push("1", "2", "3")
|
||||
|
||||
Readline::HISTORY.delete_at(1).should == "2"
|
||||
Readline::HISTORY.size.should == 2
|
||||
|
||||
Readline::HISTORY.delete_at(1).should == "3"
|
||||
Readline::HISTORY.size.should == 1
|
||||
|
||||
Readline::HISTORY.delete_at(0).should == "1"
|
||||
Readline::HISTORY.size.should == 0
|
||||
|
||||
|
||||
Readline::HISTORY.push("1", "2", "3", "4")
|
||||
|
||||
Readline::HISTORY.delete_at(-2).should == "3"
|
||||
Readline::HISTORY.size.should == 3
|
||||
|
||||
Readline::HISTORY.delete_at(-2).should == "2"
|
||||
Readline::HISTORY.size.should == 2
|
||||
|
||||
Readline::HISTORY.delete_at(0).should == "1"
|
||||
Readline::HISTORY.size.should == 1
|
||||
|
||||
Readline::HISTORY.delete_at(0).should == "4"
|
||||
Readline::HISTORY.size.should == 0
|
||||
end
|
||||
|
||||
it "raises an IndexError when the given index is greater than the history size" do
|
||||
lambda { Readline::HISTORY.delete_at(10) }.should raise_error(IndexError)
|
||||
lambda { Readline::HISTORY.delete_at(-10) }.should raise_error(IndexError)
|
||||
end
|
||||
|
||||
it "taints the returned strings" do
|
||||
Readline::HISTORY.push("1", "2", "3")
|
||||
Readline::HISTORY.delete_at(0).tainted?.should be_true
|
||||
Readline::HISTORY.delete_at(0).tainted?.should be_true
|
||||
Readline::HISTORY.delete_at(0).tainted?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
29
spec/ruby/library/readline/history/each_spec.rb
Normal file
29
spec/ruby/library/readline/history/each_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY.each" do
|
||||
before :each do
|
||||
Readline::HISTORY.push("1", "2", "3")
|
||||
end
|
||||
|
||||
after :each do
|
||||
Readline::HISTORY.pop
|
||||
Readline::HISTORY.pop
|
||||
Readline::HISTORY.pop
|
||||
end
|
||||
|
||||
it "yields each item in the history" do
|
||||
result = []
|
||||
Readline::HISTORY.each do |x|
|
||||
result << x
|
||||
end
|
||||
result.should == ["1", "2", "3"]
|
||||
end
|
||||
|
||||
it "yields tainted Objects" do
|
||||
Readline::HISTORY.each do |x|
|
||||
x.tainted?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
40
spec/ruby/library/readline/history/element_reference_spec.rb
Normal file
40
spec/ruby/library/readline/history/element_reference_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY.[]" do
|
||||
before :each do
|
||||
Readline::HISTORY.push("1", "2", "3")
|
||||
end
|
||||
|
||||
after :each do
|
||||
Readline::HISTORY.pop
|
||||
Readline::HISTORY.pop
|
||||
Readline::HISTORY.pop
|
||||
end
|
||||
|
||||
it "returns tainted objects" do
|
||||
Readline::HISTORY[0].tainted?.should be_true
|
||||
Readline::HISTORY[1].tainted?.should be_true
|
||||
end
|
||||
|
||||
it "returns the history item at the passed index" do
|
||||
Readline::HISTORY[0].should == "1"
|
||||
Readline::HISTORY[1].should == "2"
|
||||
Readline::HISTORY[2].should == "3"
|
||||
|
||||
Readline::HISTORY[-1].should == "3"
|
||||
Readline::HISTORY[-2].should == "2"
|
||||
Readline::HISTORY[-3].should == "1"
|
||||
end
|
||||
|
||||
it "raises an IndexError when there is no item at the passed index" do
|
||||
lambda { Readline::HISTORY[-10] }.should raise_error(IndexError)
|
||||
lambda { Readline::HISTORY[-9] }.should raise_error(IndexError)
|
||||
lambda { Readline::HISTORY[-8] }.should raise_error(IndexError)
|
||||
|
||||
lambda { Readline::HISTORY[8] }.should raise_error(IndexError)
|
||||
lambda { Readline::HISTORY[9] }.should raise_error(IndexError)
|
||||
lambda { Readline::HISTORY[10] }.should raise_error(IndexError)
|
||||
end
|
||||
end
|
||||
end
|
35
spec/ruby/library/readline/history/element_set_spec.rb
Normal file
35
spec/ruby/library/readline/history/element_set_spec.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY.[]=" do
|
||||
before :each do
|
||||
Readline::HISTORY.push("1", "2", "3")
|
||||
end
|
||||
|
||||
after :each do
|
||||
Readline::HISTORY.pop
|
||||
Readline::HISTORY.pop
|
||||
Readline::HISTORY.pop
|
||||
end
|
||||
|
||||
it "returns the new value for the passed index" do
|
||||
(Readline::HISTORY[1] = "second test").should == "second test"
|
||||
end
|
||||
|
||||
it "raises an IndexError when there is no item at the passed positive index" do
|
||||
lambda { Readline::HISTORY[10] = "test" }.should raise_error(IndexError)
|
||||
end
|
||||
|
||||
it "sets the item at the given index" do
|
||||
Readline::HISTORY[0] = "test"
|
||||
Readline::HISTORY[0].should == "test"
|
||||
|
||||
Readline::HISTORY[1] = "second test"
|
||||
Readline::HISTORY[1].should == "second test"
|
||||
end
|
||||
|
||||
it "raises an IndexError when there is no item at the passed negative index" do
|
||||
lambda { Readline::HISTORY[10] = "test" }.should raise_error(IndexError)
|
||||
end
|
||||
end
|
||||
end
|
13
spec/ruby/library/readline/history/empty_spec.rb
Normal file
13
spec/ruby/library/readline/history/empty_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY.empty?" do
|
||||
it "returns true when the history is empty" do
|
||||
Readline::HISTORY.should be_empty
|
||||
Readline::HISTORY.push("test")
|
||||
Readline::HISTORY.should_not be_empty
|
||||
Readline::HISTORY.pop
|
||||
Readline::HISTORY.should be_empty
|
||||
end
|
||||
end
|
||||
end
|
9
spec/ruby/library/readline/history/history_spec.rb
Normal file
9
spec/ruby/library/readline/history/history_spec.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY" do
|
||||
it "is extended with the Enumerable module" do
|
||||
Readline::HISTORY.should be_kind_of(Enumerable)
|
||||
end
|
||||
end
|
||||
end
|
9
spec/ruby/library/readline/history/length_spec.rb
Normal file
9
spec/ruby/library/readline/history/length_spec.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
require File.expand_path('../shared/size', __FILE__)
|
||||
|
||||
describe "Readline::HISTORY.length" do
|
||||
it_behaves_like :readline_history_size, :length
|
||||
end
|
||||
end
|
30
spec/ruby/library/readline/history/pop_spec.rb
Normal file
30
spec/ruby/library/readline/history/pop_spec.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY.pop" do
|
||||
it "returns nil when the history is empty" do
|
||||
Readline::HISTORY.pop.should be_nil
|
||||
end
|
||||
|
||||
it "returns and removes the last item from the history" do
|
||||
Readline::HISTORY.push("1", "2", "3")
|
||||
Readline::HISTORY.size.should == 3
|
||||
|
||||
Readline::HISTORY.pop.should == "3"
|
||||
Readline::HISTORY.size.should == 2
|
||||
|
||||
Readline::HISTORY.pop.should == "2"
|
||||
Readline::HISTORY.size.should == 1
|
||||
|
||||
Readline::HISTORY.pop.should == "1"
|
||||
Readline::HISTORY.size.should == 0
|
||||
end
|
||||
|
||||
it "taints the returned strings" do
|
||||
Readline::HISTORY.push("1", "2", "3")
|
||||
Readline::HISTORY.pop.tainted?.should be_true
|
||||
Readline::HISTORY.pop.tainted?.should be_true
|
||||
Readline::HISTORY.pop.tainted?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
26
spec/ruby/library/readline/history/push_spec.rb
Normal file
26
spec/ruby/library/readline/history/push_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY.push" do
|
||||
it "pushes all passed Objects into the history" do
|
||||
Readline::HISTORY.push("1", "2", "3")
|
||||
Readline::HISTORY.size.should == 3
|
||||
|
||||
Readline::HISTORY.pop.should == "3"
|
||||
Readline::HISTORY.pop.should == "2"
|
||||
Readline::HISTORY.pop.should == "1"
|
||||
end
|
||||
|
||||
it "tries to convert the passed Object to a String using #to_str" do
|
||||
obj = mock("Converted to String")
|
||||
obj.should_receive(:to_str).and_return("converted")
|
||||
|
||||
Readline::HISTORY.push(obj)
|
||||
Readline::HISTORY.pop.should == "converted"
|
||||
end
|
||||
|
||||
it "raises a TypeError when the passed Object can't be converted to a String" do
|
||||
lambda { Readline::HISTORY.push(mock("Object")) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
end
|
14
spec/ruby/library/readline/history/shared/size.rb
Normal file
14
spec/ruby/library/readline/history/shared/size.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
describe :readline_history_size, shared: true do
|
||||
it "returns the size of the history" do
|
||||
Readline::HISTORY.send(@method).should == 0
|
||||
Readline::HISTORY.push("1", "2", "")
|
||||
Readline::HISTORY.send(@method).should == 3
|
||||
|
||||
Readline::HISTORY.pop
|
||||
Readline::HISTORY.send(@method).should == 2
|
||||
|
||||
Readline::HISTORY.pop
|
||||
Readline::HISTORY.pop
|
||||
Readline::HISTORY.send(@method).should == 0
|
||||
end
|
||||
end
|
30
spec/ruby/library/readline/history/shift_spec.rb
Normal file
30
spec/ruby/library/readline/history/shift_spec.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY.shift" do
|
||||
it "returns nil when the history is empty" do
|
||||
Readline::HISTORY.shift.should be_nil
|
||||
end
|
||||
|
||||
it "returns and removes the first item from the history" do
|
||||
Readline::HISTORY.push("1", "2", "3")
|
||||
Readline::HISTORY.size.should == 3
|
||||
|
||||
Readline::HISTORY.shift.should == "1"
|
||||
Readline::HISTORY.size.should == 2
|
||||
|
||||
Readline::HISTORY.shift.should == "2"
|
||||
Readline::HISTORY.size.should == 1
|
||||
|
||||
Readline::HISTORY.shift.should == "3"
|
||||
Readline::HISTORY.size.should == 0
|
||||
end
|
||||
|
||||
it "taints the returned strings" do
|
||||
Readline::HISTORY.push("1", "2", "3")
|
||||
Readline::HISTORY.shift.tainted?.should be_true
|
||||
Readline::HISTORY.shift.tainted?.should be_true
|
||||
Readline::HISTORY.shift.tainted?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
9
spec/ruby/library/readline/history/size_spec.rb
Normal file
9
spec/ruby/library/readline/history/size_spec.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
require File.expand_path('../shared/size', __FILE__)
|
||||
|
||||
describe "Readline::HISTORY.size" do
|
||||
it_behaves_like :readline_history_size, :size
|
||||
end
|
||||
end
|
9
spec/ruby/library/readline/history/to_s_spec.rb
Normal file
9
spec/ruby/library/readline/history/to_s_spec.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require File.expand_path('../../spec_helper', __FILE__)
|
||||
|
||||
with_feature :readline do
|
||||
describe "Readline::HISTORY.to_s" do
|
||||
it "returns 'HISTORY'" do
|
||||
Readline::HISTORY.to_s.should == "HISTORY"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue