diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/commands/version_spec.rb | 12 | ||||
-rw-r--r-- | spec/support/path.rb | 12 |
2 files changed, 21 insertions, 3 deletions
diff --git a/spec/commands/version_spec.rb b/spec/commands/version_spec.rb index 66c7930397..8eecd9c53e 100644 --- a/spec/commands/version_spec.rb +++ b/spec/commands/version_spec.rb @@ -1,6 +1,14 @@ # frozen_string_literal: true +require_relative "../support/path" + RSpec.describe "bundle version" do + if Spec::Path.ruby_core? + COMMIT_HASH = /unknown|[a-fA-F0-9]{7,}/.freeze + else + COMMIT_HASH = /[a-fA-F0-9]{7,}/.freeze + end + context "with -v" do it "outputs the version", :bundler => "< 3" do bundle! "-v" @@ -28,12 +36,12 @@ RSpec.describe "bundle version" do context "with version" do it "outputs the version with build metadata", :bundler => "< 3" do bundle! "version" - expect(out).to match(/\ABundler version #{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit [a-fA-F0-9]{7,}\)\z/) + expect(out).to match(/\ABundler version #{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit #{COMMIT_HASH}\)\z/) end it "outputs the version with build metadata", :bundler => "3" do bundle! "version" - expect(out).to match(/\A#{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit [a-fA-F0-9]{7,}\)\z/) + expect(out).to match(/\A#{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit #{COMMIT_HASH}\)\z/) end end end diff --git a/spec/support/path.rb b/spec/support/path.rb index cc5aebb01b..4b3941b70f 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -30,14 +30,23 @@ module Spec end def tracked_files + if root != `git rev-parse --show-toplevel` + skip "not in git working directory" + end @tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler man/bundler*` : `git ls-files -z` end def shipped_files + if root != `git rev-parse --show-toplevel` + skip "not in git working directory" + end @shipped_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb man/bundler* libexec/bundle*` : `git ls-files -z -- lib man exe CHANGELOG.md LICENSE.md README.md bundler.gemspec` end def lib_tracked_files + if root != `git rev-parse --show-toplevel` + skip "not in git working directory" + end @lib_tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib` end @@ -150,7 +159,8 @@ module Spec def with_root_gemspec if ruby_core? root_gemspec = root.join("bundler.gemspec") - spec = Gem::Specification.load(gemspec.to_s) + # Dir.chdir(root) for Dir.glob in gemspec + spec = Dir.chdir(root) { Gem::Specification.load(gemspec.to_s) } spec.bindir = "libexec" File.open(root_gemspec.to_s, "w") {|f| f.write spec.to_ruby } yield(root_gemspec) |