File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ main = self
2
+
1
3
describe :kernel_load , shared : true do
2
4
before :each do
3
5
CodeLoadingSpecs . spec_setup
104
106
ScratchPad . recorded . first . should equal ( String )
105
107
end
106
108
109
+ it "sets self as a copy of the top-level main" do
110
+ path = File . expand_path "wrap_fixture.rb" , CODE_LOADING_DIR
111
+ @object . load ( path , true )
112
+
113
+ top_level = ScratchPad . recorded . last
114
+ top_level . to_s . should == "main"
115
+ top_level . should_not equal ( main )
116
+ top_level . should be_an_instance_of ( Object )
117
+ end
118
+
119
+ it "includes modules included in main's singleton class in self's class" do
120
+ mod = Module . new
121
+ main . extend ( mod )
122
+
123
+ main_ancestors = main . singleton_class . ancestors [ 1 ..-1 ]
124
+ main_ancestors . first . should == mod
125
+
126
+ path = File . expand_path "wrap_fixture.rb" , CODE_LOADING_DIR
127
+ @object . load ( path , true )
128
+
129
+ top_level = ScratchPad . recorded . last
130
+ top_level_ancestors = top_level . singleton_class . ancestors [ -main_ancestors . size ..-1 ]
131
+ top_level_ancestors . should == main_ancestors
132
+ end
133
+
107
134
describe "with top-level methods" do
108
135
before :each do
109
136
path = File . expand_path "load_wrap_method_fixture.rb" , CODE_LOADING_DIR
Original file line number Diff line number Diff line change 1
1
class LoadSpecWrap
2
2
ScratchPad << String
3
3
end
4
+
5
+ ScratchPad << self
You can’t perform that action at this time.
0 commit comments