Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7ebdd693f1f3
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dfb3f71f8508
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Feb 17, 2015

  1. Spec for calling top-level methods in wrapped load

    This specifies the expected behaviour for issue #3276 and splits up an
    existing spec for `load(_, true)` into multiple tests.
    ngollan authored and Yorick Peterse committed Feb 17, 2015
    Copy the full SHA
    5785ba2 View commit details
  2. Tag specs for load(_, true) as failing

    ngollan authored and Yorick Peterse committed Feb 17, 2015
    Copy the full SHA
    dfb3f71 View commit details
Showing with 44 additions and 5 deletions.
  1. +33 −5 spec/ruby/core/kernel/shared/load.rb
  2. +9 −0 spec/ruby/fixtures/code/load_wrap_method_fixture.rb
  3. +2 −0 spec/tags/ruby/core/kernel/load_tags.txt
38 changes: 33 additions & 5 deletions spec/ruby/core/kernel/shared/load.rb
Original file line number Diff line number Diff line change
@@ -81,12 +81,40 @@
lambda { @object.load(path) }.should raise_error(LoadError)
end

it "sets the enclosing scope to an anonymous module if passed true for 'wrap'" do
path = File.expand_path "wrap_fixture.rb", CODE_LOADING_DIR
@object.load(path, true).should be_true
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)

Object.const_defined?(:LoadSpecWrap).should be_false
ScratchPad.recorded.first.should be_an_instance_of(Class)
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

describe "(shell expansion)" do
9 changes: 9 additions & 0 deletions spec/ruby/fixtures/code/load_wrap_method_fixture.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def top_level_method
::ScratchPad << :load_wrap_loaded
end

begin
top_level_method
rescue NameError
::ScratchPad << :load_wrap_error
end
2 changes: 2 additions & 0 deletions spec/tags/ruby/core/kernel/load_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Kernel#load when passed true for 'wrap' with top-level methods allows calling top-level methods
fails:Kernel.load when passed true for 'wrap' with top-level methods allows calling top-level methods