Skip to content

Commit dd5d15f

Browse files
authored
Merge pull request #8963 from MatheusRich/raise-error-on-unexisting-version-file
Raise error on missing version file
2 parents 9aeec87 + db61de6 commit dd5d15f

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

bundler/lib/bundler/ruby_dsl.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def normalize_ruby_file(filename)
5757
else
5858
file_content.strip
5959
end
60+
rescue Errno::ENOENT
61+
raise GemfileError, "Could not find version file #{filename}"
6062
end
6163
end
6264
end

bundler/spec/bundler/ruby_dsl_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ class MockDSL
210210
it_behaves_like "it stores the ruby version"
211211
end
212212
end
213+
214+
context "when the file does not exist" do
215+
let(:ruby_version_file_path) { nil }
216+
let(:ruby_version_arg) { nil }
217+
let(:file) { "nonexistent.txt" }
218+
219+
it "raises an error" do
220+
expect { subject }.to raise_error(Bundler::GemfileError, /Could not find version file nonexistent.txt/)
221+
end
222+
end
213223
end
214224
end
215225
end

0 commit comments

Comments
 (0)