-
-
Save ngollan/f90825123c529d02001a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# goes into spec/ruby/core/kernel/shared/load.rb | |
describe :kernel_load, :shared => true do | |
# ... | |
describe "when passed true for 'wrap'" do | |
it "loads from an existing path" do | |
path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR | |
@object.load(path, true).should be_true | |
end | |
it "sets the enclosing scope to an anonymous module" do | |
path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR | |
@object.load(path, true) | |
Object.const_defined?(:LoadSpecWrap).should be_false | |
end | |
it "allows referencing outside namespaces" do | |
path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR | |
@object.load(path, true) | |
ScratchPad.recorded.first.should be_an_instance_of(Class) | |
end | |
describe "with top-level methods" do | |
before :each do | |
path = File.expand_path "load_wrap_method_fixture.rb", CODE_LOADING_DIR | |
@object.load(path, true) | |
end | |
it "allows calling top-level methods" do | |
ScratchPad.recorded.last.should == :load_wrap_loaded | |
end | |
it "does not pollute the receiver" do | |
lambda { @object.send(:top_level_method) }.should raise_error(NameError) | |
end | |
end | |
end | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/ruby/fixtures/code/load_wrap_method_fixture.rb | |
def top_level_method | |
::ScratchPad << :load_wrap_loaded | |
end | |
begin | |
top_level_method | |
rescue NameError | |
::ScratchPad << :load_wrap_error | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment