Skip to content

Commit

Permalink
[rubygems/rubygems] Extract logic to manipulate RUBYLIB in specs to a…
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and hsbt committed Jan 16, 2025
1 parent 3638f67 commit 10e7e92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 3 additions & 6 deletions spec/bundler/bundler/shared_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@

it "ensures bundler's ruby version lib path is in ENV['RUBYLIB']" do
subject.set_bundle_environment
paths = (ENV["RUBYLIB"]).split(File::PATH_SEPARATOR)
expect(paths).to include(ruby_lib_path)
expect(rubylib).to include(ruby_lib_path)
end
end

Expand All @@ -276,8 +275,7 @@

subject.set_bundle_environment

paths = (ENV["RUBYLIB"]).split(File::PATH_SEPARATOR)
expect(paths.count(RbConfig::CONFIG["rubylibdir"])).to eq(0)
expect(rubylib.count(RbConfig::CONFIG["rubylibdir"])).to eq(0)
end

it "exits if bundle path contains the unix-like path separator" do
Expand Down Expand Up @@ -441,8 +439,7 @@

it "ENV['RUBYLIB'] should only contain one instance of bundler's ruby version lib path" do
subject.set_bundle_environment
paths = (ENV["RUBYLIB"]).split(File::PATH_SEPARATOR)
expect(paths.count(ruby_lib_path)).to eq(1)
expect(rubylib.count(ruby_lib_path)).to eq(1)
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/bundler/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@
it "loads env plugins" do
plugin_msg = "hello from an env plugin!"
create_file "plugins/rubygems_plugin.rb", "puts '#{plugin_msg}'"
rubylib = ENV["RUBYLIB"].to_s.split(File::PATH_SEPARATOR).unshift(bundled_app("plugins").to_s).join(File::PATH_SEPARATOR)
install_gemfile <<-G, env: { "RUBYLIB" => rubylib }
install_gemfile <<-G, env: { "RUBYLIB" => rubylib.unshift(bundled_app("plugins").to_s).join(File::PATH_SEPARATOR) }
source "https://gem.repo1"
gem "myrack"
G
Expand Down
4 changes: 4 additions & 0 deletions spec/bundler/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ module Env
def ruby_core?
File.exist?(File.expand_path("../../../lib/bundler/bundler.gemspec", __dir__))
end

def rubylib
ENV["RUBYLIB"].to_s.split(File::PATH_SEPARATOR)
end
end
end

0 comments on commit 10e7e92

Please sign in to comment.