summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorCody Cutrer <cody@instructure.com>2024-02-12 10:13:36 -0700
committergit <svn-admin@ruby-lang.org>2024-02-15 20:26:03 +0000
commitfa334ecd40d66fa1aa1a344afdcf776d5a8c541c (patch)
tree60d654b941b0c42adc8545d3efb39b72c7c391b1 /spec
parent8f17b3bd27a5c62c44b9de2376b8d54334997071 (diff)
[rubygems/rubygems] use full path for instance_eval
so that __dir__ and __FILE__ will work properly from within that gemfile fragment, if eval_gemfile is given a relative path https://github.com/rubygems/rubygems/commit/d521bf9790
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/bundler/dsl_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb
index 99a8c3ad67..e2e17bd357 100644
--- a/spec/bundler/bundler/dsl_spec.rb
+++ b/spec/bundler/bundler/dsl_spec.rb
@@ -134,6 +134,17 @@ RSpec.describe Bundler::Dsl do
expect { subject.eval_gemfile("Gemfile") }.
to raise_error(Bundler::GemfileError, /There was an error evaluating `Gemfile`: ruby_version must match the :engine_version for MRI/)
end
+
+ it "populates __dir__ and __FILE__ correctly" do
+ abs_path = source_root.join("../fragment.rb").to_s
+ expect(Bundler).to receive(:read_file).with(abs_path).and_return(<<~RUBY)
+ @fragment_dir = __dir__
+ @fragment_file = __FILE__
+ RUBY
+ subject.eval_gemfile("../fragment.rb")
+ expect(subject.instance_variable_get(:@fragment_dir)).to eq(source_root.dirname.to_s)
+ expect(subject.instance_variable_get(:@fragment_file)).to eq(abs_path)
+ end
end
describe "#gem" do