diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-08 14:19:04 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-13 07:54:37 +0900 |
commit | 0e60b59d5884edb8f9aea023efd9b24f1ff02049 (patch) | |
tree | e52935ce510440872ca5ce6b0e092cbc94f18bc9 /spec/bundler/install/gems/standalone_spec.rb | |
parent | 68224651a4d4dc3ce0cea666f5423dd8b6ba6cfc (diff) | |
download | ruby-0e60b59d5884edb8f9aea023efd9b24f1ff02049.tar.gz |
Update the bundler version with master branch
Diffstat (limited to 'spec/bundler/install/gems/standalone_spec.rb')
-rw-r--r-- | spec/bundler/install/gems/standalone_spec.rb | 144 |
1 files changed, 60 insertions, 84 deletions
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb index f1d5c8b505..521499a5df 100644 --- a/spec/bundler/install/gems/standalone_spec.rb +++ b/spec/bundler/install/gems/standalone_spec.rb @@ -21,15 +21,18 @@ RSpec.shared_examples "bundle install --standalone" do testrb << "\nrequire \"#{k}\"" testrb << "\nputs #{k.upcase}" end - Dir.chdir(bundled_app) do - ruby testrb, :no_lib => true - end + ruby testrb, :no_lib => true expect(out).to eq(expected_gems.values.join("\n")) end it "works on a different system" do - FileUtils.mv(bundled_app, "#{bundled_app}2") + begin + FileUtils.mv(bundled_app, "#{bundled_app}2") + rescue Errno::ENOTEMPTY + puts "Couldn't rename test app since the target folder has these files: #{Dir.glob("#{bundled_app}2/*")}" + raise + end testrb = String.new <<-RUBY $:.unshift File.expand_path("bundle") @@ -40,9 +43,7 @@ RSpec.shared_examples "bundle install --standalone" do testrb << "\nrequire \"#{k}\"" testrb << "\nputs #{k.upcase}" end - Dir.chdir("#{bundled_app}2") do - ruby testrb, :no_lib => true - end + ruby testrb, :no_lib => true, :dir => "#{bundled_app}2" expect(out).to eq(expected_gems.values.join("\n")) end @@ -54,7 +55,7 @@ RSpec.shared_examples "bundle install --standalone" do source "#{file_uri_for(gem_repo1)}" gem "rails" G - bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true) + bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :dir => cwd) end let(:expected_gems) do @@ -69,7 +70,7 @@ RSpec.shared_examples "bundle install --standalone" do describe "with gems with native extension", :ruby_repo do before do - install_gemfile <<-G, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true) + install_gemfile <<-G, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :dir => cwd) source "#{file_uri_for(gem_repo1)}" gem "very_simple_binary" G @@ -102,7 +103,7 @@ RSpec.shared_examples "bundle install --standalone" do end G end - install_gemfile <<-G, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true) + install_gemfile <<-G, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :dir => cwd) gem "bar", :git => "#{lib_path("bar-1.0")}" G end @@ -122,7 +123,7 @@ RSpec.shared_examples "bundle install --standalone" do gem "rails" gem "devise", :git => "#{lib_path("devise-1.0")}" G - bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true) + bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :dir => cwd) end let(:expected_gems) do @@ -149,7 +150,7 @@ RSpec.shared_examples "bundle install --standalone" do gem "rack-test" end G - bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true) + bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :dir => cwd) end let(:expected_gems) do @@ -162,88 +163,63 @@ RSpec.shared_examples "bundle install --standalone" do include_examples "common functionality" it "allows creating a standalone file with limited groups" do - bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => "default") + bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => "default", :dir => cwd) - Dir.chdir(bundled_app) do - load_error_ruby <<-RUBY, "spec", :no_lib => true - $:.unshift File.expand_path("bundle") - require "bundler/setup" + load_error_ruby <<-RUBY, "spec", :no_lib => true + $:.unshift File.expand_path("bundle") + require "bundler/setup" - require "actionpack" - puts ACTIONPACK - require "spec" - RUBY - end + require "actionpack" + puts ACTIONPACK + require "spec" + RUBY expect(out).to eq("2.3.2") expect(err).to eq("ZOMG LOAD ERROR") end it "allows --without to limit the groups used in a standalone" do - bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle"), :without => "test").merge(:standalone => true) + bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle"), :without => "test").merge(:standalone => true, :dir => cwd) - Dir.chdir(bundled_app) do - load_error_ruby <<-RUBY, "spec", :no_lib => true - $:.unshift File.expand_path("bundle") - require "bundler/setup" + load_error_ruby <<-RUBY, "spec", :no_lib => true + $:.unshift File.expand_path("bundle") + require "bundler/setup" - require "actionpack" - puts ACTIONPACK - require "spec" - RUBY - end + require "actionpack" + puts ACTIONPACK + require "spec" + RUBY expect(out).to eq("2.3.2") expect(err).to eq("ZOMG LOAD ERROR") end - it "allows --path to change the location of the standalone bundle", :bundler => "< 3" do - bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true) + it "allows --path to change the location of the standalone bundle" do + bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true, :dir => cwd) - Dir.chdir(bundled_app) do - ruby <<-RUBY, :no_lib => true - $:.unshift File.expand_path("path/to/bundle") - require "bundler/setup" + ruby <<-RUBY, :no_lib => true + $:.unshift File.expand_path("path/to/bundle") + require "bundler/setup" - require "actionpack" - puts ACTIONPACK - RUBY - end + require "actionpack" + puts ACTIONPACK + RUBY expect(out).to eq("2.3.2") end - it "allows --path to change the location of the standalone bundle", :bundler => "3" do - bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true) - path = File.expand_path("path/to/bundle") - - Dir.chdir(bundled_app) do - ruby <<-RUBY, :no_lib => true - $:.unshift File.expand_path(#{path.dump}) - require "bundler/setup" - - require "actionpack" - puts ACTIONPACK - RUBY - end + it "allows remembered --without to limit the groups used in a standalone" do + bundle! :install, forgotten_command_line_options(:without => "test").merge(:dir => cwd) + bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :dir => cwd) - expect(out).to eq("2.3.2") - end + load_error_ruby <<-RUBY, "spec", :no_lib => true + $:.unshift File.expand_path("bundle") + require "bundler/setup" - it "allows remembered --without to limit the groups used in a standalone" do - bundle! :install, forgotten_command_line_options(:without => "test") - bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true) - - Dir.chdir(bundled_app) do - load_error_ruby <<-RUBY, "spec", :no_lib => true - $:.unshift File.expand_path("bundle") - require "bundler/setup" - - require "actionpack" - puts ACTIONPACK - require "spec" - RUBY - end + require "actionpack" + puts ACTIONPACK + require "spec" + RUBY expect(out).to eq("2.3.2") expect(err).to eq("ZOMG LOAD ERROR") @@ -259,7 +235,7 @@ RSpec.shared_examples "bundle install --standalone" do source "#{source_uri}" gem "rails" G - bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :artifice => "endpoint") + bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :artifice => "endpoint", :dir => cwd) end let(:expected_gems) do @@ -279,7 +255,7 @@ RSpec.shared_examples "bundle install --standalone" do source "#{file_uri_for(gem_repo1)}" gem "rails" G - bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :binstubs => true) + bundle! :install, forgotten_command_line_options(:path => bundled_app("bundle")).merge(:standalone => true, :binstubs => true, :dir => cwd) end let(:expected_gems) do @@ -292,21 +268,21 @@ RSpec.shared_examples "bundle install --standalone" do include_examples "common functionality" it "creates stubs that use the standalone load path" do - Dir.chdir(bundled_app) do - expect(`bin/rails -v`.chomp).to eql "2.3.2" - end + skip "exec format error" if Gem.win_platform? + + expect(sys_exec("bin/rails -v").chomp).to eql "2.3.2" end it "creates stubs that can be executed from anywhere" do + skip "exec format error" if Gem.win_platform? + require "tmpdir" - Dir.chdir(Dir.tmpdir) do - sys_exec!(%(#{bundled_app("bin/rails")} -v)) - expect(out).to eq("2.3.2") - end + sys_exec!(%(#{bundled_app("bin/rails")} -v), :dir => Dir.tmpdir) + expect(out).to eq("2.3.2") end it "creates stubs that can be symlinked" do - pending "File.symlink is unsupported on Windows" if Bundler::WINDOWS + skip "symlinks unsupported" if Gem.win_platform? symlink_dir = tmp("symlink") FileUtils.mkdir_p(symlink_dir) @@ -325,13 +301,13 @@ RSpec.shared_examples "bundle install --standalone" do end RSpec.describe "bundle install --standalone" do + let(:cwd) { bundled_app } + include_examples("bundle install --standalone") end RSpec.describe "bundle install --standalone run in a subdirectory" do - before do - Dir.chdir(bundled_app("bob").tap(&:mkpath)) - end + let(:cwd) { bundled_app("bob").tap(&:mkpath) } include_examples("bundle install --standalone") end |