1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-07-27 12:40:09 +02:00
parent a06301b103
commit 5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions

View file

@ -21,7 +21,7 @@ describe :kernel_require_basic, shared: true do
it "raises a LoadError if the file does not exist" do
path = File.expand_path "nonexistent.rb", CODE_LOADING_DIR
File.exist?(path).should be_false
lambda { @object.send(@method, path) }.should raise_error(LoadError)
-> { @object.send(@method, path) }.should raise_error(LoadError)
ScratchPad.recorded.should == []
end
@ -42,7 +42,7 @@ describe :kernel_require_basic, shared: true do
it "raises a LoadError" do
File.exist?(@path).should be_true
lambda { @object.send(@method, @path) }.should raise_error(LoadError)
-> { @object.send(@method, @path) }.should raise_error(LoadError)
end
end
end
@ -57,19 +57,19 @@ describe :kernel_require_basic, shared: true do
end
it "raises a TypeError if passed nil" do
lambda { @object.send(@method, nil) }.should raise_error(TypeError)
-> { @object.send(@method, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if passed a Fixnum" do
lambda { @object.send(@method, 42) }.should raise_error(TypeError)
-> { @object.send(@method, 42) }.should raise_error(TypeError)
end
it "raises a TypeError if passed an Array" do
lambda { @object.send(@method, []) }.should raise_error(TypeError)
-> { @object.send(@method, []) }.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that does not provide #to_str" do
lambda { @object.send(@method, mock("not a filename")) }.should raise_error(TypeError)
-> { @object.send(@method, mock("not a filename")) }.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that has #to_s but not #to_str" do
@ -77,14 +77,14 @@ describe :kernel_require_basic, shared: true do
name.stub!(:to_s).and_return("load_fixture.rb")
$LOAD_PATH << "."
Dir.chdir CODE_LOADING_DIR do
lambda { @object.send(@method, name) }.should raise_error(TypeError)
-> { @object.send(@method, name) }.should raise_error(TypeError)
end
end
it "raises a TypeError if #to_str does not return a String" do
name = mock("#to_str returns nil")
name.should_receive(:to_str).at_least(1).times.and_return(nil)
lambda { @object.send(@method, name) }.should raise_error(TypeError)
-> { @object.send(@method, name) }.should raise_error(TypeError)
end
it "calls #to_path on non-String objects" do
@ -170,7 +170,7 @@ describe :kernel_require_basic, shared: true do
it "does not resolve a ./ relative path against $LOAD_PATH entries" do
$LOAD_PATH << CODE_LOADING_DIR
lambda do
-> do
@object.send(@method, "./load_fixture.rb")
end.should raise_error(LoadError)
ScratchPad.recorded.should == []
@ -178,7 +178,7 @@ describe :kernel_require_basic, shared: true do
it "does not resolve a ../ relative path against $LOAD_PATH entries" do
$LOAD_PATH << CODE_LOADING_DIR
lambda do
-> do
@object.send(@method, "../code/load_fixture.rb")
end.should raise_error(LoadError)
ScratchPad.recorded.should == []
@ -208,14 +208,14 @@ describe :kernel_require, shared: true do
# intentional for security reasons.
it "does not load a bare filename unless the current working directory is in $LOAD_PATH" do
Dir.chdir CODE_LOADING_DIR do
lambda { @object.require("load_fixture.rb") }.should raise_error(LoadError)
-> { @object.require("load_fixture.rb") }.should raise_error(LoadError)
ScratchPad.recorded.should == []
end
end
it "does not load a relative path unless the current working directory is in $LOAD_PATH" do
Dir.chdir File.dirname(CODE_LOADING_DIR) do
lambda do
-> do
@object.require("code/load_fixture.rb")
end.should raise_error(LoadError)
ScratchPad.recorded.should == []
@ -381,7 +381,7 @@ describe :kernel_require, shared: true do
it "does not store the path if the load fails" do
$LOAD_PATH << CODE_LOADING_DIR
saved_loaded_features = $LOADED_FEATURES.dup
lambda { @object.require("raise_fixture.rb") }.should raise_error(RuntimeError)
-> { @object.require("raise_fixture.rb") }.should raise_error(RuntimeError)
$LOADED_FEATURES.should == saved_loaded_features
end
@ -683,7 +683,7 @@ describe :kernel_require, shared: true do
Thread.current[:wait_for] = t2
Thread.current[:con_raise] = true
lambda {
-> {
@object.require(@path)
}.should raise_error(RuntimeError)
@ -724,7 +724,7 @@ describe :kernel_require, shared: true do
t1 = Thread.new do
Thread.current[:con_raise] = true
lambda {
-> {
@object.require(@path)
}.should raise_error(RuntimeError)
@ -764,7 +764,7 @@ describe :kernel_require, shared: true do
it "stores the missing path in a LoadError object" do
path = "abcd1234"
lambda {
-> {
@object.send(@method, path)
}.should raise_error(LoadError) { |e|
e.path.should == path