summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGaurav Khanna <gauravk92@gmail.com>2023-08-21 13:14:25 -0700
committergit <svn-admin@ruby-lang.org>2023-08-21 20:14:35 +0000
commitb9ef819116e90ad9c3af99046d001845b047427f (patch)
treec60b5a3115e7dc72556528b1c6dff20fc55d9403 /spec
parent95e29b0423450447ea0adbf06564969f0e437673 (diff)
[rubygems/rubygems] Support `ruby file: ".tool-versions"` in Gemfile
(https://github.com/rubygems/rubygems/pull/6898) Supports .tool-versions (ASDF) by checking for a line starting with "ruby" before falling back to reading the entire file, as in .ruby-version. https://github.com/rubygems/rubygems/commit/6c0a3e793a
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/bundler/ruby_dsl_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/bundler/bundler/ruby_dsl_spec.rb b/spec/bundler/bundler/ruby_dsl_spec.rb
index 70424312ce..4af271ad59 100644
--- a/spec/bundler/bundler/ruby_dsl_spec.rb
+++ b/spec/bundler/bundler/ruby_dsl_spec.rb
@@ -121,5 +121,31 @@ RSpec.describe Bundler::RubyDsl do
end
end
end
+
+ context "with a (.tool-versions) file option" do
+ let(:options) { { :file => "foo" } }
+ let(:version) { "3.2.2" }
+ let(:ruby_version) { "3.2.2" }
+ let(:ruby_version_arg) { nil }
+ let(:engine_version) { version }
+ let(:patchlevel) { nil }
+ let(:engine) { "ruby" }
+ let(:project_root) { Pathname.new("/path/to/project") }
+
+ before do
+ allow(Bundler).to receive(:read_file).with(project_root.join("foo")).and_return("nodejs 18.16.0\nruby #{version} # This is a comment\npnpm 8.6.12\n")
+ allow(Bundler).to receive(:root).and_return(Pathname.new("/path/to/project"))
+ end
+
+ it_behaves_like "it stores the ruby version"
+
+ context "and a version" do
+ let(:ruby_version_arg) { "2.0.0" }
+
+ it "raises an error" do
+ expect { subject }.to raise_error(Bundler::GemfileError, "Cannot specify version when using the file option")
+ end
+ end
+ end
end
end