mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@241f9e7
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e59bf54b3a
commit
e87fb88be8
142 changed files with 1165 additions and 1078 deletions
|
@ -199,6 +199,65 @@ describe "Module#autoload" do
|
|||
end
|
||||
end
|
||||
|
||||
describe "the autoload is removed when the same file is required directly without autoload" do
|
||||
before :each do
|
||||
module ModuleSpecs::Autoload
|
||||
autoload :RequiredDirectly, fixture(__FILE__, "autoload_required_directly.rb")
|
||||
end
|
||||
@path = fixture(__FILE__, "autoload_required_directly.rb")
|
||||
@check = -> {
|
||||
[
|
||||
defined?(ModuleSpecs::Autoload::RequiredDirectly),
|
||||
ModuleSpecs::Autoload.autoload?(:RequiredDirectly)
|
||||
]
|
||||
}
|
||||
ScratchPad.record @check
|
||||
end
|
||||
|
||||
after :each do
|
||||
ModuleSpecs::Autoload.send(:remove_const, :RequiredDirectly)
|
||||
end
|
||||
|
||||
it "with a full path" do
|
||||
@check.call.should == ["constant", @path]
|
||||
require @path
|
||||
ScratchPad.recorded.should == [nil, nil]
|
||||
@check.call.should == ["constant", nil]
|
||||
end
|
||||
|
||||
it "with a relative path" do
|
||||
@check.call.should == ["constant", @path]
|
||||
$:.push File.dirname(@path)
|
||||
begin
|
||||
require "autoload_required_directly.rb"
|
||||
ensure
|
||||
$:.pop
|
||||
end
|
||||
ScratchPad.recorded.should == [nil, nil]
|
||||
@check.call.should == ["constant", nil]
|
||||
end
|
||||
|
||||
it "in a nested require" do
|
||||
nested = fixture(__FILE__, "autoload_required_directly_nested.rb")
|
||||
nested_require = -> {
|
||||
result = nil
|
||||
ScratchPad.record -> {
|
||||
result = [@check.call, Thread.new { @check.call }.value]
|
||||
}
|
||||
require nested
|
||||
result
|
||||
}
|
||||
ScratchPad.record nested_require
|
||||
|
||||
@check.call.should == ["constant", @path]
|
||||
require @path
|
||||
cur, other = ScratchPad.recorded
|
||||
cur.should == [nil, nil]
|
||||
other.should == [nil, nil]
|
||||
@check.call.should == ["constant", nil]
|
||||
end
|
||||
end
|
||||
|
||||
describe "during the autoload before the constant is assigned" do
|
||||
before :each do
|
||||
@path = fixture(__FILE__, "autoload_during_autoload.rb")
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
block = ScratchPad.recorded
|
||||
ScratchPad.record(block.call)
|
||||
|
||||
module ModuleSpecs::Autoload
|
||||
class RequiredDirectly
|
||||
end
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
ScratchPad.recorded.call
|
Loading…
Add table
Add a link
Reference in a new issue