summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/bundler_spec.rb22
-rw-r--r--spec/bundler/cli_spec.rb6
-rw-r--r--spec/bundler/compact_index_client/gem_parser_spec.rb174
-rw-r--r--spec/bundler/compact_index_client/updater_spec.rb6
-rw-r--r--spec/bundler/definition_spec.rb10
-rw-r--r--spec/bundler/dsl_spec.rb44
-rw-r--r--spec/bundler/env_spec.rb22
-rw-r--r--spec/bundler/fetcher/compact_index_spec.rb3
-rw-r--r--spec/bundler/friendly_errors_spec.rb4
-rw-r--r--spec/bundler/gem_helper_spec.rb40
-rw-r--r--spec/bundler/mirror_spec.rb2
-rw-r--r--spec/bundler/plugin/index_spec.rb11
-rw-r--r--spec/bundler/plugin_spec.rb9
-rw-r--r--spec/bundler/settings_spec.rb2
-rw-r--r--spec/bundler/shared_helpers_spec.rb38
-rw-r--r--spec/cache/gems_spec.rb6
-rw-r--r--spec/cache/git_spec.rb6
-rw-r--r--spec/commands/add_spec.rb36
-rw-r--r--spec/commands/binstubs_spec.rb14
-rw-r--r--spec/commands/cache_spec.rb4
-rw-r--r--spec/commands/check_spec.rb13
-rw-r--r--spec/commands/clean_spec.rb6
-rw-r--r--spec/commands/config_spec.rb11
-rw-r--r--spec/commands/console_spec.rb2
-rw-r--r--spec/commands/doctor_spec.rb4
-rw-r--r--spec/commands/exec_spec.rb59
-rw-r--r--spec/commands/help_spec.rb2
-rw-r--r--spec/commands/info_spec.rb26
-rw-r--r--spec/commands/init_spec.rb18
-rw-r--r--spec/commands/inject_spec.rb26
-rw-r--r--spec/commands/install_spec.rb27
-rw-r--r--spec/commands/lock_spec.rb8
-rw-r--r--spec/commands/newgem_spec.rb223
-rw-r--r--spec/commands/open_spec.rb4
-rw-r--r--spec/commands/pristine_spec.rb4
-rw-r--r--spec/commands/remove_spec.rb6
-rw-r--r--spec/commands/show_spec.rb45
-rw-r--r--spec/commands/update_spec.rb5
-rw-r--r--spec/install/allow_offline_install_spec.rb6
-rw-r--r--spec/install/deploy_spec.rb17
-rw-r--r--spec/install/gemfile/eval_gemfile_spec.rb4
-rw-r--r--spec/install/gemfile/gemspec_spec.rb30
-rw-r--r--spec/install/gemfile/git_spec.rb127
-rw-r--r--spec/install/gemfile/path_spec.rb65
-rw-r--r--spec/install/gemfile/platform_spec.rb6
-rw-r--r--spec/install/gemfile/ruby_spec.rb6
-rw-r--r--spec/install/gemfile/sources_spec.rb4
-rw-r--r--spec/install/gemfile/specific_platform_spec.rb6
-rw-r--r--spec/install/gemfile_spec.rb12
-rw-r--r--spec/install/gems/compact_index_spec.rb128
-rw-r--r--spec/install/gems/dependency_api_spec.rb106
-rw-r--r--spec/install/gems/flex_spec.rb2
-rw-r--r--spec/install/gems/resolving_spec.rb62
-rw-r--r--spec/install/gems/standalone_spec.rb139
-rw-r--r--spec/install/gems/win32_spec.rb2
-rw-r--r--spec/install/gemspecs_spec.rb2
-rw-r--r--spec/install/git_spec.rb22
-rw-r--r--spec/install/global_cache_spec.rb52
-rw-r--r--spec/install/path_spec.rb42
-rw-r--r--spec/lock/lockfile_spec.rb32
-rw-r--r--spec/other/platform_spec.rb42
-rw-r--r--spec/plugins/install_spec.rb14
-rw-r--r--spec/plugins/source/example_spec.rb21
-rw-r--r--spec/plugins/source_spec.rb3
-rw-r--r--spec/quality_es_spec.rb20
-rw-r--r--spec/quality_spec.rb130
-rw-r--r--spec/realworld/edgecases_spec.rb4
-rw-r--r--spec/resolver/platform_spec.rb96
-rw-r--r--spec/runtime/executable_spec.rb28
-rw-r--r--spec/runtime/gem_tasks_spec.rb10
-rw-r--r--spec/runtime/inline_spec.rb53
-rw-r--r--spec/runtime/load_spec.rb4
-rw-r--r--spec/runtime/platform_spec.rb3
-rw-r--r--spec/runtime/require_spec.rb10
-rw-r--r--spec/runtime/setup_spec.rb80
-rw-r--r--spec/runtime/with_unbundled_env_spec.rb10
-rw-r--r--spec/spec_helper.rb6
-rw-r--r--spec/support/builders.rb96
-rw-r--r--spec/support/command_execution.rb13
-rw-r--r--spec/support/filters.rb2
-rw-r--r--spec/support/helpers.rb62
-rw-r--r--spec/support/indexes.rb4
-rw-r--r--spec/support/matchers.rb8
-rw-r--r--spec/support/path.rb24
-rw-r--r--spec/support/rubygems_ext.rb52
-rw-r--r--spec/support/rubygems_version_manager.rb10
-rw-r--r--spec/update/gemfile_spec.rb8
-rw-r--r--spec/update/git_spec.rb18
88 files changed, 1638 insertions, 1013 deletions
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index 247838600b..56ef4ce75a 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -124,7 +124,15 @@ RSpec.describe Bundler do
describe "#which" do
let(:executable) { "executable" }
- let(:path) { %w[/a /b c ../d /e] }
+
+ let(:path) do
+ if Gem.win_platform?
+ %w[C:/a C:/b C:/c C:/../d C:/e]
+ else
+ %w[/a /b c ../d /e]
+ end
+ end
+
let(:expected) { "executable" }
before do
@@ -149,7 +157,13 @@ RSpec.describe Bundler do
it_behaves_like "it returns the correct executable"
context "when the executable in inside a quoted path" do
- let(:expected) { "/e/executable" }
+ let(:expected) do
+ if Gem.win_platform?
+ "C:/e/executable"
+ else
+ "/e/executable"
+ end
+ end
it_behaves_like "it returns the correct executable"
end
@@ -196,6 +210,8 @@ EOF
gem "rack"
G
+ allow(Bundler).to receive(:root).and_return(bundled_app)
+
Bundler.mkdir_p(bundled_app.join("foo", "bar"))
expect(bundled_app.join("foo", "bar")).to exist
end
@@ -322,7 +338,7 @@ EOF
end
context "with unwritable files in a parent dir" do
- # Regression test for https://github.com/bundler/bundler/pull/6316
+ # Regression test for https://github.com/rubygems/bundler/pull/6316
# It doesn't matter if there are other unwritable files so long as
# bundle_path can be created
before do
diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb
index ddcd699d6c..561f471687 100644
--- a/spec/bundler/cli_spec.rb
+++ b/spec/bundler/cli_spec.rb
@@ -14,6 +14,8 @@ RSpec.describe "bundle executable" do
end
it "looks for a binary and executes it if it's named bundler-<task>" do
+ skip "obscure error" if Gem.win_platform?
+
File.open(tmp("bundler-testtasks"), "w", 0o755) do |f|
ruby = ENV["RUBY"] || "/usr/bin/env ruby"
f.puts "#!#{ruby}\nputs 'Hello, world'\n"
@@ -91,7 +93,7 @@ RSpec.describe "bundle executable" do
context "when ENV['BUNDLE_GEMFILE'] is set to an empty string" do
it "ignores it" do
- gemfile bundled_app("Gemfile"), <<-G
+ gemfile bundled_app_gemfile, <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
G
@@ -104,7 +106,7 @@ RSpec.describe "bundle executable" do
context "when ENV['RUBYGEMS_GEMDEPS'] is set" do
it "displays a warning" do
- gemfile bundled_app("Gemfile"), <<-G
+ gemfile bundled_app_gemfile, <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
G
diff --git a/spec/bundler/compact_index_client/gem_parser_spec.rb b/spec/bundler/compact_index_client/gem_parser_spec.rb
new file mode 100644
index 0000000000..5f5305426f
--- /dev/null
+++ b/spec/bundler/compact_index_client/gem_parser_spec.rb
@@ -0,0 +1,174 @@
+# frozen_string_literal: true
+
+require "bundler/compact_index_client/gem_parser"
+
+RSpec.describe Bundler::CompactIndexClient::GemParser do
+ def parse(line)
+ parser = Bundler::CompactIndexClient::GemParser.new
+ parser.parse(line)
+ end
+
+ context "platform" do
+ it "existent" do
+ checksum = "d5956d2bcb509af2cd07c90d9e5fdb331be8845a75bfd823a31c147b52cff471"
+ line = "1.11.3-java |checksum:#{checksum}"
+ expected = [
+ "1.11.3",
+ "java",
+ [],
+ [
+ ["checksum", [checksum]],
+ ],
+ ]
+ expect(parse(line)).to eq expected
+ end
+
+ it "nonexistent" do
+ checksum = "6da2eb3c4867e64df28d3e0b1008422dfacda7c046f9a8f3c56c52505b195e81"
+ line = "1.11.3 |checksum:#{checksum}"
+ expected = [
+ "1.11.3",
+ nil,
+ [],
+ [
+ ["checksum", [checksum]],
+ ],
+ ]
+ expect(parse(line)).to eq expected
+ end
+ end
+
+ context "dependencies" do
+ it "nothing" do
+ checksum = "6da2eb3c4867e64df28d3e0b1008422dfacda7c046f9a8f3c56c52505b195e81"
+ line = "1.11.3 |checksum:#{checksum}"
+ expected = [
+ "1.11.3",
+ nil,
+ [],
+ [
+ ["checksum", [checksum]],
+ ],
+ ]
+ expect(parse(line)).to eq expected
+ end
+
+ it "one" do
+ checksum = "5f0b378d12ab5665e2b6a1525274de97350238963002583cf088dae988527647"
+ line = "0.3.2 bones:>= 2.4.2|checksum:#{checksum}"
+ expected = [
+ "0.3.2",
+ nil,
+ [
+ ["bones", [">= 2.4.2"]],
+ ],
+ [
+ ["checksum", [checksum]],
+ ],
+ ]
+ expect(parse(line)).to eq expected
+ end
+
+ it "multiple" do
+ checksum = "199e892ada86c44d1f2e110b822d5da46b52fa2cbd2f00d89695b4cf610f9927"
+ line = "3.1.2 native-package-installer:>= 0,pkg-config:>= 0|checksum:#{checksum}"
+ expected = [
+ "3.1.2",
+ nil,
+ [
+ ["native-package-installer", [">= 0"]],
+ ["pkg-config", [">= 0"]],
+ ],
+ [
+ ["checksum", [checksum]],
+ ],
+ ]
+ expect(parse(line)).to eq expected
+ end
+
+ context "version" do
+ it "multiple" do
+ checksum = "1ec894b8090cb2c9393153552be2f3b6b1975265cbc1e0a3c6b28ebfea7e76a1"
+ line = "3.1.5 multi_json:< 1.3&>= 1.0|checksum:#{checksum}"
+ expected = [
+ "3.1.5",
+ nil,
+ [
+ ["multi_json", ["< 1.3", ">= 1.0"]],
+ ],
+ [
+ ["checksum", [checksum]],
+ ],
+ ]
+ expect(parse(line)).to eq expected
+ end
+ end
+ end
+
+ context "requirements" do
+ context "ruby" do
+ it "one version" do
+ checksum ="6da2eb3c4867e64df28d3e0b1008422dfacda7c046f9a8f3c56c52505b195e81"
+ line = "1.11.3 |checksum:#{checksum},ruby:>= 2.0"
+ expected = [
+ "1.11.3",
+ nil,
+ [],
+ [
+ ["checksum", [checksum]],
+ ["ruby", [">= 2.0"]],
+ ],
+ ]
+ expect(parse(line)).to eq expected
+ end
+
+ it "multiple versions" do
+ checksum = "99e4845796c8dec1c3fc80dc772860a01633b33291bd7534007f5c7724f0b876"
+ line = "1.11.3-x86-mingw32 |checksum:#{checksum},ruby:>= 2.2, < 2.7.dev"
+ expected = [
+ "1.11.3",
+ "x86-mingw32",
+ [],
+ [
+ ["checksum", [checksum]],
+ ["ruby", [">= 2.2", "< 2.7.dev"]],
+ ],
+ ]
+ expect(parse(line)).to eq expected
+ end
+
+ it "with rubygems" do
+ checksum = "7a82b358f00da749b01f8c84df8e8eb21c1bc389740aab9a2bf4ce59894564ac"
+ line = "1.9.23.pre1 |checksum:#{checksum},ruby:>= 1.9, < 2.7.dev,rubygems:> 1.3.1"
+ expected = [
+ "1.9.23.pre1",
+ nil,
+ [],
+ [
+ ["checksum", [checksum]],
+ ["ruby", [">= 1.9", "< 2.7.dev"]],
+ ["rubygems", ["> 1.3.1"]],
+ ],
+ ]
+ expect(parse(line)).to eq expected
+ end
+ end
+
+ context "rubygems" do
+ it "existent" do
+ checksum = "91ddb4c1b5482a4aff957f6733e282ce2767b2d3051138e0203e39d6df4eba10"
+ line = "1.0.12.pre |checksum:#{checksum},rubygems:> 1.3.1"
+ expected = [
+ "1.0.12.pre",
+ nil,
+ [],
+ [
+ ["checksum", [checksum]],
+ ["rubygems", ["> 1.3.1"]],
+ ],
+ ]
+ expect(parse(line)).to eq expected
+ end
+ end
+ end
+end
diff --git a/spec/bundler/compact_index_client/updater_spec.rb b/spec/bundler/compact_index_client/updater_spec.rb
index fd554a7b0d..26159dccd8 100644
--- a/spec/bundler/compact_index_client/updater_spec.rb
+++ b/spec/bundler/compact_index_client/updater_spec.rb
@@ -9,10 +9,10 @@ RSpec.describe Bundler::CompactIndexClient::Updater do
let(:local_path) { Pathname("/tmp/localpath") }
let(:remote_path) { double(:remote_path) }
- subject(:updater) { described_class.new(fetcher) }
+ let!(:updater) { described_class.new(fetcher) }
context "when the ETag header is missing" do
- # Regression test for https://github.com/bundler/bundler/issues/5463
+ # Regression test for https://github.com/rubygems/bundler/issues/5463
let(:response) { double(:response, :body => "") }
@@ -42,8 +42,6 @@ RSpec.describe Bundler::CompactIndexClient::Updater do
end
context "when bundler doesn't have permissions on Dir.tmpdir" do
- let(:response) { double(:response, :body => "") }
-
it "Errno::EACCES is raised" do
allow(Dir).to receive(:mktmpdir) { raise Errno::EACCES }
diff --git a/spec/bundler/definition_spec.rb b/spec/bundler/definition_spec.rb
index 1f4c1a0807..d0ebb37933 100644
--- a/spec/bundler/definition_spec.rb
+++ b/spec/bundler/definition_spec.rb
@@ -210,10 +210,12 @@ RSpec.describe Bundler::Definition do
source "#{file_uri_for(gem_repo1)}"
gem "foo"
G
+
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
end
it "should get a locked specs list when updating all" do
- definition = Bundler::Definition.new(bundled_app("Gemfile.lock"), [], Bundler::SourceList.new, true)
+ definition = Bundler::Definition.new(bundled_app_lock, [], Bundler::SourceList.new, true)
locked_specs = definition.gem_version_promoter.locked_specs
expect(locked_specs.to_a.map(&:name)).to eq ["foo"]
expect(definition.instance_variable_get("@locked_specs").empty?).to eq true
@@ -267,6 +269,8 @@ RSpec.describe Bundler::Definition do
BUNDLED WITH
1.13.0
L
+
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
end
it "should not eagerly unlock shared dependency with bundle install conservative updating behavior" do
@@ -275,7 +279,7 @@ RSpec.describe Bundler::Definition do
Bundler::Dependency.new("shared_owner_b", ">= 0")]
unlock_hash_for_bundle_install = {}
definition = Bundler::Definition.new(
- bundled_app("Gemfile.lock"),
+ bundled_app_lock,
updated_deps_in_gemfile,
source_list,
unlock_hash_for_bundle_install
@@ -289,7 +293,7 @@ RSpec.describe Bundler::Definition do
Bundler::Dependency.new("shared_owner_a", ">= 0"),
Bundler::Dependency.new("shared_owner_b", ">= 0")]
definition = Bundler::Definition.new(
- bundled_app("Gemfile.lock"),
+ bundled_app_lock,
updated_deps_in_gemfile,
source_list,
:gems => ["shared_owner_a"], :lock_shared_dependencies => true
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb
index 40739a431b..9299c014af 100644
--- a/spec/bundler/dsl_spec.rb
+++ b/spec/bundler/dsl_spec.rb
@@ -72,7 +72,7 @@ RSpec.describe Bundler::Dsl do
describe "#method_missing" do
it "raises an error for unknown DSL methods" do
- expect(Bundler).to receive(:read_file).with(bundled_app("Gemfile").to_s).
+ expect(Bundler).to receive(:read_file).with(root.join("Gemfile").to_s).
and_return("unknown")
error_msg = "There was an error parsing `Gemfile`: Undefined local variable or method `unknown' for Gemfile. Bundler cannot continue."
@@ -83,13 +83,13 @@ RSpec.describe Bundler::Dsl do
describe "#eval_gemfile" do
it "handles syntax errors with a useful message" do
- expect(Bundler).to receive(:read_file).with(bundled_app("Gemfile").to_s).and_return("}")
+ expect(Bundler).to receive(:read_file).with(root.join("Gemfile").to_s).and_return("}")
expect { subject.eval_gemfile("Gemfile") }.
to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`: (syntax error, unexpected tSTRING_DEND|(compile error - )?syntax error, unexpected '\}'). Bundler cannot continue./)
end
it "distinguishes syntax errors from evaluation errors" do
- expect(Bundler).to receive(:read_file).with(bundled_app("Gemfile").to_s).and_return(
+ expect(Bundler).to receive(:read_file).with(root.join("Gemfile").to_s).and_return(
"ruby '2.1.5', :engine => 'ruby', :engine_version => '1.2.4'"
)
expect { subject.eval_gemfile("Gemfile") }.
@@ -174,40 +174,6 @@ RSpec.describe Bundler::Dsl do
end
end
- describe "#gemspec" do
- let(:spec) do
- Gem::Specification.new do |gem|
- gem.name = "example"
- gem.platform = platform
- end
- end
-
- before do
- allow(Dir).to receive(:[]).and_return(["spec_path"])
- allow(Bundler).to receive(:load_gemspec).with("spec_path").and_return(spec)
- allow(Bundler).to receive(:default_gemfile).and_return(Pathname.new("./Gemfile"))
- end
-
- context "with a ruby platform" do
- let(:platform) { "ruby" }
-
- it "keeps track of the ruby platforms in the dependency" do
- subject.gemspec
- expect(subject.dependencies.last.platforms).to eq(Bundler::Dependency::REVERSE_PLATFORM_MAP[Gem::Platform::RUBY])
- end
- end
-
- context "with a jruby platform" do
- let(:platform) { "java" }
-
- it "keeps track of the jruby platforms in the dependency" do
- allow(Gem::Platform).to receive(:local).and_return(java)
- subject.gemspec
- expect(subject.dependencies.last.platforms).to eq(Bundler::Dependency::REVERSE_PLATFORM_MAP[Gem::Platform::JAVA])
- end
- end
- end
-
context "can bundle groups of gems with" do
# git "https://github.com/rails/rails.git" do
# gem "railties"
@@ -270,7 +236,7 @@ RSpec.describe Bundler::Dsl do
describe "syntax errors" do
it "will raise a Bundler::GemfileError" do
gemfile "gem 'foo', :path => /unquoted/string/syntax/error"
- expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
+ expect { Bundler::Dsl.evaluate(bundled_app_gemfile, nil, true) }.
to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`:( compile error -)? unknown regexp options - trg.+ Bundler cannot continue./)
end
end
@@ -278,7 +244,7 @@ RSpec.describe Bundler::Dsl do
describe "Runtime errors" do
it "will raise a Bundler::GemfileError" do
gemfile "raise RuntimeError, 'foo'"
- expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
+ expect { Bundler::Dsl.evaluate(bundled_app_gemfile, nil, true) }.
to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`: foo. Bundler cannot continue./i)
end
end
diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb
index 7686fe386a..8ff5ddada6 100644
--- a/spec/bundler/env_spec.rb
+++ b/spec/bundler/env_spec.rb
@@ -34,6 +34,8 @@ RSpec.describe Bundler::Env do
end
it "prints user home" do
+ skip "needs to use a valid HOME" if Gem.win_platform? && RUBY_VERSION < "2.6.0"
+
with_clear_paths("HOME", "/a/b/c") do
out = described_class.report
expect(out).to include("User Home /a/b/c")
@@ -41,6 +43,8 @@ RSpec.describe Bundler::Env do
end
it "prints user path" do
+ skip "needs to use a valid HOME" if Gem.win_platform? && RUBY_VERSION < "2.6.0"
+
with_clear_paths("HOME", "/a/b/c") do
out = described_class.report
expect(out).to include("User Path /a/b/c/.gem")
@@ -82,6 +86,8 @@ RSpec.describe Bundler::Env do
BUNDLED WITH
1.10.0
L
+
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
end
let(:output) { described_class.report(:print_gemfile => true) }
@@ -121,6 +127,8 @@ RSpec.describe Bundler::Env do
File.open(bundled_app.join("foo.gemspec"), "wb") do |f|
f.write(gemspec)
end
+
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
end
it "prints the gemspec" do
@@ -133,13 +141,15 @@ RSpec.describe Bundler::Env do
context "when eval_gemfile is used" do
it "prints all gemfiles" do
- create_file "other/Gemfile-other", "gem 'rack'"
- create_file "other/Gemfile", "eval_gemfile 'Gemfile-other'"
- create_file "Gemfile-alt", <<-G
+ create_file bundled_app("other/Gemfile-other"), "gem 'rack'"
+ create_file bundled_app("other/Gemfile"), "eval_gemfile 'Gemfile-other'"
+ create_file bundled_app("Gemfile-alt"), <<-G
source "#{file_uri_for(gem_repo1)}"
eval_gemfile "other/Gemfile"
G
- gemfile "eval_gemfile #{File.expand_path("Gemfile-alt").dump}"
+ gemfile "eval_gemfile #{bundled_app("Gemfile-alt").to_s.dump}"
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
output = described_class.report(:print_gemspecs => true)
expect(output).to include(strip_whitespace(<<-ENV))
@@ -148,7 +158,7 @@ RSpec.describe Bundler::Env do
### Gemfile
```ruby
- eval_gemfile #{File.expand_path("Gemfile-alt").dump}
+ eval_gemfile #{bundled_app("Gemfile-alt").to_s.dump}
```
### Gemfile-alt
@@ -173,7 +183,7 @@ RSpec.describe Bundler::Env do
### Gemfile.lock
```
- <No #{bundled_app("Gemfile.lock")} found>
+ <No #{bundled_app_lock} found>
```
ENV
end
diff --git a/spec/bundler/fetcher/compact_index_spec.rb b/spec/bundler/fetcher/compact_index_spec.rb
index c9419d3eb1..b00eadceab 100644
--- a/spec/bundler/fetcher/compact_index_spec.rb
+++ b/spec/bundler/fetcher/compact_index_spec.rb
@@ -1,5 +1,8 @@
# frozen_string_literal: true
+# load CompactIndexClient upfront to prevent thread safety issues during parallel specs
+require "bundler/compact_index_client"
+
RSpec.describe Bundler::Fetcher::CompactIndex do
let(:downloader) { double(:downloader) }
let(:display_uri) { Bundler::URI("http://sampleuri.com") }
diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb
index 125724d3ea..e7addda3f2 100644
--- a/spec/bundler/friendly_errors_spec.rb
+++ b/spec/bundler/friendly_errors_spec.rb
@@ -7,13 +7,13 @@ require "cgi"
RSpec.describe Bundler, "friendly errors" do
context "with invalid YAML in .gemrc" do
before do
- File.open(Gem.configuration.config_file_name, "w") do |f|
+ File.open(home(".gemrc"), "w") do |f|
f.write "invalid: yaml: hah"
end
end
after do
- FileUtils.rm(Gem.configuration.config_file_name)
+ FileUtils.rm(home(".gemrc"))
end
it "reports a relevant friendly error message" do
diff --git a/spec/bundler/gem_helper_spec.rb b/spec/bundler/gem_helper_spec.rb
index 29e10d64f8..6af78e00be 100644
--- a/spec/bundler/gem_helper_spec.rb
+++ b/spec/bundler/gem_helper_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Bundler::GemHelper do
let(:app_gemspec_path) { app_path.join("#{app_name}.gemspec") }
before(:each) do
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
+ global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__RUBOCOP" => "false"
bundle "gem #{app_name}"
prepare_gemspec(app_gemspec_path)
end
@@ -178,13 +178,11 @@ RSpec.describe Bundler::GemHelper do
end
before do
- Dir.chdir(app_path) do
- `git init`
- `git config user.email "you@example.com"`
- `git config user.name "name"`
- `git config commit.gpgsign false`
- `git config push.default simple`
- end
+ sys_exec("git init", :dir => app_path)
+ sys_exec("git config user.email \"you@example.com\"", :dir => app_path)
+ sys_exec("git config user.name \"name\"", :dir => app_path)
+ sys_exec("git config commit.gpgsign false", :dir => app_path)
+ sys_exec("git config push.default simple", :dir => app_path)
# silence messages
allow(Bundler.ui).to receive(:confirm)
@@ -198,13 +196,13 @@ RSpec.describe Bundler::GemHelper do
end
it "when there are uncommitted files" do
- Dir.chdir(app_path) { `git add .` }
+ sys_exec("git add .", :dir => app_path)
expect { Rake.application["release"].invoke }.
to raise_error("There are files that need to be committed first.")
end
it "when there is no git remote" do
- Dir.chdir(app_path) { `git commit -a -m "initial commit"` }
+ sys_exec("git commit -a -m \"initial commit\"", :dir => app_path)
expect { Rake.application["release"].invoke }.to raise_error(RuntimeError)
end
end
@@ -213,10 +211,8 @@ RSpec.describe Bundler::GemHelper do
let(:repo) { build_git("foo", :bare => true) }
before do
- Dir.chdir(app_path) do
- sys_exec("git remote add origin #{file_uri_for(repo.path)}")
- sys_exec('git commit -a -m "initial commit"')
- end
+ sys_exec("git remote add origin #{file_uri_for(repo.path)}", :dir => app_path)
+ sys_exec('git commit -a -m "initial commit"', :dir => app_path)
end
context "on releasing" do
@@ -225,7 +221,7 @@ RSpec.describe Bundler::GemHelper do
mock_confirm_message "Tagged v#{app_version}."
mock_confirm_message "Pushed git commits and tags."
- Dir.chdir(app_path) { sys_exec("git push -u origin master") }
+ sys_exec("git push -u origin master", :dir => app_path)
end
it "calls rubygem_push with proper arguments" do
@@ -246,9 +242,7 @@ RSpec.describe Bundler::GemHelper do
mock_confirm_message "Tag v#{app_version} has already been created."
expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
- Dir.chdir(app_path) do
- `git tag -a -m \"Version #{app_version}\" v#{app_version}`
- end
+ sys_exec("git tag -a -m \"Version #{app_version}\" v#{app_version}", :dir => app_path)
Rake.application["release"].invoke
end
@@ -269,12 +263,10 @@ RSpec.describe Bundler::GemHelper do
end
before do
- Dir.chdir(app_path) do
- `git init`
- `git config user.email "you@example.com"`
- `git config user.name "name"`
- `git config push.default simple`
- end
+ sys_exec("git init", :dir => app_path)
+ sys_exec("git config user.email \"you@example.com\"", :dir => app_path)
+ sys_exec("git config user.name \"name\"", :dir => app_path)
+ sys_exec("git config push.gpgsign simple", :dir => app_path)
# silence messages
allow(Bundler.ui).to receive(:confirm)
diff --git a/spec/bundler/mirror_spec.rb b/spec/bundler/mirror_spec.rb
index 4a8a0c7c48..1eaf1e9a8e 100644
--- a/spec/bundler/mirror_spec.rb
+++ b/spec/bundler/mirror_spec.rb
@@ -305,6 +305,8 @@ RSpec.describe Bundler::Settings::TCPSocketProbe do
end
it "probes the server correctly" do
+ skip "obscure error" if Gem.win_platform?
+
with_server_and_mirror do |server, mirror|
expect(server.closed?).to be_falsey
expect(probe.replies?(mirror)).to be_truthy
diff --git a/spec/bundler/plugin/index_spec.rb b/spec/bundler/plugin/index_spec.rb
index e18e960fb8..925dc558ac 100644
--- a/spec/bundler/plugin/index_spec.rb
+++ b/spec/bundler/plugin/index_spec.rb
@@ -4,6 +4,7 @@ RSpec.describe Bundler::Plugin::Index do
Index = Bundler::Plugin::Index
before do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
gemfile ""
path = lib_path(plugin_name)
index.register_plugin("new-plugin", path.to_s, [path.join("lib").to_s], commands, sources, hooks)
@@ -117,11 +118,11 @@ RSpec.describe Bundler::Plugin::Index do
describe "global index" do
before do
- Dir.chdir(tmp) do
- Bundler::Plugin.reset!
- path = lib_path("gplugin")
- index.register_plugin("gplugin", path.to_s, [path.join("lib").to_s], [], ["glb_source"], [])
- end
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(nil)
+
+ Bundler::Plugin.reset!
+ path = lib_path("gplugin")
+ index.register_plugin("gplugin", path.to_s, [path.join("lib").to_s], [], ["glb_source"], [])
end
it "skips sources" do
diff --git a/spec/bundler/plugin_spec.rb b/spec/bundler/plugin_spec.rb
index e0e2e9afdf..8c95723bcc 100644
--- a/spec/bundler/plugin_spec.rb
+++ b/spec/bundler/plugin_spec.rb
@@ -107,7 +107,7 @@ RSpec.describe Bundler::Plugin do
describe "evaluate gemfile for plugins" do
let(:definition) { double("definition") }
let(:builder) { double("builder") }
- let(:gemfile) { bundled_app("Gemfile") }
+ let(:gemfile) { bundled_app_gemfile }
before do
allow(Plugin::DSL).to receive(:new) { builder }
@@ -237,7 +237,7 @@ RSpec.describe Bundler::Plugin do
describe "#root" do
context "in app dir" do
before do
- gemfile ""
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
end
it "returns plugin dir in app .bundle path" do
@@ -246,8 +246,11 @@ RSpec.describe Bundler::Plugin do
end
context "outside app dir" do
+ before do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(nil)
+ end
+
it "returns plugin dir in global bundle path" do
- Dir.chdir tmp
expect(subject.root).to eq(home.join(".bundle/plugin"))
end
end
diff --git a/spec/bundler/settings_spec.rb b/spec/bundler/settings_spec.rb
index b83d768477..116a038445 100644
--- a/spec/bundler/settings_spec.rb
+++ b/spec/bundler/settings_spec.rb
@@ -130,6 +130,8 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow
describe "#temporary" do
it "reset after used" do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+
Bundler.settings.set_command_option :no_install, true
Bundler.settings.temporary(:no_install => false) do
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index 4530a9a5cd..4b4d5f33f6 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -4,10 +4,13 @@ RSpec.describe Bundler::SharedHelpers do
let(:ext_lock_double) { double(:ext_lock) }
before do
+ pwd_stub
allow(Bundler.rubygems).to receive(:ext_lock).and_return(ext_lock_double)
allow(ext_lock_double).to receive(:synchronize) {|&block| block.call }
end
+ let(:pwd_stub) { allow(subject).to receive(:pwd).and_return(bundled_app) }
+
subject { Bundler::SharedHelpers }
describe "#default_gemfile" do
@@ -77,7 +80,7 @@ RSpec.describe Bundler::SharedHelpers do
let(:global_rubygems_dir) { Pathname.new(bundled_app) }
before do
- Dir.mkdir ".bundle"
+ Dir.mkdir bundled_app(".bundle")
allow(Bundler.rubygems).to receive(:user_home).and_return(global_rubygems_dir)
end
@@ -91,7 +94,7 @@ RSpec.describe Bundler::SharedHelpers do
let(:expected_bundle_dir_path) { Pathname.new("#{bundled_app}/.bundle") }
before do
- Dir.mkdir ".bundle"
+ Dir.mkdir bundled_app(".bundle")
allow(Bundler.rubygems).to receive(:user_home).and_return(global_rubygems_dir)
end
@@ -109,7 +112,8 @@ RSpec.describe Bundler::SharedHelpers do
shared_examples_for "correctly determines whether to return a Gemfile path" do
context "currently in directory with a Gemfile" do
- before { File.new("Gemfile", "w") }
+ before { FileUtils.touch(bundled_app_gemfile) }
+ after { FileUtils.rm(bundled_app_gemfile) }
it "returns path of the bundle Gemfile" do
expect(subject.in_bundle?).to eq("#{bundled_app}/Gemfile")
@@ -147,22 +151,24 @@ RSpec.describe Bundler::SharedHelpers do
describe "#chdir" do
let(:op_block) { proc { Dir.mkdir "nested_dir" } }
- before { Dir.mkdir "chdir_test_dir" }
+ before { Dir.mkdir bundled_app("chdir_test_dir") }
it "executes the passed block while in the specified directory" do
- subject.chdir("chdir_test_dir", &op_block)
- expect(Pathname.new("chdir_test_dir/nested_dir")).to exist
+ subject.chdir(bundled_app("chdir_test_dir"), &op_block)
+ expect(bundled_app("chdir_test_dir/nested_dir")).to exist
end
end
describe "#pwd" do
+ let(:pwd_stub) { nil }
+
it "returns the current absolute path" do
- expect(subject.pwd).to eq(bundled_app)
+ expect(subject.pwd).to eq(root)
end
end
describe "#with_clean_git_env" do
- let(:with_clean_git_env_block) { proc { Dir.mkdir "with_clean_git_env_test_dir" } }
+ let(:with_clean_git_env_block) { proc { Dir.mkdir bundled_app("with_clean_git_env_test_dir") } }
before do
ENV["GIT_DIR"] = "ORIGINAL_ENV_GIT_DIR"
@@ -171,20 +177,20 @@ RSpec.describe Bundler::SharedHelpers do
it "executes the passed block" do
subject.with_clean_git_env(&with_clean_git_env_block)
- expect(Pathname.new("with_clean_git_env_test_dir")).to exist
+ expect(bundled_app("with_clean_git_env_test_dir")).to exist
end
context "when a block is passed" do
let(:with_clean_git_env_block) do
proc do
- Dir.mkdir "git_dir_test_dir" unless ENV["GIT_DIR"].nil?
- Dir.mkdir "git_work_tree_test_dir" unless ENV["GIT_WORK_TREE"].nil?
+ Dir.mkdir bundled_app("git_dir_test_dir") unless ENV["GIT_DIR"].nil?
+ Dir.mkdir bundled_app("git_work_tree_test_dir") unless ENV["GIT_WORK_TREE"].nil?
end end
it "uses a fresh git env for execution" do
subject.with_clean_git_env(&with_clean_git_env_block)
- expect(Pathname.new("git_dir_test_dir")).to_not exist
- expect(Pathname.new("git_work_tree_test_dir")).to_not exist
+ expect(bundled_app("git_dir_test_dir")).to_not exist
+ expect(bundled_app("git_work_tree_test_dir")).to_not exist
end
end
@@ -224,7 +230,7 @@ RSpec.describe Bundler::SharedHelpers do
end
shared_examples_for "ENV['PATH'] gets set correctly" do
- before { Dir.mkdir ".bundle" }
+ before { Dir.mkdir bundled_app(".bundle") }
it "ensures bundle bin path is in ENV['PATH']" do
subject.set_bundle_environment
@@ -244,7 +250,7 @@ RSpec.describe Bundler::SharedHelpers do
let(:ruby_lib_path) { "stubbed_ruby_lib_dir" }
before do
- allow(Bundler::SharedHelpers).to receive(:bundler_ruby_lib).and_return(ruby_lib_path)
+ allow(subject).to receive(:bundler_ruby_lib).and_return(ruby_lib_path)
end
it "ensures bundler's ruby version lib path is in ENV['RUBYLIB']" do
@@ -263,7 +269,7 @@ RSpec.describe Bundler::SharedHelpers do
end
it "ignores if bundler_ruby_lib is same as rubylibdir" do
- allow(Bundler::SharedHelpers).to receive(:bundler_ruby_lib).and_return(RbConfig::CONFIG["rubylibdir"])
+ allow(subject).to receive(:bundler_ruby_lib).and_return(RbConfig::CONFIG["rubylibdir"])
subject.set_bundle_environment
diff --git a/spec/cache/gems_spec.rb b/spec/cache/gems_spec.rb
index 89d6d41570..b82ccbbd30 100644
--- a/spec/cache/gems_spec.rb
+++ b/spec/cache/gems_spec.rb
@@ -69,7 +69,7 @@ RSpec.describe "bundle cache" do
bundle "cache"
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
end
@@ -165,11 +165,11 @@ RSpec.describe "bundle cache" do
end
it "should not explode if the lockfile is not present" do
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
bundle :cache
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
end
diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb
index 75525d405b..ecdc97f837 100644
--- a/spec/cache/git_spec.rb
+++ b/spec/cache/git_spec.rb
@@ -155,10 +155,8 @@ RSpec.describe "bundle cache with git" do
s.add_dependency "submodule"
end
- Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
- `git commit -m "submodulator"`
- end
+ sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", :dir => lib_path("has_submodule-1.0")
+ sys_exec "git commit -m \"submodulator\"", :dir => lib_path("has_submodule-1.0")
install_gemfile <<-G
git "#{lib_path("has_submodule-1.0")}", :submodules => true do
diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb
index 35fd43d3d2..672b1ffa52 100644
--- a/spec/commands/add_spec.rb
+++ b/spec/commands/add_spec.rb
@@ -30,25 +30,25 @@ RSpec.describe "bundle add" do
describe "without version specified" do
it "version requirement becomes ~> major.minor.patch when resolved version is < 1.0" do
bundle "add 'bar'"
- expect(bundled_app("Gemfile").read).to match(/gem "bar", "~> 0.12.3"/)
+ expect(bundled_app_gemfile.read).to match(/gem "bar", "~> 0.12.3"/)
expect(the_bundle).to include_gems "bar 0.12.3"
end
it "version requirement becomes ~> major.minor when resolved version is > 1.0" do
bundle "add 'baz'"
- expect(bundled_app("Gemfile").read).to match(/gem "baz", "~> 1.2"/)
+ expect(bundled_app_gemfile.read).to match(/gem "baz", "~> 1.2"/)
expect(the_bundle).to include_gems "baz 1.2.3"
end
it "version requirement becomes ~> major.minor.patch.pre when resolved version is < 1.0" do
bundle "add 'cat'"
- expect(bundled_app("Gemfile").read).to match(/gem "cat", "~> 0.12.3.pre"/)
+ expect(bundled_app_gemfile.read).to match(/gem "cat", "~> 0.12.3.pre"/)
expect(the_bundle).to include_gems "cat 0.12.3.pre"
end
it "version requirement becomes ~> major.minor.pre when resolved version is > 1.0.pre" do
bundle "add 'dog'"
- expect(bundled_app("Gemfile").read).to match(/gem "dog", "~> 1.1.pre"/)
+ expect(bundled_app_gemfile.read).to match(/gem "dog", "~> 1.1.pre"/)
expect(the_bundle).to include_gems "dog 1.1.3.pre"
end
end
@@ -56,14 +56,14 @@ RSpec.describe "bundle add" do
describe "with --version" do
it "adds dependency of specified version and runs install" do
bundle "add 'foo' --version='~> 1.0'"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 1.0"/)
+ expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 1.0"/)
expect(the_bundle).to include_gems "foo 1.1"
end
it "adds multiple version constraints when specified" do
requirements = ["< 3.0", "> 1.0"]
bundle "add 'foo' --version='#{requirements.join(", ")}'"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", #{Gem::Requirement.new(requirements).as_list.map(&:dump).join(', ')}/)
+ expect(bundled_app_gemfile.read).to match(/gem "foo", #{Gem::Requirement.new(requirements).as_list.map(&:dump).join(', ')}/)
expect(the_bundle).to include_gems "foo 2.0"
end
end
@@ -71,13 +71,13 @@ RSpec.describe "bundle add" do
describe "with --group" do
it "adds dependency for the specified group" do
bundle "add 'foo' --group='development'"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :group => :development/)
+ expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :group => :development/)
expect(the_bundle).to include_gems "foo 2.0"
end
it "adds dependency to more than one group" do
bundle "add 'foo' --group='development, test'"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :groups => \[:development, :test\]/)
+ expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :groups => \[:development, :test\]/)
expect(the_bundle).to include_gems "foo 2.0"
end
end
@@ -86,7 +86,7 @@ RSpec.describe "bundle add" do
it "adds dependency with specified source" do
bundle "add 'foo' --source='#{file_uri_for(gem_repo2)}'"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :source => "#{file_uri_for(gem_repo2)}"/)
+ expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :source => "#{file_uri_for(gem_repo2)}"/)
expect(the_bundle).to include_gems "foo 2.0"
end
end
@@ -95,7 +95,7 @@ RSpec.describe "bundle add" do
it "adds dependency with specified github source" do
bundle "add foo --git=#{lib_path("foo-2.0")}"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/)
+ expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/)
expect(the_bundle).to include_gems "foo 2.0"
end
end
@@ -108,7 +108,7 @@ RSpec.describe "bundle add" do
it "adds dependency with specified github source and branch" do
bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/)
+ expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/)
expect(the_bundle).to include_gems "foo 2.0"
end
end
@@ -117,14 +117,14 @@ RSpec.describe "bundle add" do
it "adds gem to Gemfile but is not installed" do
bundle "add foo --skip-install --version=2.0"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "= 2.0"/)
+ expect(bundled_app_gemfile.read).to match(/gem "foo", "= 2.0"/)
expect(the_bundle).to_not include_gems "foo 2.0"
end
end
it "using combination of short form options works like long form" do
bundle "add 'foo' -s='#{file_uri_for(gem_repo2)}' -g='development' -v='~>1.0'"
- expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 1.0", :group => :development, :source => "#{file_uri_for(gem_repo2)}")
+ expect(bundled_app_gemfile.read).to include %(gem "foo", "~> 1.0", :group => :development, :source => "#{file_uri_for(gem_repo2)}")
expect(the_bundle).to include_gems "foo 1.1"
end
@@ -153,7 +153,7 @@ RSpec.describe "bundle add" do
describe "with --optimistic" do
it "adds optimistic version" do
bundle! "add 'foo' --optimistic"
- expect(bundled_app("Gemfile").read).to include %(gem "foo", ">= 2.0")
+ expect(bundled_app_gemfile.read).to include %(gem "foo", ">= 2.0")
expect(the_bundle).to include_gems "foo 2.0"
end
end
@@ -161,7 +161,7 @@ RSpec.describe "bundle add" do
describe "with --strict option" do
it "adds strict version" do
bundle! "add 'foo' --strict"
- expect(bundled_app("Gemfile").read).to include %(gem "foo", "= 2.0")
+ expect(bundled_app_gemfile.read).to include %(gem "foo", "= 2.0")
expect(the_bundle).to include_gems "foo 2.0"
end
end
@@ -169,7 +169,7 @@ RSpec.describe "bundle add" do
describe "with no option" do
it "adds pessimistic version" do
bundle! "add 'foo'"
- expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 2.0")
+ expect(bundled_app_gemfile.read).to include %(gem "foo", "~> 2.0")
expect(the_bundle).to include_gems "foo 2.0"
end
end
@@ -186,8 +186,8 @@ RSpec.describe "bundle add" do
it "adds multiple gems to gemfile" do
bundle! "add bar baz"
- expect(bundled_app("Gemfile").read).to match(/gem "bar", "~> 0.12.3"/)
- expect(bundled_app("Gemfile").read).to match(/gem "baz", "~> 1.2"/)
+ expect(bundled_app_gemfile.read).to match(/gem "bar", "~> 0.12.3"/)
+ expect(bundled_app_gemfile.read).to match(/gem "baz", "~> 1.2"/)
end
it "throws error if any of the specified gems are present in the gemfile with different version" do
diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb
index 7c04e8ddbd..a5e48753fb 100644
--- a/spec/commands/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
@@ -1,6 +1,10 @@
# frozen_string_literal: true
RSpec.describe "bundle binstubs <gem>" do
+ before do
+ skip "https://github.com/rubygems/bundler/issues/6894" if Gem.win_platform?
+ end
+
context "when the gem exists in the lockfile" do
it "sets up the binstub" do
install_gemfile <<-G
@@ -82,7 +86,7 @@ RSpec.describe "bundle binstubs <gem>" do
bundle "binstubs rack"
- File.open("bin/bundle", "wb") do |file|
+ File.open(bundled_app("bin/bundle"), "wb") do |file|
file.print "OMG"
end
@@ -133,7 +137,7 @@ RSpec.describe "bundle binstubs <gem>" do
context "when BUNDLER_VERSION is set" do
it "runs the correct version of bundler" do
- sys_exec "#{bundled_app("bin/bundle")} install", "BUNDLER_VERSION" => "999.999.999"
+ sys_exec "#{bundled_app("bin/bundle")} install", :env => { "BUNDLER_VERSION" => "999.999.999" }
expect(exitstatus).to eq(42) if exitstatus
expect(err).to include("Activating bundler (~> 999.999) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`")
@@ -217,7 +221,7 @@ RSpec.describe "bundle binstubs <gem>" do
context "without a lockfile" do
it "falls back to the latest installed bundler" do
- FileUtils.rm bundled_app("Gemfile.lock")
+ FileUtils.rm bundled_app_lock
sys_exec! bundled_app("bin/bundle").to_s
expect(out).to eq "system bundler #{system_bundler_version}\n[]"
end
@@ -274,6 +278,8 @@ RSpec.describe "bundle binstubs <gem>" do
end
it "sets correct permissions for binstubs" do
+ skip "https://github.com/rubygems/bundler/issues/6895" if Gem.win_platform?
+
with_umask(0o002) do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -295,7 +301,7 @@ RSpec.describe "bundle binstubs <gem>" do
bundle "binstubs rack --shebang jruby"
- expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env jruby\n")
+ expect(File.open(bundled_app("bin/rackup")).gets).to eq("#!/usr/bin/env jruby\n")
end
end
end
diff --git a/spec/commands/cache_spec.rb b/spec/commands/cache_spec.rb
index 07ec186c2f..04dfee5b16 100644
--- a/spec/commands/cache_spec.rb
+++ b/spec/commands/cache_spec.rb
@@ -198,6 +198,10 @@ RSpec.describe "bundle cache" do
end
context "with --all-platforms" do
+ before do
+ skip "doesn't put gems where it should" if Gem.win_platform?
+ end
+
it "puts the gems in vendor/cache even for other rubies" do
gemfile <<-D
source "#{file_uri_for(gem_repo1)}"
diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb
index c755ef2804..0b5eae5d0b 100644
--- a/spec/commands/check_spec.rb
+++ b/spec/commands/check_spec.rb
@@ -18,8 +18,7 @@ RSpec.describe "bundle check" do
gem "rails"
G
- Dir.chdir tmp
- bundle "check --gemfile bundled_app/Gemfile"
+ bundle "check --gemfile bundled_app/Gemfile", :dir => tmp
expect(out).to include("The Gemfile's dependencies are satisfied")
end
@@ -29,11 +28,11 @@ RSpec.describe "bundle check" do
gem "rails"
G
- FileUtils.rm("Gemfile.lock")
+ FileUtils.rm(bundled_app_lock)
bundle "check"
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
it "does not create a Gemfile.lock if --dry-run was passed" do
@@ -42,11 +41,11 @@ RSpec.describe "bundle check" do
gem "rails"
G
- FileUtils.rm("Gemfile.lock")
+ FileUtils.rm(bundled_app_lock)
bundle "check --dry-run"
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
end
it "prints a generic error if the missing gems are unresolvable" do
@@ -232,7 +231,7 @@ RSpec.describe "bundle check" do
G
bundle! "install", forgotten_command_line_options(:deployment => true)
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
bundle :check
expect(last_command).to be_failure
diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index 5cc97de912..590852b02d 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -536,7 +536,7 @@ RSpec.describe "bundle clean" do
expect(out).to include("rack (1.0.0)")
end
- describe "when missing permissions" do
+ describe "when missing permissions", :permissions do
before { ENV["BUNDLE_PATH__SYSTEM"] = "true" }
let(:system_cache_path) { system_gem_path("cache") }
after do
@@ -585,11 +585,11 @@ RSpec.describe "bundle clean" do
bundle "install"
# mimic 7 length git revisions in Gemfile.lock
- gemfile_lock = File.read(bundled_app("Gemfile.lock")).split("\n")
+ gemfile_lock = File.read(bundled_app_lock).split("\n")
gemfile_lock.each_with_index do |line, index|
gemfile_lock[index] = line[0..(11 + 7)] if line.include?(" revision:")
end
- lockfile(bundled_app("Gemfile.lock"), gemfile_lock.join("\n"))
+ lockfile(bundled_app_lock, gemfile_lock.join("\n"))
bundle "config set path vendor/bundle"
bundle "install"
diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb
index ef580463e5..7a45dd0dd7 100644
--- a/spec/commands/config_spec.rb
+++ b/spec/commands/config_spec.rb
@@ -54,14 +54,13 @@ RSpec.describe ".bundle/config" do
it "can provide a relative path with the environment variable" do
FileUtils.mkdir_p bundled_app("omg")
- Dir.chdir bundled_app("omg")
ENV["BUNDLE_APP_CONFIG"] = "../foo"
- bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle").merge(:dir => bundled_app("omg"))
expect(bundled_app(".bundle")).not_to exist
expect(bundled_app("../foo/config")).to exist
- expect(the_bundle).to include_gems "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0", :dir => bundled_app("omg")
end
end
@@ -138,7 +137,7 @@ RSpec.describe ".bundle/config" do
it "expands the path at time of setting" do
bundle "config set --global local.foo .."
run "puts Bundler.settings['local.foo']"
- expect(out).to eq(File.expand_path(Dir.pwd + "/.."))
+ expect(out).to eq(File.expand_path(bundled_app.to_s + "/.."))
end
it "saves with parseable option" do
@@ -205,7 +204,7 @@ RSpec.describe ".bundle/config" do
it "expands the path at time of setting" do
bundle "config set --local local.foo .."
run "puts Bundler.settings['local.foo']"
- expect(out).to eq(File.expand_path(Dir.pwd + "/.."))
+ expect(out).to eq(File.expand_path(bundled_app.to_s + "/.."))
end
it "can be deleted with parseable option" do
@@ -484,7 +483,7 @@ RSpec.describe "setting gemfile via config" do
G
bundle "config set --local gemfile #{bundled_app("NotGemfile")}"
- expect(File.exist?(".bundle/config")).to eq(true)
+ expect(File.exist?(bundled_app(".bundle/config"))).to eq(true)
bundle "config list"
expect(out).to include("NotGemfile")
diff --git a/spec/commands/console_spec.rb b/spec/commands/console_spec.rb
index a0b71ff016..3092184f45 100644
--- a/spec/commands/console_spec.rb
+++ b/spec/commands/console_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle console", :bundler => "< 3" do
+RSpec.describe "bundle console", :bundler => "< 3", :readline => true do
before :each do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
diff --git a/spec/commands/doctor_spec.rb b/spec/commands/doctor_spec.rb
index d829f00092..0731bb08db 100644
--- a/spec/commands/doctor_spec.rb
+++ b/spec/commands/doctor_spec.rb
@@ -32,6 +32,7 @@ RSpec.describe "bundle doctor" do
before(:each) do
stat = double("stat")
unwritable_file = double("file")
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
allow(Find).to receive(:find).with(Bundler.bundle_path.to_s) { [unwritable_file] }
allow(File).to receive(:stat).with(unwritable_file) { stat }
allow(stat).to receive(:uid) { Process.uid }
@@ -72,6 +73,7 @@ RSpec.describe "bundle doctor" do
before(:each) do
@stat = double("stat")
@unwritable_file = double("file")
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
allow(Find).to receive(:find).with(Bundler.bundle_path.to_s) { [@unwritable_file] }
allow(File).to receive(:stat).with(@unwritable_file) { @stat }
end
@@ -87,7 +89,7 @@ RSpec.describe "bundle doctor" do
expect(@stdout.string).not_to include("No issues")
end
- context "when home contains files that are not owned by the current process" do
+ context "when home contains files that are not owned by the current process", :permissions do
before(:each) do
allow(@stat).to receive(:uid) { 0o0000 }
end
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index 42f760ab12..17fc959baf 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -68,6 +68,8 @@ RSpec.describe "bundle exec" do
end
it "respects custom process title when loading through ruby" do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~'RUBY'
Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15")
puts `ps -ocommand= -p#{$$}`
@@ -91,6 +93,8 @@ RSpec.describe "bundle exec" do
end
it "handles --keep-file-descriptors" do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
require "tempfile"
command = Tempfile.new("io-test")
@@ -122,12 +126,14 @@ RSpec.describe "bundle exec" do
end
it "can run a command named --verbose" do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
install_gemfile 'gem "rack"'
- File.open("--verbose", "w") do |f|
+ File.open(bundled_app("--verbose"), "w") do |f|
f.puts "#!/bin/sh"
f.puts "echo foobar"
end
- File.chmod(0o744, "--verbose")
+ File.chmod(0o744, bundled_app("--verbose"))
with_path_as(".") do
bundle "exec -- --verbose"
end
@@ -146,21 +152,17 @@ RSpec.describe "bundle exec" do
gem "rack", "0.9.1"
G
- Dir.chdir bundled_app2 do
- install_gemfile bundled_app2("Gemfile"), <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack_two", "1.0.0"
- G
- end
+ install_gemfile bundled_app2("Gemfile"), <<-G, :dir => bundled_app2
+ source "#{file_uri_for(gem_repo2)}"
+ gem "rack_two", "1.0.0"
+ G
bundle! "exec rackup"
expect(out).to eq("0.9.1")
- Dir.chdir bundled_app2 do
- bundle! "exec rackup"
- expect(out).to eq("1.0.0")
- end
+ bundle! "exec rackup", :dir => bundled_app2
+ expect(out).to eq("1.0.0")
end
context "with default gems" do
@@ -254,12 +256,10 @@ RSpec.describe "bundle exec" do
gem "rack", "0.9.1"
G
- Dir.chdir bundled_app2 do
- install_gemfile bundled_app2("Gemfile"), <<-G
- source "#{file_uri_for(gem_repo2)}"
- gem "rack_two", "1.0.0"
- G
- end
+ install_gemfile bundled_app2("Gemfile"), <<-G, :dir => bundled_app2
+ source "#{file_uri_for(gem_repo2)}"
+ gem "rack_two", "1.0.0"
+ G
bundle! "exec rackup"
@@ -286,6 +286,8 @@ RSpec.describe "bundle exec" do
end
it "does not duplicate already exec'ed RUBYOPT" do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
install_gemfile <<-G
gem "rack"
G
@@ -301,6 +303,8 @@ RSpec.describe "bundle exec" do
end
it "does not duplicate already exec'ed RUBYLIB" do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
install_gemfile <<-G
gem "rack"
G
@@ -368,6 +372,8 @@ RSpec.describe "bundle exec" do
each_prefix.call("exec") do |exec|
describe "when #{exec} is used" do
before(:each) do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
install_gemfile <<-G
gem "rack"
G
@@ -581,6 +587,8 @@ RSpec.describe "bundle exec" do
describe "with gems bundled for deployment" do
it "works when calling bundler from another script" do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
gemfile <<-G
module Monkey
def bin_path(a,b,c)
@@ -610,8 +618,8 @@ RSpec.describe "bundle exec" do
RUBY
before do
- path.open("w") {|f| f << executable }
- path.chmod(0o755)
+ bundled_app(path).open("w") {|f| f << executable }
+ bundled_app(path).chmod(0o755)
install_gemfile <<-G
gem "rack"
@@ -634,6 +642,8 @@ RSpec.describe "bundle exec" do
shared_examples_for "it runs" do
it "like a normally executed executable" do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
subject
expect(exitstatus).to eq(exit_code) if exitstatus
expect(err).to eq(expected_err)
@@ -782,7 +792,7 @@ __FILE__: #{path.to_s.inspect}
end
context "when the path is relative with a leading ./" do
- let(:path) { Pathname.new("./#{super().relative_path_from(Pathname.pwd)}") }
+ let(:path) { Pathname.new("./#{super().relative_path_from(bundled_app)}") }
pending "relative paths with ./ have absolute __FILE__"
end
@@ -813,6 +823,8 @@ __FILE__: #{path.to_s.inspect}
RUBY
it "receives the signal" do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
bundle!("exec #{path}") do |_, o, thr|
o.gets # Consumes 'Started' and ensures that thread has started
Process.kill("INT", thr.pid)
@@ -834,6 +846,8 @@ __FILE__: #{path.to_s.inspect}
RUBY
it "makes sure no unexpected signals are restored to DEFAULT" do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
test_signals.each do |n|
Signal.trap(n, "IGNORE")
end
@@ -858,6 +872,8 @@ __FILE__: #{path.to_s.inspect}
end
it "correctly shells out", :ruby_repo do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
+
file = bundled_app("file_that_bundle_execs.rb")
create_file(file, <<-RB)
#!#{Gem.ruby}
@@ -874,6 +890,7 @@ __FILE__: #{path.to_s.inspect}
let(:expected) { ruby "gem 'openssl', '< 999999'; require 'openssl'; puts OpenSSL::VERSION", :artifice => nil }
it "only leaves the default gem in the stdlib available" do
+ skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform?
skip "openssl isn't a default gem" if expected.empty?
install_gemfile! "" # must happen before installing the broken system gem
diff --git a/spec/commands/help_spec.rb b/spec/commands/help_spec.rb
index f4f90b9347..658b1374d4 100644
--- a/spec/commands/help_spec.rb
+++ b/spec/commands/help_spec.rb
@@ -28,6 +28,8 @@ RSpec.describe "bundle help" do
end
it "looks for a binary and executes it with --help option if it's named bundler-<task>" do
+ skip "obscure error" if Gem.win_platform?
+
File.open(tmp("bundler-testtasks"), "w", 0o755) do |f|
f.puts "#!/usr/bin/env ruby\nputs ARGV.join(' ')\n"
end
diff --git a/spec/commands/info_spec.rb b/spec/commands/info_spec.rb
index 881f66d440..b70b711127 100644
--- a/spec/commands/info_spec.rb
+++ b/spec/commands/info_spec.rb
@@ -11,15 +11,15 @@ RSpec.describe "bundle info" do
end
it "creates a Gemfile.lock when invoked with a gem name" do
- FileUtils.rm("Gemfile.lock")
+ FileUtils.rm(bundled_app_lock)
- bundle "info rails"
+ bundle! "info rails"
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
it "prints information if gem exists in bundle" do
- bundle "info rails"
+ bundle! "info rails"
expect(out).to include "* rails (2.3.2)
\tSummary: This is just a fake gem for testing
\tHomepage: http://example.com
@@ -27,12 +27,12 @@ RSpec.describe "bundle info" do
end
it "prints path if gem exists in bundle" do
- bundle "info rails --path"
+ bundle! "info rails --path"
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
it "prints the path to the running bundler" do
- bundle "info bundler --path"
+ bundle! "info bundler --path"
expect(out).to eq(root.to_s)
end
@@ -43,7 +43,7 @@ RSpec.describe "bundle info" do
context "given a default gem shippped in ruby", :ruby_repo do
it "prints information about the default gem" do
- bundle "info rdoc"
+ bundle! "info rdoc"
expect(out).to include("* rdoc")
expect(out).to include("Default Gem: yes")
end
@@ -51,7 +51,7 @@ RSpec.describe "bundle info" do
context "given a gem with metadata" do
it "prints the gem metadata" do
- bundle "info has_metadata"
+ bundle! "info has_metadata"
expect(out).to include "* has_metadata (1.0)
\tSummary: This is just a fake gem for testing
\tHomepage: http://example.com
@@ -92,7 +92,7 @@ RSpec.describe "bundle info" do
G
expect(the_bundle).to include_gems "foo 1.0"
- bundle "info foo"
+ bundle! "info foo"
expect(out).to include("foo (1.0 #{@git.ref_for("master", 6)}")
end
@@ -107,7 +107,7 @@ RSpec.describe "bundle info" do
G
expect(the_bundle).to include_gems "foo 1.0.omg"
- bundle "info foo"
+ bundle! "info foo"
expect(out).to include("foo (1.0 #{@git.ref_for("omg", 6)}")
end
@@ -117,7 +117,7 @@ RSpec.describe "bundle info" do
gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{sha}"
G
- bundle "info foo"
+ bundle! "info foo"
expect(out).to include("foo (1.0 #{sha[0..6]})")
end
@@ -134,14 +134,14 @@ RSpec.describe "bundle info" do
end
context "with a valid regexp for gem name" do
- it "presents alternatives" do
+ it "presents alternatives", :readline do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
gem "rack-obama"
G
- bundle "info rac"
+ bundle! "info rac"
expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
end
end
diff --git a/spec/commands/init_spec.rb b/spec/commands/init_spec.rb
index 7960ce85bd..ed52187115 100644
--- a/spec/commands/init_spec.rb
+++ b/spec/commands/init_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe "bundle init" do
it "generates a Gemfile" do
bundle! :init
expect(out).to include("Writing new Gemfile")
- expect(bundled_app("Gemfile")).to be_file
+ expect(bundled_app_gemfile).to be_file
end
context "when a Gemfile already exists" do
@@ -15,7 +15,7 @@ RSpec.describe "bundle init" do
end
it "does not change existing Gemfiles" do
- expect { bundle :init }.not_to change { File.read(bundled_app("Gemfile")) }
+ expect { bundle :init }.not_to change { File.read(bundled_app_gemfile) }
end
it "notifies the user that an existing Gemfile already exists" do
@@ -32,9 +32,7 @@ RSpec.describe "bundle init" do
FileUtils.mkdir bundled_app(subdir)
- Dir.chdir bundled_app(subdir) do
- bundle! :init
- end
+ bundle! :init, :dir => bundled_app(subdir)
expect(out).to include("Writing new Gemfile")
expect(bundled_app("#{subdir}/Gemfile")).to be_file
@@ -50,9 +48,7 @@ RSpec.describe "bundle init" do
mode = File.stat(bundled_app(subdir)).mode ^ 0o222
FileUtils.chmod mode, bundled_app(subdir)
- Dir.chdir bundled_app(subdir) do
- bundle :init
- end
+ bundle :init, :dir => bundled_app(subdir)
expect(err).to include("directory is not writable")
expect(Dir[bundled_app("#{subdir}/*")]).to be_empty
@@ -75,7 +71,7 @@ RSpec.describe "bundle init" do
bundle :init, :gemspec => spec_file
- gemfile = bundled_app("Gemfile").read
+ gemfile = bundled_app_gemfile.read
expect(gemfile).to match(%r{source 'https://rubygems.org'})
expect(gemfile.scan(/gem "rack", "= 1.0.1"/).size).to eq(1)
expect(gemfile.scan(/gem "rspec", "= 1.2"/).size).to eq(1)
@@ -133,9 +129,7 @@ RSpec.describe "bundle init" do
FileUtils.mkdir bundled_app(subdir)
- Dir.chdir bundled_app(subdir) do
- bundle! :init
- end
+ bundle! :init, :dir => bundled_app(subdir)
expect(out).to include("Writing new gems.rb")
expect(bundled_app("#{subdir}/gems.rb")).to be_file
diff --git a/spec/commands/inject_spec.rb b/spec/commands/inject_spec.rb
index 01c1f91877..78355edab3 100644
--- a/spec/commands/inject_spec.rb
+++ b/spec/commands/inject_spec.rb
@@ -10,9 +10,9 @@ RSpec.describe "bundle inject", :bundler => "< 3" do
context "without a lockfile" do
it "locks with the injected gems" do
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
bundle "inject 'rack-obama' '> 0'"
- expect(bundled_app("Gemfile.lock").read).to match(/rack-obama/)
+ expect(bundled_app_lock.read).to match(/rack-obama/)
end
end
@@ -22,15 +22,15 @@ RSpec.describe "bundle inject", :bundler => "< 3" do
end
it "adds the injected gems to the Gemfile" do
- expect(bundled_app("Gemfile").read).not_to match(/rack-obama/)
+ expect(bundled_app_gemfile.read).not_to match(/rack-obama/)
bundle "inject 'rack-obama' '> 0'"
- expect(bundled_app("Gemfile").read).to match(/rack-obama/)
+ expect(bundled_app_gemfile.read).to match(/rack-obama/)
end
it "locks with the injected gems" do
- expect(bundled_app("Gemfile.lock").read).not_to match(/rack-obama/)
+ expect(bundled_app_lock.read).not_to match(/rack-obama/)
bundle "inject 'rack-obama' '> 0'"
- expect(bundled_app("Gemfile.lock").read).to match(/rack-obama/)
+ expect(bundled_app_lock.read).to match(/rack-obama/)
end
end
@@ -54,7 +54,7 @@ Usage: "bundle inject GEM VERSION"
context "with source option" do
it "add gem with source option in gemfile" do
bundle "inject 'foo' '>0' --source #{file_uri_for(gem_repo1)}"
- gemfile = bundled_app("Gemfile").read
+ gemfile = bundled_app_gemfile.read
str = "gem \"foo\", \"> 0\", :source => \"#{file_uri_for(gem_repo1)}\""
expect(gemfile).to include str
end
@@ -63,14 +63,14 @@ Usage: "bundle inject GEM VERSION"
context "with group option" do
it "add gem with group option in gemfile" do
bundle "inject 'rack-obama' '>0' --group=development"
- gemfile = bundled_app("Gemfile").read
+ gemfile = bundled_app_gemfile.read
str = "gem \"rack-obama\", \"> 0\", :group => :development"
expect(gemfile).to include str
end
it "add gem with multiple groups in gemfile" do
bundle "inject 'rack-obama' '>0' --group=development,test"
- gemfile = bundled_app("Gemfile").read
+ gemfile = bundled_app_gemfile.read
str = "gem \"rack-obama\", \"> 0\", :groups => [:development, :test]"
expect(gemfile).to include str
end
@@ -88,13 +88,13 @@ Usage: "bundle inject GEM VERSION"
it "injects anyway" do
bundle "inject 'rack-obama' '> 0'"
- expect(bundled_app("Gemfile").read).to match(/rack-obama/)
+ expect(bundled_app_gemfile.read).to match(/rack-obama/)
end
it "locks with the injected gems" do
- expect(bundled_app("Gemfile.lock").read).not_to match(/rack-obama/)
+ expect(bundled_app_lock.read).not_to match(/rack-obama/)
bundle "inject 'rack-obama' '> 0'"
- expect(bundled_app("Gemfile.lock").read).to match(/rack-obama/)
+ expect(bundled_app_lock.read).to match(/rack-obama/)
end
it "restores frozen afterwards" do
@@ -111,7 +111,7 @@ Usage: "bundle inject GEM VERSION"
bundle "inject 'rack' '> 0'"
expect(err).to match(/trying to install in deployment mode after changing/)
- expect(bundled_app("Gemfile.lock").read).not_to match(/rack-obama/)
+ expect(bundled_app_lock.read).not_to match(/rack-obama/)
end
end
end
diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb
index b57d81b10a..9a4ce33a26 100644
--- a/spec/commands/install_spec.rb
+++ b/spec/commands/install_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe "bundle install with gem sources" do
G
expect(err).to include('StandardError, "FAIL"')
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
end
it "creates a Gemfile.lock" do
@@ -26,7 +26,7 @@ RSpec.describe "bundle install with gem sources" do
gem "rack"
G
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
it "does not create ./.bundle by default", :bundler => "< 3" do
@@ -66,13 +66,13 @@ RSpec.describe "bundle install with gem sources" do
gem 'rack'
G
- lockfile = File.read(bundled_app("Gemfile.lock"))
+ lockfile = File.read(bundled_app_lock)
install_gemfile <<-G
raise StandardError, "FAIL"
G
- expect(File.read(bundled_app("Gemfile.lock"))).to eq(lockfile)
+ expect(File.read(bundled_app_lock)).to eq(lockfile)
end
it "does not touch the lockfile if nothing changed" do
@@ -81,7 +81,7 @@ RSpec.describe "bundle install with gem sources" do
gem "rack"
G
- expect { run "1" }.not_to change { File.mtime(bundled_app("Gemfile.lock")) }
+ expect { run "1" }.not_to change { File.mtime(bundled_app_lock) }
end
it "fetches gems" do
@@ -218,6 +218,8 @@ RSpec.describe "bundle install with gem sources" do
describe "with a gem that installs multiple platforms" do
it "installs gems for the local platform as first choice" do
+ skip "version is 1.0, not 1.0.0" if Gem.win_platform?
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "platform_specific"
@@ -318,7 +320,7 @@ RSpec.describe "bundle install with gem sources" do
install_gemfile <<-G
G
- expect(File.exist?(bundled_app("Gemfile.lock"))).to eq(true)
+ expect(File.exist?(bundled_app_lock)).to eq(true)
end
context "throws a warning if a gem is added twice in Gemfile" do
@@ -372,6 +374,8 @@ RSpec.describe "bundle install with gem sources" do
end
it "gracefully handles error when rubygems server is unavailable" do
+ skip "networking issue" if Gem.win_platform?
+
install_gemfile <<-G, :artifice => nil
source "#{file_uri_for(gem_repo1)}"
source "http://0.0.0.0:9384" do
@@ -500,23 +504,20 @@ RSpec.describe "bundle install with gem sources" do
end
describe "when Bundler root contains regex chars" do
- before do
+ it "doesn't blow up" do
root_dir = tmp("foo[]bar")
FileUtils.mkdir_p(root_dir)
- in_app_root_custom(root_dir)
- end
- it "doesn't blow up" do
build_lib "foo"
gemfile = <<-G
gem 'foo', :path => "#{lib_path("foo-1.0")}"
G
- File.open("Gemfile", "w") do |file|
+ File.open("#{root_dir}/Gemfile", "w") do |file|
file.puts gemfile
end
- bundle :install
+ bundle :install, :dir => root_dir
expect(exitstatus).to eq(0) if exitstatus
end
@@ -536,7 +537,7 @@ RSpec.describe "bundle install with gem sources" do
end
end
- describe "when bundle path does not have write access" do
+ describe "when bundle path does not have write access", :permissions do
before do
FileUtils.mkdir_p(bundled_app("vendor"))
gemfile <<-G
diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb
index 1d9813a835..ad8f1d6f32 100644
--- a/spec/commands/lock_spec.rb
+++ b/spec/commands/lock_spec.rb
@@ -195,6 +195,8 @@ RSpec.describe "bundle lock" do
gem 'foo'
gem 'qux'
G
+
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
end
it "single gem updates dependent gem to minor" do
@@ -213,12 +215,15 @@ RSpec.describe "bundle lock" do
it "supports adding new platforms" do
bundle! "lock --add-platform java x86-mingw32"
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
lockfile = Bundler::LockfileParser.new(read_lockfile)
expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq)
end
it "supports adding the `ruby` platform" do
bundle! "lock --add-platform ruby"
+
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
lockfile = Bundler::LockfileParser.new(read_lockfile)
expect(lockfile.platforms).to match_array(local_platforms.unshift("ruby").uniq)
end
@@ -231,6 +236,7 @@ RSpec.describe "bundle lock" do
it "allows removing platforms" do
bundle! "lock --add-platform java x86-mingw32"
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
lockfile = Bundler::LockfileParser.new(read_lockfile)
expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq)
@@ -245,7 +251,7 @@ RSpec.describe "bundle lock" do
expect(err).to include("Removing all platforms from the bundle is not allowed")
end
- # from https://github.com/bundler/bundler/issues/4896
+ # from https://github.com/rubygems/bundler/issues/4896
it "properly adds platforms when platform requirements come from different dependencies" do
build_repo4 do
build_gem "ffi", "1.9.14"
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 2c8ab4b5ef..b8fbf8806a 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -17,7 +17,6 @@ RSpec.describe "bundle gem" do
let(:require_path) { "mygem" }
before do
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
git_config_content = <<-EOF
[user]
name = "Bundler User"
@@ -64,7 +63,7 @@ RSpec.describe "bundle gem" do
bundle! "gem #{gem_name} #{flags}"
end
- it "generates a gem skeleton with a .git folder" do
+ it "generates a gem skeleton with a .git folder", :readline do
gem_skeleton_assertions
expect(bundled_app("#{gem_name}/.git")).to exist
end
@@ -82,7 +81,7 @@ RSpec.describe "bundle gem" do
end
end
- context "when passing --no-git" do
+ context "when passing --no-git", :readline do
before do
bundle! "gem #{gem_name} --no-git"
end
@@ -163,13 +162,12 @@ RSpec.describe "bundle gem" do
end
it "includes rubocop in generated Gemfile" do
- Dir.chdir(bundled_app(gem_name)) do
- builder = Bundler::Dsl.new
- builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
- builder.dependencies
- rubocop_dep = builder.dependencies.find {|d| d.name == "rubocop" }
- expect(rubocop_dep).not_to be_nil
- end
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ builder = Bundler::Dsl.new
+ builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
+ builder.dependencies
+ rubocop_dep = builder.dependencies.find {|d| d.name == "rubocop" }
+ expect(rubocop_dep).not_to be_nil
end
end
@@ -187,17 +185,16 @@ RSpec.describe "bundle gem" do
end
it "does not include rubocop in generated Gemfile" do
- Dir.chdir(bundled_app(gem_name)) do
- builder = Bundler::Dsl.new
- builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
- builder.dependencies
- rubocop_dep = builder.dependencies.find {|d| d.name == "rubocop" }
- expect(rubocop_dep).to be_nil
- end
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ builder = Bundler::Dsl.new
+ builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
+ builder.dependencies
+ rubocop_dep = builder.dependencies.find {|d| d.name == "rubocop" }
+ expect(rubocop_dep).to be_nil
end
end
- context "README.md" do
+ context "README.md", :readline do
context "git config github.user present" do
before do
bundle! "gem #{gem_name}"
@@ -212,7 +209,7 @@ RSpec.describe "bundle gem" do
context "git config github.user is absent" do
before do
sys_exec("git config --unset github.user")
- bundle "gem #{gem_name}"
+ bundle! "gem #{gem_name}"
end
it "contribute URL set to [USERNAME]" do
@@ -222,18 +219,18 @@ RSpec.describe "bundle gem" do
end
end
- it "creates a new git repository" do
- bundle "gem #{gem_name}"
+ it "creates a new git repository", :readline do
+ bundle! "gem #{gem_name}"
expect(bundled_app("#{gem_name}/.git")).to exist
end
- context "when git is not available" do
+ context "when git is not available", :readline do
# This spec cannot have `git` available in the test env
before do
load_paths = [lib_dir, spec_dir]
load_path_str = "-I#{load_paths.join(File::PATH_SEPARATOR)}"
- sys_exec "#{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}", "PATH" => ""
+ sys_exec! "#{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}", :env => { "PATH" => "" }
end
it "creates the gem without the need for git" do
@@ -249,25 +246,23 @@ RSpec.describe "bundle gem" do
end
end
- it "generates a valid gemspec" do
+ it "generates a valid gemspec", :readline do
bundle! "gem newgem --bin"
prepare_gemspec(bundled_app("newgem", "newgem.gemspec"))
- Dir.chdir(bundled_app("newgem")) do
- gems = ["rake-12.3.2"]
- system_gems gems, :path => :bundle_path
- bundle! "exec rake build"
- end
+ gems = ["rake-12.3.2"]
+ system_gems gems, :path => :bundle_path, :bundle_dir => bundled_app("newgem")
+ bundle! "exec rake build", :dir => bundled_app("newgem")
expect(last_command.stdboth).not_to include("ERROR")
end
- context "gem naming with relative paths" do
+ context "gem naming with relative paths", :readline do
it "resolves ." do
create_temporary_dir("tmp")
- bundle "gem ."
+ bundle! "gem .", :dir => bundled_app("tmp")
expect(bundled_app("tmp/lib/tmp.rb")).to exist
end
@@ -275,7 +270,7 @@ RSpec.describe "bundle gem" do
it "resolves .." do
create_temporary_dir("temp/empty_dir")
- bundle "gem .."
+ bundle! "gem ..", :dir => bundled_app("temp/empty_dir")
expect(bundled_app("temp/lib/temp.rb")).to exist
end
@@ -283,14 +278,13 @@ RSpec.describe "bundle gem" do
it "resolves relative directory" do
create_temporary_dir("tmp/empty/tmp")
- bundle "gem ../../empty"
+ bundle! "gem ../../empty", :dir => bundled_app("tmp/empty/tmp")
expect(bundled_app("tmp/empty/lib/empty.rb")).to exist
end
def create_temporary_dir(dir)
- FileUtils.mkdir_p(dir)
- Dir.chdir(dir)
+ FileUtils.mkdir_p(bundled_app(dir))
end
end
@@ -327,9 +321,9 @@ RSpec.describe "bundle gem" do
context "git config user.{name,email} is not set" do
before do
- `git config --unset user.name`
- `git config --unset user.email`
- bundle "gem #{gem_name}"
+ sys_exec("git config --unset user.name", :dir => bundled_app)
+ sys_exec("git config --unset user.email", :dir => bundled_app)
+ bundle! "gem #{gem_name}"
end
it_should_behave_like "git config is absent"
@@ -376,15 +370,13 @@ RSpec.describe "bundle gem" do
file.puts rakefile
end
- Dir.chdir(bundled_app(gem_name)) do
- sys_exec(rake)
- expect(out).to include("SUCCESS")
- end
+ sys_exec(rake, :dir => bundled_app(gem_name))
+ expect(out).to include("SUCCESS")
end
context "--exe parameter set" do
before do
- bundle "gem #{gem_name} --exe"
+ bundle! "gem #{gem_name} --exe"
end
it "builds exe skeleton" do
@@ -398,7 +390,7 @@ RSpec.describe "bundle gem" do
context "--bin parameter set" do
before do
- bundle "gem #{gem_name} --bin"
+ bundle! "gem #{gem_name} --bin"
end
it "builds exe skeleton" do
@@ -412,7 +404,7 @@ RSpec.describe "bundle gem" do
context "no --test parameter" do
before do
- bundle "gem #{gem_name}"
+ bundle! "gem #{gem_name}"
end
it "doesn't create any spec/test file" do
@@ -420,13 +412,13 @@ RSpec.describe "bundle gem" do
expect(bundled_app("#{gem_name}/spec/#{require_path}_spec.rb")).to_not exist
expect(bundled_app("#{gem_name}/spec/spec_helper.rb")).to_not exist
expect(bundled_app("#{gem_name}/test/#{require_path}.rb")).to_not exist
- expect(bundled_app("#{gem_name}/test/minitest_helper.rb")).to_not exist
+ expect(bundled_app("#{gem_name}/test/test_helper.rb")).to_not exist
end
end
context "--test parameter set to rspec" do
before do
- bundle "gem #{gem_name} --test=rspec"
+ bundle! "gem #{gem_name} --test=rspec"
end
it "builds spec skeleton" do
@@ -436,13 +428,12 @@ RSpec.describe "bundle gem" do
end
it "depends on a specific version of rspec in generated Gemfile" do
- Dir.chdir(bundled_app(gem_name)) do
- builder = Bundler::Dsl.new
- builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
- builder.dependencies
- rspec_dep = builder.dependencies.find {|d| d.name == "rspec" }
- expect(rspec_dep).to be_specific
- end
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ builder = Bundler::Dsl.new
+ builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
+ builder.dependencies
+ rspec_dep = builder.dependencies.find {|d| d.name == "rspec" }
+ expect(rspec_dep).to be_specific
end
it "requires the main file" do
@@ -457,7 +448,7 @@ RSpec.describe "bundle gem" do
context "gem.test setting set to rspec" do
before do
bundle "config set gem.test rspec"
- bundle "gem #{gem_name}"
+ bundle! "gem #{gem_name}"
end
it "builds spec skeleton" do
@@ -470,7 +461,7 @@ RSpec.describe "bundle gem" do
context "gem.test setting set to rspec and --test is set to minitest" do
before do
bundle "config set gem.test rspec"
- bundle "gem #{gem_name} --test=minitest"
+ bundle! "gem #{gem_name} --test=minitest"
end
it "builds spec skeleton" do
@@ -485,13 +476,12 @@ RSpec.describe "bundle gem" do
end
it "depends on a specific version of minitest" do
- Dir.chdir(bundled_app(gem_name)) do
- builder = Bundler::Dsl.new
- builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
- builder.dependencies
- minitest_dep = builder.dependencies.find {|d| d.name == "minitest" }
- expect(minitest_dep).to be_specific
- end
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ builder = Bundler::Dsl.new
+ builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
+ builder.dependencies
+ minitest_dep = builder.dependencies.find {|d| d.name == "minitest" }
+ expect(minitest_dep).to be_specific
end
it "builds spec skeleton" do
@@ -503,7 +493,7 @@ RSpec.describe "bundle gem" do
expect(bundled_app("#{gem_name}/test/test_helper.rb").read).to include(%(require "#{require_path}"))
end
- it "requires 'minitest_helper'" do
+ it "requires 'test_helper'" do
expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb").read).to include(%(require "test_helper"))
end
@@ -515,6 +505,62 @@ RSpec.describe "bundle gem" do
context "gem.test setting set to minitest" do
before do
bundle "config set gem.test minitest"
+ bundle! "gem #{gem_name}"
+ end
+
+ it "creates a default rake task to run the test suite" do
+ rakefile = strip_whitespace <<-RAKEFILE
+ require "bundler/gem_tasks"
+ require "rake/testtask"
+
+ Rake::TestTask.new(:test) do |t|
+ t.libs << "test"
+ t.libs << "lib"
+ t.test_files = FileList["test/**/*_test.rb"]
+ end
+
+ task :default => :test
+ RAKEFILE
+
+ expect(bundled_app("#{gem_name}/Rakefile").read).to eq(rakefile)
+ end
+ end
+
+ context "--test parameter set to test-unit" do
+ before do
+ bundle "gem #{gem_name} --test=test-unit"
+ end
+
+ it "depends on a specific version of test-unit" do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ builder = Bundler::Dsl.new
+ builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
+ builder.dependencies
+ test_unit_dep = builder.dependencies.find {|d| d.name == "test-unit" }
+ expect(test_unit_dep).to be_specific
+ end
+
+ it "builds spec skeleton" do
+ expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb")).to exist
+ expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist
+ end
+
+ it "requires the main file" do
+ expect(bundled_app("#{gem_name}/test/test_helper.rb").read).to include(%(require "#{require_path}"))
+ end
+
+ it "requires 'test_helper'" do
+ expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb").read).to include(%(require "test_helper"))
+ end
+
+ it "creates a default test which fails" do
+ expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb").read).to include("assert_equal(\"expected\", \"actual\")")
+ end
+ end
+
+ context "gem.test setting set to test-unit" do
+ before do
+ bundle "config set gem.test test-unit"
bundle "gem #{gem_name}"
end
@@ -538,12 +584,12 @@ RSpec.describe "bundle gem" do
context "--test with no arguments" do
before do
- bundle "gem #{gem_name} --test"
+ bundle! "gem #{gem_name} --test"
end
it "defaults to rspec" do
expect(bundled_app("#{gem_name}/spec/spec_helper.rb")).to exist
- expect(bundled_app("#{gem_name}/test/minitest_helper.rb")).to_not exist
+ expect(bundled_app("#{gem_name}/test/test_helper.rb")).to_not exist
end
it "creates a .travis.yml file to test the library against the current Ruby version on Travis CI" do
@@ -554,58 +600,67 @@ RSpec.describe "bundle gem" do
context "--edit option" do
it "opens the generated gemspec in the user's text editor" do
output = bundle "gem #{gem_name} --edit=echo"
- gemspec_path = File.join(Dir.pwd, gem_name, "#{gem_name}.gemspec")
+ gemspec_path = File.join(bundled_app, gem_name, "#{gem_name}.gemspec")
expect(output).to include("echo \"#{gemspec_path}\"")
end
end
end
- context "testing --mit and --coc options against bundle config settings" do
+ context "testing --mit and --coc options against bundle config settings", :readline do
let(:gem_name) { "test-gem" }
let(:require_path) { "test/gem" }
context "with mit option in bundle config settings set to true" do
before do
- global_config "BUNDLE_GEM__MIT" => "true", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__RUBOCOP" => "false", "BUNDLE_GEM__COC" => "false"
+ global_config "BUNDLE_GEM__MIT" => "true"
end
it_behaves_like "--mit flag"
it_behaves_like "--no-mit flag"
end
context "with mit option in bundle config settings set to false" do
+ before do
+ global_config "BUNDLE_GEM__MIT" => "false"
+ end
it_behaves_like "--mit flag"
it_behaves_like "--no-mit flag"
end
context "with coc option in bundle config settings set to true" do
before do
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__RUBOCOP" => "false", "BUNDLE_GEM__COC" => "true"
+ global_config "BUNDLE_GEM__COC" => "true"
end
it_behaves_like "--coc flag"
it_behaves_like "--no-coc flag"
end
context "with coc option in bundle config settings set to false" do
+ before do
+ global_config "BUNDLE_GEM__COC" => "false"
+ end
it_behaves_like "--coc flag"
it_behaves_like "--no-coc flag"
end
context "with rubocop option in bundle config settings set to true" do
before do
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__RUBOCOP" => "true"
+ global_config "BUNDLE_GEM__RUBOCOP" => "true"
end
it_behaves_like "--rubocop flag"
it_behaves_like "--no-rubocop flag"
end
context "with rubocop option in bundle config settings set to false" do
+ before do
+ global_config "BUNDLE_GEM__RUBOCOP" => "false"
+ end
it_behaves_like "--rubocop flag"
it_behaves_like "--no-rubocop flag"
end
end
- context "gem naming with underscore" do
+ context "gem naming with underscore", :readline do
let(:gem_name) { "test_gem" }
let(:require_path) { "test_gem" }
@@ -647,7 +702,7 @@ RSpec.describe "bundle gem" do
ext.lib_dir = "lib/#{gem_name}"
end
- task :default => [:clobber, :compile, :spec]
+ task :default => [:clobber, :compile]
RAKEFILE
expect(bundled_app("#{gem_name}/Rakefile").read).to eq(rakefile)
@@ -655,7 +710,7 @@ RSpec.describe "bundle gem" do
end
end
- context "gem naming with dashed" do
+ context "gem naming with dashed", :readline do
let(:gem_name) { "test-gem" }
let(:require_path) { "test/gem" }
@@ -673,7 +728,7 @@ RSpec.describe "bundle gem" do
end
describe "uncommon gem names" do
- it "can deal with two dashes" do
+ it "can deal with two dashes", :readline do
bundle! "gem a--a"
expect(bundled_app("a--a/a--a.gemspec")).to exist
@@ -703,7 +758,7 @@ Usage: "bundle gem NAME [OPTIONS]"
end
end
- describe "#ensure_safe_gem_name" do
+ describe "#ensure_safe_gem_name", :readline do
before do
bundle "gem #{subject}"
end
@@ -729,11 +784,11 @@ Usage: "bundle gem NAME [OPTIONS]"
end
end
- context "on first run" do
+ context "on first run", :readline do
it "asks about test framework" do
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__COC" => "false"
- bundle "gem foobar" do |input, _, _|
+ bundle! "gem foobar" do |input, _, _|
input.puts "rspec"
end
@@ -756,7 +811,7 @@ Usage: "bundle gem NAME [OPTIONS]"
bundle "config list"
- bundle "gem foobar" do |input, _, _|
+ bundle! "gem foobar" do |input, _, _|
input.puts "yes"
end
@@ -766,7 +821,7 @@ Usage: "bundle gem NAME [OPTIONS]"
it "asks about CoC" do
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false"
- bundle "gem foobar" do |input, _, _|
+ bundle! "gem foobar" do |input, _, _|
input.puts "yes"
end
@@ -774,18 +829,18 @@ Usage: "bundle gem NAME [OPTIONS]"
end
end
- context "on conflicts with a previously created file" do
+ context "on conflicts with a previously created file", :readline do
it "should fail gracefully" do
- FileUtils.touch("conflict-foobar")
+ FileUtils.touch(bundled_app("conflict-foobar"))
bundle "gem conflict-foobar"
expect(err).to include("Errno::ENOTDIR")
expect(exitstatus).to eql(32) if exitstatus
end
end
- context "on conflicts with a previously created directory" do
+ context "on conflicts with a previously created directory", :readline do
it "should succeed" do
- FileUtils.mkdir_p("conflict-foobar/Gemfile")
+ FileUtils.mkdir_p(bundled_app("conflict-foobar/Gemfile"))
bundle! "gem conflict-foobar"
expect(out).to include("file_clash conflict-foobar/Gemfile").
and include "Initializing git repo in #{bundled_app("conflict-foobar")}"
diff --git a/spec/commands/open_spec.rb b/spec/commands/open_spec.rb
index 8fae4af5b4..31dc0315ac 100644
--- a/spec/commands/open_spec.rb
+++ b/spec/commands/open_spec.rb
@@ -58,7 +58,7 @@ RSpec.describe "bundle open" do
expect(out).to include("bundler_editor #{default_bundle_path("gems", "activerecord-2.3.2")}")
end
- it "select the gem from many match gems" do
+ it "select the gem from many match gems", :readline do
env = { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" }
bundle "open active", :env => env do |input, _, _|
input.puts "2"
@@ -67,7 +67,7 @@ RSpec.describe "bundle open" do
expect(out).to match(/bundler_editor #{default_bundle_path('gems', 'activerecord-2.3.2')}\z/)
end
- it "allows selecting exit from many match gems" do
+ it "allows selecting exit from many match gems", :readline do
env = { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" }
bundle! "open active", :env => env do |input, _, _|
input.puts "0"
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index 94ceb86e30..15336137b6 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -28,6 +28,8 @@ RSpec.describe "bundle pristine", :ruby_repo do
gemspec
G
+
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
end
context "when sourced from RubyGems" do
@@ -112,7 +114,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
it "reinstall gemspec dependency" do
spec = Bundler.definition.specs["baz-dev"].first
- changed_file = Pathname.new(spec.full_gem_path).join("lib/baz-dev.rb")
+ changed_file = Pathname.new(spec.full_gem_path).join("lib/baz/dev.rb")
diff = "#Pristine spec changes"
File.open(changed_file, "a") {|f| f.puts "#Pristine spec changes" }
diff --git a/spec/commands/remove_spec.rb b/spec/commands/remove_spec.rb
index 402faaf1f3..ef313928e2 100644
--- a/spec/commands/remove_spec.rb
+++ b/spec/commands/remove_spec.rb
@@ -54,7 +54,7 @@ RSpec.describe "bundle remove" do
bundle "remove rack"
- expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
+ expect(err).to include("`rack` is not specified in #{bundled_app_gemfile} so it could not be removed.")
end
end
end
@@ -91,7 +91,7 @@ RSpec.describe "bundle remove" do
bundle "remove rails rack minitest"
- expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
+ expect(err).to include("`rack` is not specified in #{bundled_app_gemfile} so it could not be removed.")
gemfile_should_be <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -436,7 +436,7 @@ RSpec.describe "bundle remove" do
bundle "remove rack"
- expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
+ expect(err).to include("`rack` is not specified in #{bundled_app_gemfile} so it could not be removed.")
end
end
diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb
index 61b8f73e7f..5dd800e7c4 100644
--- a/spec/commands/show_spec.rb
+++ b/spec/commands/show_spec.rb
@@ -10,28 +10,28 @@ RSpec.describe "bundle show", :bundler => "< 3" do
end
it "creates a Gemfile.lock if one did not exist" do
- FileUtils.rm("Gemfile.lock")
+ FileUtils.rm(bundled_app_lock)
- bundle "show"
+ bundle! "show"
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
it "creates a Gemfile.lock when invoked with a gem name" do
- FileUtils.rm("Gemfile.lock")
+ FileUtils.rm(bundled_app_lock)
- bundle "show rails"
+ bundle! "show rails"
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
it "prints path if gem exists in bundle" do
- bundle "show rails"
+ bundle! "show rails"
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
it "prints path if gem exists in bundle (with --paths option)" do
- bundle "show rails --paths"
+ bundle! "show rails --paths"
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
@@ -45,7 +45,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do
end
it "prints the path to the running bundler" do
- bundle "show bundler"
+ bundle! "show bundler"
expect(out).to eq(root.to_s)
end
@@ -55,7 +55,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do
end
it "prints path of all gems in bundle sorted by name" do
- bundle "show --paths"
+ bundle! "show --paths"
expect(out).to include(default_bundle_path("gems", "rake-12.3.2").to_s)
expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s)
@@ -66,7 +66,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do
end
it "prints summary of gems" do
- bundle "show --verbose"
+ bundle! "show --verbose"
expect(out).to include <<~MSG
* actionmailer (2.3.2)
@@ -77,7 +77,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do
end
it "includes bundler in the summary of gems" do
- bundle "show --verbose"
+ bundle! "show --verbose"
expect(out).to include <<~MSG
* bundler (#{Bundler::VERSION})
@@ -99,7 +99,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do
G
expect(the_bundle).to include_gems "foo 1.0"
- bundle :show
+ bundle! :show
expect(out).to include("foo (1.0 #{@git.ref_for("master", 6)}")
end
@@ -114,7 +114,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do
G
expect(the_bundle).to include_gems "foo 1.0.omg"
- bundle :show
+ bundle! :show
expect(out).to include("foo (1.0 #{@git.ref_for("omg", 6)}")
end
@@ -124,7 +124,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do
gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{sha}"
G
- bundle :show
+ bundle! :show
expect(out).to include("foo (1.0 #{sha[0..6]})")
end
@@ -143,13 +143,12 @@ RSpec.describe "bundle show", :bundler => "< 3" do
context "in a fresh gem in a blank git repo" do
before :each do
build_git "foo", :path => lib_path("foo")
- in_app_root_custom lib_path("foo")
- File.open("Gemfile", "w") {|f| f.puts "gemspec" }
- sys_exec "rm -rf .git && git init"
+ File.open(lib_path("foo/Gemfile"), "w") {|f| f.puts "gemspec" }
+ sys_exec "rm -rf .git && git init", :dir => lib_path("foo")
end
it "does not output git errors" do
- bundle :show
+ bundle :show, :dir => lib_path("foo")
expect(err_without_deprecations).to be_empty
end
end
@@ -161,19 +160,19 @@ RSpec.describe "bundle show", :bundler => "< 3" do
G
bundle "config set auto_install 1"
- bundle :show
+ bundle! :show
expect(out).to include("Installing foo 1.0")
end
context "with a valid regexp for gem name" do
- it "presents alternatives" do
+ it "presents alternatives", :readline do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
gem "rack-obama"
G
- bundle "show rac"
+ bundle! "show rac"
expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
end
end
@@ -193,7 +192,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do
end
context "--outdated option" do
- # Regression test for https://github.com/bundler/bundler/issues/5375
+ # Regression test for https://github.com/rubygems/bundler/issues/5375
before do
build_repo2
end
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index e4449312eb..5a7d26353c 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe "bundle update" do
exit!
G
bundle "update"
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
end
@@ -54,7 +54,7 @@ RSpec.describe "bundle update" do
exit!
G
bundle "update", :all => true
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
end
@@ -831,6 +831,7 @@ RSpec.describe "bundle update --bundler" do
source "#{file_uri_for(gem_repo4)}"
gem "rack"
G
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2')
FileUtils.rm_r gem_repo4
diff --git a/spec/install/allow_offline_install_spec.rb b/spec/install/allow_offline_install_spec.rb
index 8af88b7efe..2662c12953 100644
--- a/spec/install/allow_offline_install_spec.rb
+++ b/spec/install/allow_offline_install_spec.rb
@@ -7,6 +7,8 @@ RSpec.describe "bundle install with :allow_offline_install" do
context "with no cached data locally" do
it "still installs" do
+ skip "corrupt test gem" if Gem.win_platform?
+
install_gemfile! <<-G, :artifice => "compact_index"
source "http://testgemserver.local"
gem "rack-obama"
@@ -26,6 +28,8 @@ RSpec.describe "bundle install with :allow_offline_install" do
context "with cached data locally" do
it "will install from the compact index" do
+ skip "corrupt test gem" if Gem.win_platform?
+
system_gems ["rack-1.0.0"], :path => :bundle_path
bundle! "config set clean false"
@@ -70,6 +74,8 @@ RSpec.describe "bundle install with :allow_offline_install" do
end
it "will install from a cached git repo" do
+ skip "doesn't print errors" if Gem.win_platform?
+
git = build_git "a", "1.0.0", :path => lib_path("a")
update_git("a", :path => git.path, :branch => "new_branch")
install_gemfile! <<-G
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index f92a531bf5..5031bd9aa0 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -43,13 +43,12 @@ RSpec.describe "install with --deployment or --frozen" do
it "still works if you are not in the app directory and specify --gemfile" do
bundle! "install"
- Dir.chdir tmp do
- simulate_new_machine
- bundle! :install,
- forgotten_command_line_options(:gemfile => "#{tmp}/bundled_app/Gemfile",
- :deployment => true,
- :path => "vendor/bundle")
- end
+ simulate_new_machine
+ bundle! :install,
+ forgotten_command_line_options(:gemfile => "#{tmp}/bundled_app/Gemfile",
+ :deployment => true,
+ :path => "vendor/bundle",
+ :dir => tmp)
expect(the_bundle).to include_gems "rack 1.0"
end
@@ -65,6 +64,8 @@ RSpec.describe "install with --deployment or --frozen" do
end
it "works when you bundle exec bundle" do
+ skip "doesn't find bundle" if Gem.win_platform?
+
bundle! :install
bundle "install --deployment"
bundle! "exec bundle check"
@@ -83,6 +84,8 @@ RSpec.describe "install with --deployment or --frozen" do
end
it "works when there are credentials in the source URL" do
+ skip "corrupt test gem" if Gem.win_platform?
+
install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
source "http://user:pass@localgemserver.test/"
diff --git a/spec/install/gemfile/eval_gemfile_spec.rb b/spec/install/gemfile/eval_gemfile_spec.rb
index 7df94aaff5..69341250c3 100644
--- a/spec/install/gemfile/eval_gemfile_spec.rb
+++ b/spec/install/gemfile/eval_gemfile_spec.rb
@@ -28,8 +28,8 @@ RSpec.describe "bundle install with gemfile that uses eval_gemfile" do
context "eval-ed Gemfile has relative-path gems" do
before do
- build_lib("a", :path => "gems/a")
- create_file "nested/Gemfile-nested", <<-G
+ build_lib("a", :path => bundled_app("gems/a"))
+ create_file bundled_app("nested/Gemfile-nested"), <<-G
gem "a", :path => "../gems/a"
G
diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb
index c50f8c9668..b28d70a798 100644
--- a/spec/install/gemfile/gemspec_spec.rb
+++ b/spec/install/gemfile/gemspec_spec.rb
@@ -120,18 +120,16 @@ RSpec.describe "bundle install from an existing gemspec" do
s.add_development_dependency "rake", "=12.3.2"
end
- Dir.chdir(tmp.join("foo")) do
- bundle "install"
- # This should really be able to rely on $stderr, but, it's not written
- # right, so we can't. In fact, this is a bug negation test, and so it'll
- # ghost pass in future, and will only catch a regression if the message
- # doesn't change. Exit codes should be used correctly (they can be more
- # than just 0 and 1).
- output = bundle("install --deployment")
- expect(output).not_to match(/You have added to the Gemfile/)
- expect(output).not_to match(/You have deleted from the Gemfile/)
- expect(output).not_to match(/install in deployment mode after changing/)
- end
+ bundle "install", :dir => tmp.join("foo")
+ # This should really be able to rely on $stderr, but, it's not written
+ # right, so we can't. In fact, this is a bug negation test, and so it'll
+ # ghost pass in future, and will only catch a regression if the message
+ # doesn't change. Exit codes should be used correctly (they can be more
+ # than just 0 and 1).
+ output = bundle("install --deployment", :dir => tmp.join("foo"))
+ expect(output).not_to match(/You have added to the Gemfile/)
+ expect(output).not_to match(/You have deleted from the Gemfile/)
+ expect(output).not_to match(/install in deployment mode after changing/)
end
it "should match a lockfile without needing to re-resolve" do
@@ -201,7 +199,7 @@ RSpec.describe "bundle install from an existing gemspec" do
it "allows the gemspec to activate other gems" do
ENV["BUNDLE_PATH__SYSTEM"] = "true"
- # see https://github.com/bundler/bundler/issues/5409
+ # see https://github.com/rubygems/bundler/issues/5409
#
# issue was caused by rubygems having an unresolved gem during a require,
# so emulate that
@@ -210,7 +208,7 @@ RSpec.describe "bundle install from an existing gemspec" do
build_lib("foo", :path => bundled_app)
gemspec = bundled_app("foo.gemspec").read
bundled_app("foo.gemspec").open("w") do |f|
- f.write "#{gemspec.strip}.tap { gem 'rack-obama'; require 'rack-obama' }"
+ f.write "#{gemspec.strip}.tap { gem 'rack-obama'; require 'rack/obama' }"
end
install_gemfile! <<-G
@@ -333,6 +331,8 @@ RSpec.describe "bundle install from an existing gemspec" do
let(:platform) { "ruby" }
before do
+ skip "not installing for some reason" if Gem.win_platform?
+
build_lib("foo", :path => tmp.join("foo")) do |s|
s.add_dependency "rack", "=1.0.0"
end
@@ -425,7 +425,7 @@ RSpec.describe "bundle install from an existing gemspec" do
end
end
- build_lib "foo", :path => "." do |s|
+ build_lib "foo", :path => bundled_app do |s|
if platform_specific_type == :runtime
s.add_runtime_dependency dependency
elsif platform_specific_type == :development
diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb
index 00f8e96625..067de1777d 100644
--- a/spec/install/gemfile/git_spec.rb
+++ b/spec/install/gemfile/git_spec.rb
@@ -57,22 +57,18 @@ RSpec.describe "bundle install with git sources" do
it "does not update the git source implicitly" do
update_git "foo"
- in_app_root2 do
- install_gemfile bundled_app2("Gemfile"), <<-G
- git "#{lib_path("foo-1.0")}" do
- gem 'foo'
- end
- G
- end
+ install_gemfile bundled_app2("Gemfile"), <<-G, :dir => bundled_app2
+ git "#{lib_path("foo-1.0")}" do
+ gem 'foo'
+ end
+ G
- in_app_root do
- run <<-RUBY
- require 'foo'
- puts "fail" if defined?(FOO_PREV_REF)
- RUBY
+ run <<-RUBY
+ require 'foo'
+ puts "fail" if defined?(FOO_PREV_REF)
+ RUBY
- expect(out).to be_empty
- end
+ expect(out).to be_empty
end
it "sets up git gem executables on the path" do
@@ -129,19 +125,19 @@ RSpec.describe "bundle install with git sources" do
it "still works after moving the application directory" do
bundle "install --path vendor/bundle"
+
FileUtils.mv bundled_app, tmp("bundled_app.bck")
- Dir.chdir tmp("bundled_app.bck")
- expect(the_bundle).to include_gems "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0", :dir => tmp("bundled_app.bck")
end
it "can still install after moving the application directory" do
bundle "install --path vendor/bundle"
+
FileUtils.mv bundled_app, tmp("bundled_app.bck")
update_git "foo", "1.1", :path => lib_path("foo-1.0")
- Dir.chdir tmp("bundled_app.bck")
gemfile tmp("bundled_app.bck/Gemfile"), <<-G
source "#{file_uri_for(gem_repo1)}"
git "#{lib_path("foo-1.0")}" do
@@ -151,9 +147,9 @@ RSpec.describe "bundle install with git sources" do
gem "rack", "1.0"
G
- bundle "update foo"
+ bundle "update foo", :dir => tmp("bundled_app.bck")
- expect(the_bundle).to include_gems "foo 1.1", "rack 1.0"
+ expect(the_bundle).to include_gems "foo 1.1", "rack 1.0", :dir => tmp("bundled_app.bck")
end
end
@@ -220,9 +216,7 @@ RSpec.describe "bundle install with git sources" do
s.write("lib/foo.rb", "raise 'FAIL'")
end
- Dir.chdir(lib_path("foo-1.0")) do
- `git update-ref -m "Bundler Spec!" refs/bundler/1 master~1`
- end
+ sys_exec("git update-ref -m \"Bundler Spec!\" refs/bundler/1 master~1", :dir => lib_path("foo-1.0"))
# want to ensure we don't fallback to HEAD
update_git "foo", :path => lib_path("foo-1.0"), :branch => "rando" do |s|
@@ -256,9 +250,7 @@ RSpec.describe "bundle install with git sources" do
s.write("lib/foo.rb", "raise 'FAIL'")
end
- Dir.chdir(lib_path("foo-1.0")) do
- `git update-ref -m "Bundler Spec!" refs/bundler/1 master~1`
- end
+ sys_exec("git update-ref -m \"Bundler Spec!\" refs/bundler/1 master~1", :dir => lib_path("foo-1.0"))
# want to ensure we don't fallback to HEAD
update_git "foo", :path => lib_path("foo-1.0"), :branch => "rando" do |s|
@@ -281,9 +273,7 @@ RSpec.describe "bundle install with git sources" do
end
it "does not download random non-head refs" do
- Dir.chdir(lib_path("foo-1.0")) do
- sys_exec!('git update-ref -m "Bundler Spec!" refs/bundler/1 master~1')
- end
+ sys_exec("git update-ref -m \"Bundler Spec!\" refs/bundler/1 master~1", :dir => lib_path("foo-1.0"))
bundle! "config set global_gem_cache true"
@@ -296,9 +286,7 @@ RSpec.describe "bundle install with git sources" do
# ensure we also git fetch after cloning
bundle! :update, :all => true
- Dir.chdir(Dir[home(".bundle/cache/git/foo-*")].first) do
- sys_exec("git ls-remote .")
- end
+ sys_exec("git ls-remote .", :dir => Dir[home(".bundle/cache/git/foo-*")].first)
expect(out).not_to include("refs/bundler/1")
end
@@ -307,11 +295,10 @@ RSpec.describe "bundle install with git sources" do
describe "when specifying a branch" do
let(:branch) { "branch" }
let(:repo) { build_git("foo").path }
- before(:each) do
- update_git("foo", :path => repo, :branch => branch)
- end
it "works" do
+ update_git("foo", :path => repo, :branch => branch)
+
install_gemfile <<-G
git "#{repo}", :branch => #{branch.dump} do
gem "foo"
@@ -324,6 +311,10 @@ RSpec.describe "bundle install with git sources" do
context "when the branch starts with a `#`" do
let(:branch) { "#149/redirect-url-fragment" }
it "works" do
+ skip "git does not accept this" if Gem.win_platform?
+
+ update_git("foo", :path => repo, :branch => branch)
+
install_gemfile <<-G
git "#{repo}", :branch => #{branch.dump} do
gem "foo"
@@ -337,6 +328,10 @@ RSpec.describe "bundle install with git sources" do
context "when the branch includes quotes" do
let(:branch) { %('") }
it "works" do
+ skip "git does not accept this" if Gem.win_platform?
+
+ update_git("foo", :path => repo, :branch => branch)
+
install_gemfile <<-G
git "#{repo}", :branch => #{branch.dump} do
gem "foo"
@@ -351,11 +346,10 @@ RSpec.describe "bundle install with git sources" do
describe "when specifying a tag" do
let(:tag) { "tag" }
let(:repo) { build_git("foo").path }
- before(:each) do
- update_git("foo", :path => repo, :tag => tag)
- end
it "works" do
+ update_git("foo", :path => repo, :tag => tag)
+
install_gemfile <<-G
git "#{repo}", :tag => #{tag.dump} do
gem "foo"
@@ -368,6 +362,10 @@ RSpec.describe "bundle install with git sources" do
context "when the tag starts with a `#`" do
let(:tag) { "#149/redirect-url-fragment" }
it "works" do
+ skip "git does not accept this" if Gem.win_platform?
+
+ update_git("foo", :path => repo, :tag => tag)
+
install_gemfile <<-G
git "#{repo}", :tag => #{tag.dump} do
gem "foo"
@@ -381,6 +379,10 @@ RSpec.describe "bundle install with git sources" do
context "when the tag includes quotes" do
let(:tag) { %('") }
it "works" do
+ skip "git does not accept this" if Gem.win_platform?
+
+ update_git("foo", :path => repo, :tag => tag)
+
install_gemfile <<-G
git "#{repo}", :tag => #{tag.dump} do
gem "foo"
@@ -463,7 +465,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- lockfile0 = File.read(bundled_app("Gemfile.lock"))
+ lockfile0 = File.read(bundled_app_lock)
FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
update_git "rack", "0.8", :path => lib_path("local-rack") do |s|
@@ -473,7 +475,7 @@ RSpec.describe "bundle install with git sources" do
bundle %(config set local.rack #{lib_path("local-rack")})
run "require 'rack'"
- lockfile1 = File.read(bundled_app("Gemfile.lock"))
+ lockfile1 = File.read(bundled_app_lock)
expect(lockfile1).not_to eq(lockfile0)
end
@@ -485,7 +487,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- lockfile0 = File.read(bundled_app("Gemfile.lock"))
+ lockfile0 = File.read(bundled_app_lock)
FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
update_git "rack", "0.8", :path => lib_path("local-rack")
@@ -493,7 +495,7 @@ RSpec.describe "bundle install with git sources" do
bundle %(config set local.rack #{lib_path("local-rack")})
bundle :install
- lockfile1 = File.read(bundled_app("Gemfile.lock"))
+ lockfile1 = File.read(bundled_app_lock)
expect(lockfile1).not_to eq(lockfile0)
end
@@ -621,6 +623,8 @@ RSpec.describe "bundle install with git sources" do
end
it "installs dependencies from git even if a newer gem is available elsewhere" do
+ skip "override is not winning" if Gem.win_platform?
+
system_gems "rack-1.0.0"
build_lib "rack", "1.0", :path => lib_path("nested/bar") do |s|
@@ -817,9 +821,7 @@ RSpec.describe "bundle install with git sources" do
bundle "update", :all => true
expect(the_bundle).to include_gems "forced 1.1"
- Dir.chdir(lib_path("forced-1.0")) do
- `git reset --hard HEAD^`
- end
+ sys_exec("git reset --hard HEAD^", :dir => lib_path("forced-1.0"))
bundle "update", :all => true
expect(the_bundle).to include_gems "forced 1.0"
@@ -830,10 +832,8 @@ RSpec.describe "bundle install with git sources" do
build_git "has_submodule", "1.0" do |s|
s.add_dependency "submodule"
end
- Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
- `git commit -m "submodulator"`
- end
+ sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", :dir => lib_path("has_submodule-1.0")
+ sys_exec "git commit -m \"submodulator\"", :dir => lib_path("has_submodule-1.0")
install_gemfile <<-G
git "#{lib_path("has_submodule-1.0")}" do
@@ -850,10 +850,8 @@ RSpec.describe "bundle install with git sources" do
build_git "has_submodule", "1.0" do |s|
s.add_dependency "submodule"
end
- Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
- `git commit -m "submodulator"`
- end
+ sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", :dir => lib_path("has_submodule-1.0")
+ sys_exec "git commit -m \"submodulator\"", :dir => lib_path("has_submodule-1.0")
install_gemfile <<-G
git "#{lib_path("has_submodule-1.0")}", :submodules => true do
@@ -916,6 +914,8 @@ RSpec.describe "bundle install with git sources" do
end
it "prints a friendly error if a file blocks the git repo" do
+ skip "drive letter is not detected correctly in error message" if Gem.win_platform?
+
build_git "foo"
FileUtils.mkdir_p(default_bundle_path)
@@ -943,7 +943,7 @@ RSpec.describe "bundle install with git sources" do
gem "bar", :git => "#{lib_path("nested")}"
G
- expect(File.read(bundled_app("Gemfile.lock")).scan("GIT").size).to eq(1)
+ expect(File.read(bundled_app_lock).scan("GIT").size).to eq(1)
end
describe "switching sources" do
@@ -1003,8 +1003,8 @@ RSpec.describe "bundle install with git sources" do
update_git "valim"
new_revision = revision_for(lib_path("valim-1.0"))
- old_lockfile = File.read(bundled_app("Gemfile.lock"))
- lockfile(bundled_app("Gemfile.lock"), old_lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}"))
+ old_lockfile = File.read(bundled_app_lock)
+ lockfile(bundled_app_lock, old_lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}"))
bundle "install"
@@ -1150,16 +1150,15 @@ RSpec.describe "bundle install with git sources" do
end
2.times do |i|
- Dir.chdir(git_reader.path) do
- File.open("ext/foo.c", "w") do |file|
- file.write <<-C
- #include "ruby.h"
- VALUE foo() { return INT2FIX(#{i}); }
- void Init_foo() { rb_define_global_function("foo", &foo, 0); }
- C
- end
- `git commit -m "commit for iteration #{i}" ext/foo.c`
+ File.open(git_reader.path.join("ext/foo.c"), "w") do |file|
+ file.write <<-C
+ #include "ruby.h"
+ VALUE foo() { return INT2FIX(#{i}); }
+ void Init_foo() { rb_define_global_function("foo", &foo, 0); }
+ C
end
+ sys_exec("git commit -m \"commit for iteration #{i}\" ext/foo.c", :dir => git_reader.path)
+
git_commit_sha = git_reader.ref_for("HEAD")
install_gemfile <<-G
diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb
index b21c08ec92..a733c02512 100644
--- a/spec/install/gemfile/path_spec.rb
+++ b/spec/install/gemfile/path_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe "bundle install with explicit source paths" do
it "supports relative paths" do
build_lib "foo"
- relative_path = lib_path("foo-1.0").relative_path_from(Pathname.new(Dir.pwd))
+ relative_path = lib_path("foo-1.0").relative_path_from(bundled_app)
install_gemfile <<-G
gem 'foo', :path => "#{relative_path}"
@@ -59,6 +59,8 @@ RSpec.describe "bundle install with explicit source paths" do
end
it "expands paths raise error with not existing user's home dir" do
+ skip "problems with ~ expansion" if Gem.win_platform?
+
build_lib "foo"
username = "some_unexisting_user"
relative_path = lib_path("foo-1.0").relative_path_from(Pathname.new("/home/#{username}").expand_path)
@@ -77,10 +79,7 @@ RSpec.describe "bundle install with explicit source paths" do
gem 'foo', :path => "./foo-1.0"
G
- bundled_app("subdir").mkpath
- Dir.chdir(bundled_app("subdir")) do
- expect(the_bundle).to include_gems("foo 1.0")
- end
+ expect(the_bundle).to include_gems("foo 1.0", :dir => bundled_app("subdir").mkpath)
end
it "sorts paths consistently on install and update when they start with ./" do
@@ -119,12 +118,10 @@ RSpec.describe "bundle install with explicit source paths" do
#{Bundler::VERSION}
L
- Dir.chdir(lib_path("demo")) do
- bundle :install
- expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile)
- bundle :update, :all => true
- expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile)
- end
+ bundle :install, :dir => lib_path("demo")
+ expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile)
+ bundle :update, :all => true, :dir => lib_path("demo")
+ expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile)
end
it "expands paths when comparing locked paths to Gemfile paths" do
@@ -139,6 +136,8 @@ RSpec.describe "bundle install with explicit source paths" do
end
it "installs dependencies from the path even if a newer gem is available elsewhere" do
+ skip "override is not winning" if Gem.win_platform?
+
system_gems "rack-1.0.0"
build_lib "rack", "1.0", :path => lib_path("nested/bar") do |s|
@@ -245,11 +244,9 @@ RSpec.describe "bundle install with explicit source paths" do
File.open(lib_path("foo/Gemfile"), "w") {|f| f.puts gemfile }
- Dir.chdir(lib_path("foo")) do
- bundle "install"
- expect(the_bundle).to include_gems "foo 1.0"
- expect(the_bundle).to include_gems "rack 1.0"
- end
+ bundle "install", :dir => lib_path("foo")
+ expect(the_bundle).to include_gems "foo 1.0", :dir => lib_path("foo")
+ expect(the_bundle).to include_gems "rack 1.0", :dir => lib_path("foo")
end
it "supports gemspec syntax with an alternative path" do
@@ -271,19 +268,17 @@ RSpec.describe "bundle install with explicit source paths" do
s.add_dependency "rack", ">= 1.0"
end
- Dir.chdir lib_path("foo")
-
- install_gemfile lib_path("foo/Gemfile"), <<-G
+ install_gemfile lib_path("foo/Gemfile"), <<-G, :dir => lib_path("foo")
source "#{file_uri_for(gem_repo1)}"
gemspec
G
build_gem "rack", "1.0.1", :to_system => true
- bundle "install"
+ bundle "install", :dir => lib_path("foo")
- expect(the_bundle).to include_gems "foo 1.0"
- expect(the_bundle).to include_gems "rack 1.0"
+ expect(the_bundle).to include_gems "foo 1.0", :dir => lib_path("foo")
+ expect(the_bundle).to include_gems "rack 1.0", :dir => lib_path("foo")
end
it "doesn't automatically unlock dependencies when using the gemspec syntax and the gem has development dependencies" do
@@ -292,19 +287,17 @@ RSpec.describe "bundle install with explicit source paths" do
s.add_development_dependency "activesupport"
end
- Dir.chdir lib_path("foo")
-
- install_gemfile lib_path("foo/Gemfile"), <<-G
+ install_gemfile lib_path("foo/Gemfile"), <<-G, :dir => lib_path("foo")
source "#{file_uri_for(gem_repo1)}"
gemspec
G
build_gem "rack", "1.0.1", :to_system => true
- bundle "install"
+ bundle "install", :dir => lib_path("foo")
- expect(the_bundle).to include_gems "foo 1.0"
- expect(the_bundle).to include_gems "rack 1.0"
+ expect(the_bundle).to include_gems "foo 1.0", :dir => lib_path("foo")
+ expect(the_bundle).to include_gems "rack 1.0", :dir => lib_path("foo")
end
it "raises if there are multiple gemspecs" do
@@ -422,7 +415,7 @@ RSpec.describe "bundle install with explicit source paths" do
remote: http://rubygems.org
L
- in_app_root { FileUtils.mkdir_p("vendor/bar") }
+ FileUtils.mkdir_p(bundled_app("vendor/bar"))
install_gemfile <<-G
gem "bar", "1.0.0", path: "vendor/bar", require: "bar/nyard"
@@ -644,6 +637,8 @@ RSpec.describe "bundle install with explicit source paths" do
describe "when there are both a gemspec and remote gems" do
it "doesn't query rubygems for local gemspec name" do
+ skip "platform issues" if Gem.win_platform?
+
build_lib "private_lib", "2.2", :path => lib_path("private_lib")
gemfile = <<-G
source "http://localgemserver.test"
@@ -652,13 +647,11 @@ RSpec.describe "bundle install with explicit source paths" do
G
File.open(lib_path("private_lib/Gemfile"), "w") {|f| f.puts gemfile }
- Dir.chdir(lib_path("private_lib")) do
- bundle :install, :env => { "DEBUG" => "1" }, :artifice => "endpoint"
- expect(out).to match(%r{^HTTP GET http://localgemserver\.test/api/v1/dependencies\?gems=rack$})
- expect(out).not_to match(/^HTTP GET.*private_lib/)
- expect(the_bundle).to include_gems "private_lib 2.2"
- expect(the_bundle).to include_gems "rack 1.0"
- end
+ bundle :install, :env => { "DEBUG" => "1" }, :artifice => "endpoint", :dir => lib_path("private_lib")
+ expect(out).to match(%r{^HTTP GET http://localgemserver\.test/api/v1/dependencies\?gems=rack$})
+ expect(out).not_to match(/^HTTP GET.*private_lib/)
+ expect(the_bundle).to include_gems "private_lib 2.2", :dir => lib_path("private_lib")
+ expect(the_bundle).to include_gems "rack 1.0", :dir => lib_path("private_lib")
end
end
diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb
index c096531398..52e1cf86fa 100644
--- a/spec/install/gemfile/platform_spec.rb
+++ b/spec/install/gemfile/platform_spec.rb
@@ -274,6 +274,8 @@ end
RSpec.describe "bundle install with platform conditionals" do
it "installs gems tagged w/ the current platforms" do
+ skip "platform issues" if Gem.win_platform?
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -299,6 +301,8 @@ RSpec.describe "bundle install with platform conditionals" do
end
it "installs gems tagged w/ the current platforms inline" do
+ skip "platform issues" if Gem.win_platform?
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "nokogiri", :platforms => :#{local_tag}
@@ -317,6 +321,8 @@ RSpec.describe "bundle install with platform conditionals" do
end
it "installs gems tagged w/ the current platform inline" do
+ skip "platform issues" if Gem.win_platform?
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "nokogiri", :platform => :#{local_tag}
diff --git a/spec/install/gemfile/ruby_spec.rb b/spec/install/gemfile/ruby_spec.rb
index d1e9fc7e05..aab269b325 100644
--- a/spec/install/gemfile/ruby_spec.rb
+++ b/spec/install/gemfile/ruby_spec.rb
@@ -2,10 +2,10 @@
RSpec.describe "ruby requirement" do
def locked_ruby_version
- Bundler::RubyVersion.from_string(Bundler::LockfileParser.new(lockfile).ruby_version)
+ Bundler::RubyVersion.from_string(Bundler::LockfileParser.new(File.read(bundled_app_lock)).ruby_version)
end
- # As discovered by https://github.com/bundler/bundler/issues/4147, there is
+ # As discovered by https://github.com/rubygems/bundler/issues/4147, there is
# no test coverage to ensure that adding a gem is possible with a ruby
# requirement. This test verifies the fix, committed in bfbad5c5.
it "allows adding gems" do
@@ -51,6 +51,7 @@ RSpec.describe "ruby requirement" do
gem "rack"
G
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
expect(locked_ruby_version).to eq(Bundler::RubyVersion.system)
simulate_ruby_version "5100"
@@ -72,6 +73,7 @@ RSpec.describe "ruby requirement" do
gem "rack"
G
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
expect(locked_ruby_version).to eq(Bundler::RubyVersion.system)
simulate_ruby_version "5100"
diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb
index 61943ef2e5..8b52833ba1 100644
--- a/spec/install/gemfile/sources_spec.rb
+++ b/spec/install/gemfile/sources_spec.rb
@@ -285,7 +285,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
- # In https://github.com/bundler/bundler/issues/3585 this failed
+ # In https://github.com/rubygems/bundler/issues/3585 this failed
# when there is already a lock file, and the gems are missing, so try again
system_gems []
bundle :install
@@ -426,7 +426,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
G
end
- # Reproduction of https://github.com/bundler/bundler/issues/3298
+ # Reproduction of https://github.com/rubygems/bundler/issues/3298
it "does not unlock the installed gem on exec" do
expect(the_bundle).to include_gems("rack 0.9.1")
end
diff --git a/spec/install/gemfile/specific_platform_spec.rb b/spec/install/gemfile/specific_platform_spec.rb
index 24b602589f..a1cc6b3551 100644
--- a/spec/install/gemfile/specific_platform_spec.rb
+++ b/spec/install/gemfile/specific_platform_spec.rb
@@ -58,6 +58,7 @@ RSpec.describe "bundle install with specific_platform enabled" do
it "locks to both the specific darwin platform and ruby" do
install_gemfile!(google_protobuf)
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
expect(the_bundle.locked_gems.platforms).to eq([pl("ruby"), pl("x86_64-darwin-15")])
expect(the_bundle).to include_gem("google-protobuf 3.0.0.alpha.5.0.5.1 universal-darwin")
expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[
@@ -78,6 +79,7 @@ RSpec.describe "bundle install with specific_platform enabled" do
source "#{file_uri_for(gem_repo2)}"
gem "facter"
G
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
expect(the_bundle.locked_gems.platforms).to eq([pl("ruby"), pl("x86_64-darwin-15")])
expect(the_bundle).to include_gems("facter 2.4.6 universal-darwin", "CFPropertyList 1.0")
@@ -87,6 +89,10 @@ RSpec.describe "bundle install with specific_platform enabled" do
end
context "when adding a platform via lock --add_platform" do
+ before do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ end
+
it "adds the foreign platform" do
install_gemfile!(google_protobuf)
bundle! "lock --add-platform=#{x64_mingw}"
diff --git a/spec/install/gemfile_spec.rb b/spec/install/gemfile_spec.rb
index dd08939cb0..e760f87ec1 100644
--- a/spec/install/gemfile_spec.rb
+++ b/spec/install/gemfile_spec.rb
@@ -44,20 +44,14 @@ RSpec.describe "bundle install" do
end
it "uses the gemfile while in a subdirectory" do
bundled_app("subdir").mkpath
- Dir.chdir(bundled_app("subdir")) do
- bundle "install"
- bundle "list"
+ bundle "install", :dir => bundled_app("subdir")
+ bundle "list", :dir => bundled_app("subdir")
- expect(out).to include("rack (1.0.0)")
- end
+ expect(out).to include("rack (1.0.0)")
end
end
context "with deprecated features" do
- before :each do
- in_app_root
- end
-
it "reports that lib is an invalid option" do
gemfile <<-G
gem "rack", :lib => "rack"
diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb
index a294b83d1c..be6c01aee9 100644
--- a/spec/install/gems/compact_index_spec.rb
+++ b/spec/install/gems/compact_index_spec.rb
@@ -5,6 +5,8 @@ RSpec.describe "compact index api" do
let(:source_uri) { "http://#{source_hostname}" }
it "should use the API" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -26,6 +28,8 @@ RSpec.describe "compact index api" do
end
it "should handle nested dependencies" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rails"
@@ -44,6 +48,8 @@ RSpec.describe "compact index api" do
end
it "should handle case sensitivity conflicts" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo4 do
build_gem "rack", "1.0" do |s|
s.add_runtime_dependency("Rack", "0.1")
@@ -64,6 +70,8 @@ RSpec.describe "compact index api" do
end
it "should handle multiple gem dependencies on the same gem" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "net-sftp"
@@ -74,6 +82,8 @@ RSpec.describe "compact index api" do
end
it "should use the endpoint when using --deployment" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -86,6 +96,8 @@ RSpec.describe "compact index api" do
end
it "handles git dependencies that are in rubygems" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_git "foo" do |s|
s.executables = "foobar"
s.add_dependency "rails", "2.3.2"
@@ -104,6 +116,8 @@ RSpec.describe "compact index api" do
end
it "handles git dependencies that are in rubygems using --deployment" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_git "foo" do |s|
s.executables = "foobar"
s.add_dependency "rails", "2.3.2"
@@ -148,6 +162,8 @@ RSpec.describe "compact index api" do
end
it "falls back when the API URL returns 403 Forbidden" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -159,6 +175,8 @@ RSpec.describe "compact index api" do
end
it "falls back when the versions endpoint has a checksum mismatch" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -173,6 +191,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "falls back when the user's home directory does not exist or is not writable" do
+ skip "artifice issues?" if Gem.win_platform?
+
ENV["HOME"] = tmp("missing_home").to_s
gemfile <<-G
@@ -186,6 +206,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "handles host redirects" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -196,6 +218,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "handles host redirects without Net::HTTP::Persistent" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -220,6 +244,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "times out when Bundler::Fetcher redirects too much" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -230,6 +256,10 @@ The checksum of /versions does not match the checksum provided by the server! So
end
context "when --full-index is specified" do
+ before do
+ skip "artifice issues?" if Gem.win_platform?
+ end
+
it "should use the modern index for install" do
gemfile <<-G
source "#{source_uri}"
@@ -270,6 +300,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -288,6 +320,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "fetches again when more dependencies are found in subsequent sources with source blocks" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -306,6 +340,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "fetches gem versions even when those gems are already installed" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack", "1.0.0"
@@ -329,6 +365,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
# In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
# exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
# of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
@@ -353,6 +391,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "considers all possible versions of dependencies from all api gem sources when using blocks", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
# In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
# exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
# of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
@@ -378,6 +418,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "prints API output properly with back deps" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -399,6 +441,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "does not fetch every spec if the index of gems is large when doing back deps" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -424,6 +468,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "does not fetch every spec if the index of gems is large when doing back deps & everything is the compact index" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo4 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -448,6 +494,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "uses the endpoint if all sources support it" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
@@ -459,6 +507,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -479,6 +529,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "fetches again when more dependencies are found in subsequent sources using --deployment with blocks" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -500,6 +552,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "does not refetch if the only unmet dependency is bundler" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
@@ -523,6 +577,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "installs the binstubs", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -535,6 +591,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "installs the bins when using --path and uses autoclean", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -546,6 +604,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "installs the bins when using --path and uses bundle clean", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -557,6 +617,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "prints post_install_messages" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem 'rack-obama'
@@ -567,6 +629,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "should display the post install message for a dependency" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem 'rack_middleware'
@@ -581,7 +645,7 @@ The checksum of /versions does not match the checksum provided by the server! So
let(:user) { "user" }
let(:password) { "pass" }
let(:basic_auth_source_uri) do
- uri = URI.parse(source_uri)
+ uri = Bundler::URI.parse(source_uri)
uri.user = user
uri.password = password
@@ -589,6 +653,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "passes basic authentication details and strips out creds" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
gem "rack"
@@ -600,6 +666,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "strips http basic authentication creds for modern index" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
gem "rack"
@@ -621,6 +689,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
source "#{file_uri_for(gem_repo1)}"
@@ -634,6 +704,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "does not pass the user / password to different hosts on redirect" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
gem "rack"
@@ -652,6 +724,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "reads authentication details by host name from bundle config" do
+ skip "artifice issues?" if Gem.win_platform?
+
bundle "config set #{source_hostname} #{user}:#{password}"
bundle! :install, :artifice => "compact_index_strict_basic_authentication"
@@ -661,6 +735,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "reads authentication details by full url from bundle config" do
+ skip "artifice issues?" if Gem.win_platform?
+
# The trailing slash is necessary here; Fetcher canonicalizes the URI.
bundle "config set #{source_uri}/ #{user}:#{password}"
@@ -671,6 +747,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "should use the API" do
+ skip "artifice issues?" if Gem.win_platform?
+
bundle "config set #{source_hostname} #{user}:#{password}"
bundle! :install, :artifice => "compact_index_strict_basic_authentication"
expect(out).to include("Fetching gem metadata from #{source_uri}")
@@ -678,6 +756,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "prefers auth supplied in the source uri" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
gem "rack"
@@ -706,6 +786,8 @@ The checksum of /versions does not match the checksum provided by the server! So
let(:password) { nil }
it "passes basic authentication details" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
gem "rack"
@@ -762,27 +844,31 @@ The checksum of /versions does not match the checksum provided by the server! So
end
context ".gemrc with sources is present" do
- before do
+ it "uses other sources declared in the Gemfile" do
+ skip "artifice issues?" if Gem.win_platform?
+
File.open(home(".gemrc"), "w") do |file|
file.puts({ :sources => ["https://rubygems.org"] }.to_yaml)
end
- end
- after do
- home(".gemrc").rmtree
- end
+ begin
+ gemfile <<-G
+ source "#{source_uri}"
+ gem 'rack'
+ G
- it "uses other sources declared in the Gemfile" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack'
- G
+ bundle! :install, :artifice => "compact_index_forbidden"
- bundle! :install, :artifice => "compact_index_forbidden"
+ expect(exitstatus).to eq(0) if exitstatus
+ ensure
+ home(".gemrc").rmtree
+ end
end
end
it "performs partial update with a non-empty range" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem 'rack', '0.9.1'
@@ -804,6 +890,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "performs partial update while local cache is updated by another process" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem 'rack'
@@ -822,6 +910,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "performs full update of compact index info cache if range is not satisfiable" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem 'rack', '0.9.1'
@@ -865,6 +955,8 @@ The checksum of /versions does not match the checksum provided by the server! So
describe "checksum validation" do
it "raises when the checksum does not match" do
+ skip "artifice issues?" if Gem.win_platform?
+
install_gemfile <<-G, :artifice => "compact_index_wrong_gem_checksum"
source "#{source_uri}"
gem "rack"
@@ -885,6 +977,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "raises when the checksum is the wrong length" do
+ skip "artifice issues?" if Gem.win_platform?
+
install_gemfile <<-G, :artifice => "compact_index_wrong_gem_checksum", :env => { "BUNDLER_SPEC_RACK_CHECKSUM" => "checksum!" }
source "#{source_uri}"
gem "rack"
@@ -894,6 +988,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "does not raise when disable_checksum_validation is set" do
+ skip "artifice issues?" if Gem.win_platform?
+
bundle! "config set disable_checksum_validation true"
install_gemfile! <<-G, :artifice => "compact_index_wrong_gem_checksum"
source "#{source_uri}"
@@ -903,6 +999,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "works when cache dir is world-writable" do
+ skip "artifice issues?" if Gem.win_platform?
+
install_gemfile! <<-G, :artifice => "compact_index"
File.umask(0000)
source "#{source_uri}"
@@ -911,6 +1009,8 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "doesn't explode when the API dependencies are wrong" do
+ skip "artifice issues?" if Gem.win_platform?
+
install_gemfile <<-G, :artifice => "compact_index_wrong_dependencies", :env => { "DEBUG" => "true" }
source "#{source_uri}"
gem "rails"
@@ -927,13 +1027,15 @@ Either installing with `--full-index` or running `bundle update rails` should fi
end
it "does not duplicate specs in the lockfile when updating and a dependency is not installed" do
+ skip "artifice issues?" if Gem.win_platform?
+
install_gemfile! <<-G, :artifice => "compact_index"
source "#{source_uri}" do
gem "rails"
gem "activemerchant"
end
G
- gem_command! :uninstall, "activemerchant"
+ gem_command! "uninstall activemerchant"
bundle! "update rails", :artifice => "compact_index"
expect(lockfile.scan(/activemerchant \(/).size).to eq(1)
end
diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb
index a8713eb445..78cca5f8b7 100644
--- a/spec/install/gems/dependency_api_spec.rb
+++ b/spec/install/gems/dependency_api_spec.rb
@@ -5,6 +5,8 @@ RSpec.describe "gemcutter's dependency API" do
let(:source_uri) { "http://#{source_hostname}" }
it "should use the API" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -26,6 +28,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "should handle nested dependencies" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rails"
@@ -44,6 +48,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "should handle multiple gem dependencies on the same gem" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "net-sftp"
@@ -54,6 +60,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "should use the endpoint when using --deployment" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -66,6 +74,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "handles git dependencies that are in rubygems" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_git "foo" do |s|
s.executables = "foobar"
s.add_dependency "rails", "2.3.2"
@@ -84,6 +94,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "handles git dependencies that are in rubygems using --deployment" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_git "foo" do |s|
s.executables = "foobar"
s.add_dependency "rails", "2.3.2"
@@ -128,6 +140,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "falls back when hitting the Gemcutter Dependency Limit" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "activesupport"
@@ -154,6 +168,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "falls back when Gemcutter API doesn't return proper Marshal format" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -165,6 +181,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "falls back when the API URL returns 403 Forbidden" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -176,6 +194,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "handles host redirects" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -186,6 +206,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "handles host redirects without Net::HTTP::Persistent" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -210,6 +232,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "timeouts when Bundler::Fetcher redirects too much" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -220,6 +244,10 @@ RSpec.describe "gemcutter's dependency API" do
end
context "when --full-index is specified" do
+ before do
+ skip "artifice issues?" if Gem.win_platform?
+ end
+
it "should use the modern index for install" do
gemfile <<-G
source "#{source_uri}"
@@ -244,6 +272,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -262,6 +292,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "fetches again when more dependencies are found in subsequent sources using blocks" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -281,6 +313,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "fetches gem versions even when those gems are already installed" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack", "1.0.0"
@@ -303,6 +337,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
# In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
# exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
# of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
@@ -327,6 +363,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "considers all possible versions of dependencies from all api gem sources using blocks" do
+ skip "artifice issues?" if Gem.win_platform?
+
# In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
# exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
# of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
@@ -352,6 +390,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "prints API output properly with back deps" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -373,6 +413,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "does not fetch every spec if the index of gems is large when doing back deps", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -397,6 +439,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "does not fetch every spec if the index of gems is large when doing back deps using blocks" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -422,6 +466,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "uses the endpoint if all sources support it" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
@@ -433,6 +479,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -453,6 +501,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "fetches again when more dependencies are found in subsequent sources using --deployment with blocks" do
+ skip "artifice issues?" if Gem.win_platform?
+
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -497,6 +547,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "installs the binstubs", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -509,6 +561,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "installs the bins when using --path and uses autoclean", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -520,6 +574,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "installs the bins when using --path and uses bundle clean", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -531,6 +587,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "prints post_install_messages" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem 'rack-obama'
@@ -541,6 +599,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "should display the post install message for a dependency" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{source_uri}"
gem 'rack_middleware'
@@ -555,7 +615,7 @@ RSpec.describe "gemcutter's dependency API" do
let(:user) { "user" }
let(:password) { "pass" }
let(:basic_auth_source_uri) do
- uri = URI.parse(source_uri)
+ uri = Bundler::URI.parse(source_uri)
uri.user = user
uri.password = password
@@ -563,6 +623,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "passes basic authentication details and strips out creds" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
gem "rack"
@@ -574,6 +636,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "strips http basic authentication creds for modern index" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
gem "rack"
@@ -595,6 +659,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
source "#{file_uri_for(gem_repo1)}"
@@ -608,6 +674,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "does not pass the user / password to different hosts on redirect" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
gem "rack"
@@ -626,6 +694,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "reads authentication details by host name from bundle config" do
+ skip "artifice issues?" if Gem.win_platform?
+
bundle "config set #{source_hostname} #{user}:#{password}"
bundle :install, :artifice => "endpoint_strict_basic_authentication"
@@ -635,6 +705,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "reads authentication details by full url from bundle config" do
+ skip "artifice issues?" if Gem.win_platform?
+
# The trailing slash is necessary here; Fetcher canonicalizes the URI.
bundle "config set #{source_uri}/ #{user}:#{password}"
@@ -645,6 +717,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "should use the API" do
+ skip "artifice issues?" if Gem.win_platform?
+
bundle "config set #{source_hostname} #{user}:#{password}"
bundle :install, :artifice => "endpoint_strict_basic_authentication"
expect(out).to include("Fetching gem metadata from #{source_uri}")
@@ -652,6 +726,8 @@ RSpec.describe "gemcutter's dependency API" do
end
it "prefers auth supplied in the source uri" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
gem "rack"
@@ -680,6 +756,8 @@ RSpec.describe "gemcutter's dependency API" do
let(:password) { nil }
it "passes basic authentication details" do
+ skip "artifice issues?" if Gem.win_platform?
+
gemfile <<-G
source "#{basic_auth_source_uri}"
gem "rack"
@@ -736,25 +814,25 @@ RSpec.describe "gemcutter's dependency API" do
end
context ".gemrc with sources is present" do
- before do
+ it "uses other sources declared in the Gemfile" do
+ skip "artifice issues?" if Gem.win_platform?
+
File.open(home(".gemrc"), "w") do |file|
file.puts({ :sources => ["https://rubygems.org"] }.to_yaml)
end
- end
- after do
- home(".gemrc").rmtree
- end
-
- it "uses other sources declared in the Gemfile" do
- gemfile <<-G
- source "#{source_uri}"
- gem 'rack'
- G
+ begin
+ gemfile <<-G
+ source "#{source_uri}"
+ gem 'rack'
+ G
- bundle "install", :artifice => "endpoint_marshal_fail"
+ bundle "install", :artifice => "endpoint_marshal_fail"
- expect(exitstatus).to eq(0) if exitstatus
+ expect(exitstatus).to eq(0) if exitstatus
+ ensure
+ home(".gemrc").rmtree
+ end
end
end
end
diff --git a/spec/install/gems/flex_spec.rb b/spec/install/gems/flex_spec.rb
index 865bc7b72a..77891acc24 100644
--- a/spec/install/gems/flex_spec.rb
+++ b/spec/install/gems/flex_spec.rb
@@ -233,7 +233,7 @@ RSpec.describe "bundle flex_install" do
it "does something" do
expect do
bundle "install"
- end.not_to change { File.read(bundled_app("Gemfile.lock")) }
+ end.not_to change { File.read(bundled_app_lock) }
expect(err).to include("rack = 0.9.1")
expect(err).to include("locked at 1.0.0")
diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb
index 52511ff67f..323b28fdb1 100644
--- a/spec/install/gems/resolving_spec.rb
+++ b/spec/install/gems/resolving_spec.rb
@@ -19,6 +19,8 @@ RSpec.describe "bundle install with install-time dependencies" do
end
it "installs gems with a dependency with no type" do
+ skip "incorrect data check error" if Gem.win_platform?
+
build_repo2
path = "#{gem_repo2}/#{Gem::MARSHAL_SPEC_DIR}/actionpack-2.3.2.gemspec.rz"
@@ -67,6 +69,20 @@ RSpec.describe "bundle install with install-time dependencies" do
expect(the_bundle).to include_gems "net_a 1.0", "net_b 1.0", "net_c 1.0", "net_d 1.0", "net_e 1.0"
end
+ context "with ENV['BUNDLER_DEBUG_RESOLVER'] set" do
+ it "produces debug output" do
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ gem "net_c"
+ gem "net_e"
+ G
+
+ bundle :install, :env => { "BUNDLER_DEBUG_RESOLVER" => "1" }
+
+ expect(err).to include("Creating possibility state for net_c")
+ end
+ end
+
context "with ENV['DEBUG_RESOLVER'] set" do
it "produces debug output" do
gemfile <<-G
@@ -101,6 +117,10 @@ RSpec.describe "bundle install with install-time dependencies" do
describe "when a required ruby version" do
context "allows only an older version" do
+ before do
+ skip "gem not found" if Gem.win_platform?
+ end
+
it "installs the older version" do
build_repo2 do
build_gem "rack", "9001.0.0" do |s|
@@ -137,6 +157,31 @@ RSpec.describe "bundle install with install-time dependencies" do
expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
expect(the_bundle).to include_gems("rack 1.2")
end
+
+ it "installs the older not platform specific version" do
+ build_repo4 do
+ build_gem "rack", "9001.0.0" do |s|
+ s.required_ruby_version = "> 9000"
+ end
+ build_gem "rack", "1.2" do |s|
+ s.platform = mingw
+ s.required_ruby_version = "> 9000"
+ end
+ build_gem "rack", "1.2"
+ end
+
+ simulate_platform mingw do
+ install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
+ ruby "#{RUBY_VERSION}"
+ source "http://localgemserver.test/"
+ gem 'rack'
+ G
+ end
+
+ expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
+ expect(out).to_not include("rack-1.2-#{Bundler.local_platform} requires ruby version > 9000")
+ expect(the_bundle).to include_gems("rack 1.2")
+ end
end
context "allows no gems" do
@@ -150,9 +195,18 @@ RSpec.describe "bundle install with install-time dependencies" do
let(:ruby_requirement) { %("#{RUBY_VERSION}") }
let(:error_message_requirement) { "~> #{RUBY_VERSION}.0" }
+ let(:error_message_platform) do
+ if Bundler.feature_flag.specific_platform?
+ " #{Bundler.local_platform}"
+ else
+ ""
+ end
+ end
shared_examples_for "ruby version conflicts" do
it "raises an error during resolution" do
+ skip "ruby requirement includes platform and it shouldn't" if Gem.win_platform?
+
install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }
source "http://localgemserver.test/"
ruby #{ruby_requirement}
@@ -164,9 +218,9 @@ RSpec.describe "bundle install with install-time dependencies" do
nice_error = strip_whitespace(<<-E).strip
Bundler found conflicting requirements for the Ruby\0 version:
In Gemfile:
- Ruby\0 (#{error_message_requirement})
+ Ruby\0 (#{error_message_requirement})#{error_message_platform}
- require_ruby was resolved to 1.0, which depends on
+ require_ruby#{error_message_platform} was resolved to 1.0, which depends on
Ruby\0 (> 9000)
Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation
@@ -179,7 +233,7 @@ RSpec.describe "bundle install with install-time dependencies" do
describe "with a < requirement" do
let(:ruby_requirement) { %("< 5000") }
- let(:error_message_requirement) { "< 5000" }
+ let(:error_message_requirement) { Gem::Requirement.new(["< 5000", "= #{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"]).to_s }
it_behaves_like "ruby version conflicts"
end
@@ -187,7 +241,7 @@ RSpec.describe "bundle install with install-time dependencies" do
describe "with a compound requirement" do
let(:reqs) { ["> 0.1", "< 5000"] }
let(:ruby_requirement) { reqs.map(&:dump).join(", ") }
- let(:error_message_requirement) { Gem::Requirement.new(reqs).to_s }
+ let(:error_message_requirement) { Gem::Requirement.new(reqs + ["= #{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"]).to_s }
it_behaves_like "ruby version conflicts"
end
diff --git a/spec/install/gems/standalone_spec.rb b/spec/install/gems/standalone_spec.rb
index f1d5c8b505..c7c9d2a6a9 100644
--- a/spec/install/gems/standalone_spec.rb
+++ b/spec/install/gems/standalone_spec.rb
@@ -21,9 +21,7 @@ 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
@@ -40,9 +38,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 +50,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 +65,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 +98,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 +118,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 +145,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 +158,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")
@@ -255,11 +226,13 @@ RSpec.shared_examples "bundle install --standalone" do
describe "simple gems" do
before do
+ skip "artifice issues maybe" if Gem.win_platform?
+
gemfile <<-G
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 +252,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 +265,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 +298,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
diff --git a/spec/install/gems/win32_spec.rb b/spec/install/gems/win32_spec.rb
index 01edcca803..972a455bee 100644
--- a/spec/install/gems/win32_spec.rb
+++ b/spec/install/gems/win32_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe "bundle install with win32-generated lockfile" do
it "should read lockfile" do
- File.open(bundled_app("Gemfile.lock"), "wb") do |f|
+ File.open(bundled_app_lock, "wb") do |f|
f << "GEM\r\n"
f << " remote: #{file_uri_for(gem_repo1)}/\r\n"
f << " specs:\r\n"
diff --git a/spec/install/gemspecs_spec.rb b/spec/install/gemspecs_spec.rb
index 4c00caa60c..048987af9b 100644
--- a/spec/install/gemspecs_spec.rb
+++ b/spec/install/gemspecs_spec.rb
@@ -28,6 +28,8 @@ RSpec.describe "bundle install" do
end
it "should use gemspecs in the system cache when available" do
+ skip "weird incompatible marshal file format error" if Gem.win_platform?
+
gemfile <<-G
source "http://localtestserver.gem"
gem 'rack'
diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb
index cc8bf70b03..1b32991fa8 100644
--- a/spec/install/git_spec.rb
+++ b/spec/install/git_spec.rb
@@ -5,16 +5,17 @@ RSpec.describe "bundle install" do
it "displays the revision hash of the gem repository", :bundler => "< 3" do
build_git "foo", "1.0", :path => lib_path("foo")
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo")}"
+ install_gemfile! <<-G
+ gem "foo", :git => "#{file_uri_for(lib_path("foo"))}"
G
- bundle! :install
- expect(out).to include("Using foo 1.0 from #{lib_path("foo")} (at master@#{revision_for(lib_path("foo"))[0..6]})")
+ expect(out).to include("Using foo 1.0 from #{file_uri_for(lib_path("foo"))} (at master@#{revision_for(lib_path("foo"))[0..6]})")
expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}"
end
it "displays the ref of the gem repository when using branch~num as a ref", :bundler => "< 3" do
+ skip "maybe branch~num notation doesn't work on Windows' git" if Gem.win_platform?
+
build_git "foo", "1.0", :path => lib_path("foo")
rev = revision_for(lib_path("foo"))[0..6]
update_git "foo", "2.0", :path => lib_path("foo"), :gemspec => true
@@ -22,17 +23,16 @@ RSpec.describe "bundle install" do
update_git "foo", "3.0", :path => lib_path("foo"), :gemspec => true
install_gemfile! <<-G
- gem "foo", :git => "#{lib_path("foo")}", :ref => "master~2"
+ gem "foo", :git => "#{file_uri_for(lib_path("foo"))}", :ref => "master~2"
G
- bundle! :install
- expect(out).to include("Using foo 1.0 from #{lib_path("foo")} (at master~2@#{rev})")
+ expect(out).to include("Using foo 1.0 from #{file_uri_for(lib_path("foo"))} (at master~2@#{rev})")
expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}"
update_git "foo", "4.0", :path => lib_path("foo"), :gemspec => true
bundle! :update, :all => true
- expect(out).to include("Using foo 2.0 (was 1.0) from #{lib_path("foo")} (at master~2@#{rev2})")
+ expect(out).to include("Using foo 2.0 (was 1.0) from #{file_uri_for(lib_path("foo"))} (at master~2@#{rev2})")
expect(the_bundle).to include_gems "foo 2.0", :source => "git@#{lib_path("foo")}"
end
@@ -69,10 +69,10 @@ RSpec.describe "bundle install" do
build_git "gems", :path => lib_path("gems"), :gemspec => false
end
- install_gemfile <<-G
+ install_gemfile! <<-G
source "#{file_uri_for(gem_repo2)}"
- gem "foo", :git => "#{lib_path("gems")}", :glob => "foo/*.gemspec"
- gem "zebra", :git => "#{lib_path("gems")}", :glob => "zebra/*.gemspec"
+ gem "foo", :git => "#{file_uri_for(lib_path("gems"))}", :glob => "foo/*.gemspec"
+ gem "zebra", :git => "#{file_uri_for(lib_path("gems"))}", :glob => "zebra/*.gemspec"
G
bundle "info foo"
diff --git a/spec/install/global_cache_spec.rb b/spec/install/global_cache_spec.rb
index 023e52b060..15987bdf53 100644
--- a/spec/install/global_cache_spec.rb
+++ b/spec/install/global_cache_spec.rb
@@ -16,6 +16,8 @@ RSpec.describe "global gem caching" do
end
it "caches gems into the global cache on download" do
+ skip "corrupt test gem" if Gem.win_platform?
+
install_gemfile! <<-G, :artifice => "compact_index"
source "#{source}"
gem "rack"
@@ -38,6 +40,10 @@ RSpec.describe "global gem caching" do
end
describe "when the same gem from different sources is installed" do
+ before do
+ skip "corrupt test gem" if Gem.win_platform?
+ end
+
it "should use the appropriate one from the global cache" do
install_gemfile! <<-G, :artifice => "compact_index"
source "#{source}"
@@ -134,6 +140,8 @@ RSpec.describe "global gem caching" do
describe "when installing gems from a different directory" do
it "uses the global cache as a source" do
+ skip "corrupt test gem" if Gem.win_platform?
+
install_gemfile! <<-G, :artifice => "compact_index"
source "#{source}"
gem "rack"
@@ -161,34 +169,34 @@ RSpec.describe "global gem caching" do
expect(source_global_cache("rack-1.0.0.gem")).to exist
expect(source_global_cache("activesupport-2.3.5.gem")).to exist
- Dir.chdir bundled_app2 do
- create_file bundled_app2("gems.rb"), <<-G
- source "#{source}"
- gem "activesupport"
- G
-
- # Neither gem is installed and both are in the global cache
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(the_bundle).not_to include_gems "activesupport 2.3.5"
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- expect(source_global_cache("activesupport-2.3.5.gem")).to exist
-
- # Install using the global cache instead of by downloading the .gem
- # from the server
- bundle! :install, :artifice => "compact_index_no_gem"
-
- # activesupport is installed and both are in the global cache
- expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(the_bundle).to include_gems "activesupport 2.3.5"
- expect(source_global_cache("rack-1.0.0.gem")).to exist
- expect(source_global_cache("activesupport-2.3.5.gem")).to exist
- end
+ create_file bundled_app2("gems.rb"), <<-G
+ source "#{source}"
+ gem "activesupport"
+ G
+
+ # Neither gem is installed and both are in the global cache
+ expect(the_bundle).not_to include_gems "rack 1.0.0", :dir => bundled_app2
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5", :dir => bundled_app2
+ expect(source_global_cache("rack-1.0.0.gem")).to exist
+ expect(source_global_cache("activesupport-2.3.5.gem")).to exist
+
+ # Install using the global cache instead of by downloading the .gem
+ # from the server
+ bundle! :install, :artifice => "compact_index_no_gem", :dir => bundled_app2
+
+ # activesupport is installed and both are in the global cache
+ expect(the_bundle).not_to include_gems "rack 1.0.0", :dir => bundled_app2
+ expect(the_bundle).to include_gems "activesupport 2.3.5", :dir => bundled_app2
+ expect(source_global_cache("rack-1.0.0.gem")).to exist
+ expect(source_global_cache("activesupport-2.3.5.gem")).to exist
end
end
end
describe "extension caching", :ruby_repo do
it "works" do
+ skip "gets incorrect ref in path" if Gem.win_platform?
+
build_git "very_simple_git_binary", &:add_c_extension
build_lib "very_simple_path_binary", &:add_c_extension
revision = revision_for(lib_path("very_simple_git_binary-1.0"))[0, 12]
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index 5240c5820c..bed28ed3e2 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -22,10 +22,8 @@ RSpec.describe "bundle install" do
dir = bundled_app("bun++dle")
dir.mkpath
- Dir.chdir(dir) do
- bundle! :install, forgotten_command_line_options(:path => dir.join("vendor/bundle"))
- expect(out).to include("installed into `./vendor/bundle`")
- end
+ bundle! :install, forgotten_command_line_options(:path => dir.join("vendor/bundle")).merge(:dir => dir)
+ expect(out).to include("installed into `./vendor/bundle`")
dir.rmtree
end
@@ -54,30 +52,24 @@ RSpec.describe "bundle install" do
before { bundle! "config set path_relative_to_cwd true" }
it "installs the bundle relatively to current working directory", :bundler => "< 3" do
- Dir.chdir(bundled_app.parent) do
- bundle! "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle"
- expect(out).to include("installed into `./vendor/bundle`")
- expect(bundled_app("../vendor/bundle")).to be_directory
- end
+ bundle! "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle", :dir => bundled_app.parent
+ expect(out).to include("installed into `./vendor/bundle`")
+ expect(bundled_app("../vendor/bundle")).to be_directory
expect(the_bundle).to include_gems "rack 1.0.0"
end
it "installs the standalone bundle relative to the cwd" do
- Dir.chdir(bundled_app.parent) do
- bundle! :install, :gemfile => bundled_app("Gemfile"), :standalone => true
- expect(out).to include("installed into `./bundled_app/bundle`")
- expect(bundled_app("bundle")).to be_directory
- expect(bundled_app("bundle/ruby")).to be_directory
- end
+ bundle! :install, :gemfile => bundled_app_gemfile, :standalone => true, :dir => bundled_app.parent
+ expect(out).to include("installed into `./bundled_app/bundle`")
+ expect(bundled_app("bundle")).to be_directory
+ expect(bundled_app("bundle/ruby")).to be_directory
bundle! "config unset path"
- Dir.chdir(bundled_app("subdir").tap(&:mkpath)) do
- bundle! :install, :gemfile => bundled_app("Gemfile"), :standalone => true
- expect(out).to include("installed into `../bundle`")
- expect(bundled_app("bundle")).to be_directory
- expect(bundled_app("bundle/ruby")).to be_directory
- end
+ bundle! :install, :gemfile => bundled_app_gemfile, :standalone => true, :dir => bundled_app("subdir").tap(&:mkpath)
+ expect(out).to include("installed into `../bundle`")
+ expect(bundled_app("bundle")).to be_directory
+ expect(bundled_app("bundle/ruby")).to be_directory
end
end
end
@@ -137,9 +129,7 @@ RSpec.describe "bundle install" do
set_bundle_path(type, "vendor")
FileUtils.mkdir_p bundled_app("lol")
- Dir.chdir(bundled_app("lol")) do
- bundle! :install
- end
+ bundle! :install, :dir => bundled_app("lol")
expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
expect(the_bundle).to include_gems "rack 1.0.0"
@@ -203,9 +193,7 @@ RSpec.describe "bundle install" do
describe "to a file" do
before do
- in_app_root do
- FileUtils.touch "bundle"
- end
+ FileUtils.touch bundled_app("bundle")
end
it "reports the file exists" do
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb
index ddab4831a5..afcb89ba8a 100644
--- a/spec/lock/lockfile_spec.rb
+++ b/spec/lock/lockfile_spec.rb
@@ -303,6 +303,8 @@ RSpec.describe "the lockfile format" do
end
it "generates a lockfile without credentials for a configured source", :bundler => "< 3" do
+ skip "corrupt test gem" if Gem.win_platform?
+
bundle "config set http://localgemserver.test/ user:pass"
install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
@@ -1209,7 +1211,7 @@ RSpec.describe "the lockfile format" do
gem "rack", "1.1"
G
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
expect(err).to include "rack (= 1.0) and rack (= 1.1)"
end
@@ -1220,7 +1222,7 @@ RSpec.describe "the lockfile format" do
gem "rack", :git => "git://hubz.com"
G
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
expect(err).to include "rack (>= 0) should come from an unspecified source and git://hubz.com (at master)"
end
@@ -1376,7 +1378,7 @@ RSpec.describe "the lockfile format" do
describe "a line ending" do
def set_lockfile_mtime_to_known_value
time = Time.local(2000, 1, 1, 0, 0, 0)
- File.utime(time, time, bundled_app("Gemfile.lock"))
+ File.utime(time, time, bundled_app_lock)
end
before(:each) do
build_repo2
@@ -1389,7 +1391,7 @@ RSpec.describe "the lockfile format" do
end
it "generates Gemfile.lock with \\n line endings" do
- expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n")
+ expect(File.read(bundled_app_lock)).not_to match("\r\n")
expect(the_bundle).to include_gems "rack 1.0"
end
@@ -1397,19 +1399,21 @@ RSpec.describe "the lockfile format" do
it "preserves Gemfile.lock \\n line endings" do
update_repo2
- expect { bundle "update", :all => true }.to change { File.mtime(bundled_app("Gemfile.lock")) }
- expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n")
+ expect { bundle "update", :all => true }.to change { File.mtime(bundled_app_lock) }
+ expect(File.read(bundled_app_lock)).not_to match("\r\n")
expect(the_bundle).to include_gems "rack 1.2"
end
it "preserves Gemfile.lock \\n\\r line endings" do
+ skip "needs to be adapted" if Gem.win_platform?
+
update_repo2
- win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
- File.open(bundled_app("Gemfile.lock"), "wb") {|f| f.puts(win_lock) }
+ win_lock = File.read(bundled_app_lock).gsub(/\n/, "\r\n")
+ File.open(bundled_app_lock, "wb") {|f| f.puts(win_lock) }
set_lockfile_mtime_to_known_value
- expect { bundle "update", :all => true }.to change { File.mtime(bundled_app("Gemfile.lock")) }
- expect(File.read(bundled_app("Gemfile.lock"))).to match("\r\n")
+ expect { bundle "update", :all => true }.to change { File.mtime(bundled_app_lock) }
+ expect(File.read(bundled_app_lock)).to match("\r\n")
expect(the_bundle).to include_gems "rack 1.2"
end
end
@@ -1421,12 +1425,12 @@ RSpec.describe "the lockfile format" do
require 'bundler'
Bundler.setup
RUBY
- end.not_to change { File.mtime(bundled_app("Gemfile.lock")) }
+ end.not_to change { File.mtime(bundled_app_lock) }
end
it "preserves Gemfile.lock \\n\\r line endings" do
- win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
- File.open(bundled_app("Gemfile.lock"), "wb") {|f| f.puts(win_lock) }
+ win_lock = File.read(bundled_app_lock).gsub(/\n/, "\r\n")
+ File.open(bundled_app_lock, "wb") {|f| f.puts(win_lock) }
set_lockfile_mtime_to_known_value
expect do
@@ -1434,7 +1438,7 @@ RSpec.describe "the lockfile format" do
require 'bundler'
Bundler.setup
RUBY
- end.not_to change { File.mtime(bundled_app("Gemfile.lock")) }
+ end.not_to change { File.mtime(bundled_app_lock) }
end
end
end
diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb
index ab9ba9cae6..9c8df44acc 100644
--- a/spec/other/platform_spec.rb
+++ b/spec/other/platform_spec.rb
@@ -298,7 +298,7 @@ G
#{ruby_version_correct}
G
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
it "installs fine with any engine" do
@@ -310,7 +310,7 @@ G
#{ruby_version_correct_engineless}
G
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
end
@@ -322,7 +322,7 @@ G
#{ruby_version_correct_patchlevel}
G
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
it "doesn't install when the ruby version doesn't match" do
@@ -333,7 +333,7 @@ G
#{ruby_version_incorrect}
G
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
should_be_ruby_version_incorrect
end
@@ -345,7 +345,7 @@ G
#{engine_incorrect}
G
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
should_be_engine_incorrect
end
@@ -358,7 +358,7 @@ G
#{engine_version_incorrect}
G
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
should_be_engine_version_incorrect
end
end
@@ -371,7 +371,7 @@ G
#{patchlevel_incorrect}
G
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
should_be_patchlevel_incorrect
end
end
@@ -936,7 +936,7 @@ G
G
end
- it "starts IRB with the default group loaded when ruby version matches" do
+ it "starts IRB with the default group loaded when ruby version matches", :readline do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@@ -953,7 +953,7 @@ G
expect(out).to include("0.9.1")
end
- it "starts IRB with the default group loaded when ruby version matches any engine" do
+ it "starts IRB with the default group loaded when ruby version matches any engine", :readline do
simulate_ruby_engine "jruby" do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -1051,10 +1051,10 @@ G
#{ruby_version_correct}
G
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
run "1"
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
it "makes a Gemfile.lock if setup succeeds for any engine" do
@@ -1067,10 +1067,10 @@ G
#{ruby_version_correct_engineless}
G
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
run "1"
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
end
@@ -1083,13 +1083,13 @@ G
#{ruby_version_incorrect}
G
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
ruby <<-R
require 'bundler/setup'
R
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
should_be_ruby_version_incorrect
end
@@ -1102,13 +1102,13 @@ G
#{engine_incorrect}
G
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
ruby <<-R
require 'bundler/setup'
R
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
should_be_engine_incorrect
end
@@ -1122,13 +1122,13 @@ G
#{engine_version_incorrect}
G
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
ruby <<-R
require 'bundler/setup'
R
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
should_be_engine_version_incorrect
end
end
@@ -1142,13 +1142,13 @@ G
#{patchlevel_incorrect}
G
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
ruby <<-R
require 'bundler/setup'
R
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
should_be_patchlevel_incorrect
end
end
diff --git a/spec/plugins/install_spec.rb b/spec/plugins/install_spec.rb
index 669ed09fb5..663363ca21 100644
--- a/spec/plugins/install_spec.rb
+++ b/spec/plugins/install_spec.rb
@@ -155,6 +155,10 @@ RSpec.describe "bundler plugin install" do
end
context "Gemfile eval" do
+ before do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ end
+
it "installs plugins listed in gemfile" do
gemfile <<-G
source '#{file_uri_for(gem_repo2)}'
@@ -245,6 +249,7 @@ RSpec.describe "bundler plugin install" do
describe "local plugin" do
it "is installed when inside an app" do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
gemfile ""
bundle "plugin install foo --source #{file_uri_for(gem_repo2)}"
@@ -287,21 +292,16 @@ RSpec.describe "bundler plugin install" do
end
# outside the app
- Dir.chdir tmp
- bundle "plugin install fubar --source #{file_uri_for(gem_repo2)}"
+ bundle "plugin install fubar --source #{file_uri_for(gem_repo2)}", :dir => tmp
end
it "inside the app takes precedence over global plugin" do
- Dir.chdir bundled_app
-
bundle "shout"
expect(out).to eq("local_one")
end
it "outside the app global plugin is used" do
- Dir.chdir tmp
-
- bundle "shout"
+ bundle "shout", :dir => tmp
expect(out).to eq("global_one")
end
end
diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb
index 64002d8f46..aac506dc9a 100644
--- a/spec/plugins/source/example_spec.rb
+++ b/spec/plugins/source/example_spec.rb
@@ -125,14 +125,14 @@ RSpec.describe "real source plugins" do
end
it "installs the gem executables" do
- build_lib "gem-with-bin" do |s|
+ build_lib "gem_with_bin" do |s|
s.executables = ["foo"]
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}" # plugin source
- source "#{lib_path("gem-with-bin-1.0")}", :type => :mpath do
- gem "gem-with-bin"
+ source "#{lib_path("gem_with_bin-1.0")}", :type => :mpath do
+ gem "gem_with_bin"
end
G
@@ -215,6 +215,8 @@ RSpec.describe "real source plugins" do
build_repo2 do
build_plugin "bundler-source-gitp" do |s|
s.write "plugins.rb", <<-RUBY
+ require "open3"
+
class SPlugin < Bundler::Plugin::API
source "gitp"
@@ -254,9 +256,7 @@ RSpec.describe "real source plugins" do
mkdir_p(install_path.dirname)
rm_rf(install_path)
`git clone --no-checkout --quiet "\#{cache_path}" "\#{install_path}"`
- Dir.chdir install_path do
- `git reset --hard \#{revision}`
- end
+ Open3.capture2e("git reset --hard \#{revision}", :chdir => install_path)
spec_path = install_path.join("\#{spec.full_name}.gemspec")
spec_path.open("wb") {|f| f.write spec.to_ruby }
@@ -310,9 +310,8 @@ RSpec.describe "real source plugins" do
cache_repo
end
- Dir.chdir cache_path do
- `git rev-parse --verify \#{@ref}`.strip
- end
+ output, _status = Open3.capture2e("git rev-parse --verify \#{@ref}", :chdir => cache_path)
+ output.strip
end
def base_name
@@ -451,7 +450,7 @@ RSpec.describe "real source plugins" do
bundle "install"
run <<-RUBY
- require 'ma-gitp-gem'
+ require 'ma/gitp/gem'
puts "WIN" unless defined?(MAGITPGEM_PREV_REF)
RUBY
expect(out).to eq("WIN")
@@ -462,7 +461,7 @@ RSpec.describe "real source plugins" do
bundle "update ma-gitp-gem"
run <<-RUBY
- require 'ma-gitp-gem'
+ require 'ma/gitp/gem'
puts "WIN" if defined?(MAGITPGEM_PREV_REF)
RUBY
expect(out).to eq("WIN")
diff --git a/spec/plugins/source_spec.rb b/spec/plugins/source_spec.rb
index c8deee96b1..14643e5c81 100644
--- a/spec/plugins/source_spec.rb
+++ b/spec/plugins/source_spec.rb
@@ -21,6 +21,7 @@ RSpec.describe "bundler source plugin" do
end
G
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
plugin_should_be_installed("bundler-source-psource")
end
@@ -75,6 +76,7 @@ RSpec.describe "bundler source plugin" do
end
it "installs the explicit one" do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
plugin_should_be_installed("another-psource")
end
@@ -100,6 +102,7 @@ RSpec.describe "bundler source plugin" do
end
it "installs the default one" do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
plugin_should_be_installed("bundler-source-psource")
end
end
diff --git a/spec/quality_es_spec.rb b/spec/quality_es_spec.rb
index 4238ac7452..ab2e2983aa 100644
--- a/spec/quality_es_spec.rb
+++ b/spec/quality_es_spec.rb
@@ -40,12 +40,10 @@ RSpec.describe "La biblioteca si misma" do
it "mantiene la calidad de lenguaje de la documentación" do
included = /ronn/
error_messages = []
- Dir.chdir(root) do
- `git ls-files -z -- man`.split("\x0").each do |filename|
- next unless filename =~ included
- error_messages << check_for_expendable_words(filename)
- error_messages << check_for_specific_pronouns(filename)
- end
+ man_tracked_files.split("\x0").each do |filename|
+ next unless filename =~ included
+ error_messages << check_for_expendable_words(filename)
+ error_messages << check_for_specific_pronouns(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -53,12 +51,10 @@ RSpec.describe "La biblioteca si misma" do
it "mantiene la calidad de lenguaje de oraciones usadas en el código fuente" do
error_messages = []
exempt = /vendor/
- Dir.chdir(root) do
- lib_tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_expendable_words(filename)
- error_messages << check_for_specific_pronouns(filename)
- end
+ lib_tracked_files.split("\x0").each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_expendable_words(filename)
+ error_messages << check_for_specific_pronouns(filename)
end
expect(error_messages.compact).to be_well_formed
end
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index 09e59d88ae..e94addae5e 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -107,12 +107,10 @@ RSpec.describe "The library itself" do
it "has no malformed whitespace" do
exempt = /\.gitmodules|fixtures|vendor|LICENSE|vcr_cassettes|rbreadline\.diff|\.txt$/
error_messages = []
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_tab_characters(filename)
- error_messages << check_for_extra_spaces(filename)
- end
+ tracked_files.split("\x0").each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_tab_characters(filename)
+ error_messages << check_for_extra_spaces(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -120,11 +118,9 @@ RSpec.describe "The library itself" do
it "has no estraneous quotes" do
exempt = /vendor|vcr_cassettes|LICENSE|rbreadline\.diff/
error_messages = []
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_straneous_quotes(filename)
- end
+ tracked_files.split("\x0").each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_straneous_quotes(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -132,11 +128,9 @@ RSpec.describe "The library itself" do
it "does not include any leftover debugging or development mechanisms" do
exempt = %r{quality_spec.rb|support/helpers|vcr_cassettes|\.md|\.ronn|\.txt|\.5|\.1}
error_messages = []
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_debugging_mechanisms(filename)
- end
+ tracked_files.split("\x0").each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_debugging_mechanisms(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -144,11 +138,9 @@ RSpec.describe "The library itself" do
it "does not include any unresolved merge conflicts" do
error_messages = []
exempt = %r{lock/lockfile_spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb}
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_git_merge_conflicts(filename)
- end
+ tracked_files.split("\x0").each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_git_merge_conflicts(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -156,12 +148,10 @@ RSpec.describe "The library itself" do
it "maintains language quality of the documentation" do
included = /ronn/
error_messages = []
- Dir.chdir(root) do
- `git ls-files -z -- man`.split("\x0").each do |filename|
- next unless filename =~ included
- error_messages << check_for_expendable_words(filename)
- error_messages << check_for_specific_pronouns(filename)
- end
+ man_tracked_files.split("\x0").each do |filename|
+ next unless filename =~ included
+ error_messages << check_for_expendable_words(filename)
+ error_messages << check_for_specific_pronouns(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -169,12 +159,10 @@ RSpec.describe "The library itself" do
it "maintains language quality of sentences used in source code" do
error_messages = []
exempt = /vendor|vcr_cassettes/
- Dir.chdir(root) do
- lib_tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_expendable_words(filename)
- error_messages << check_for_specific_pronouns(filename)
- end
+ lib_tracked_files.split("\x0").each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_expendable_words(filename)
+ error_messages << check_for_specific_pronouns(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -197,15 +185,13 @@ RSpec.describe "The library itself" do
Bundler::Settings::NUMBER_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::NUMBER_KEYS" }
Bundler::Settings::ARRAY_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::ARRAY_KEYS" }
- Dir.chdir(root) do
- key_pattern = /([a-z\._-]+)/i
- lib_tracked_files.split("\x0").each do |filename|
- each_line(filename) do |line, number|
- line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `#{filename}:#{number.succ}`" }
- end
+ key_pattern = /([a-z\._-]+)/i
+ lib_tracked_files.split("\x0").each do |filename|
+ each_line(filename) do |line, number|
+ line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `#{filename}:#{number.succ}`" }
end
- documented_settings = File.read("man/bundle-config.ronn")[/LIST OF AVAILABLE KEYS.*/m].scan(/^\* `#{key_pattern}`/).flatten
end
+ documented_settings = File.read("man/bundle-config.ronn")[/LIST OF AVAILABLE KEYS.*/m].scan(/^\* `#{key_pattern}`/).flatten
documented_settings.each do |s|
all_settings.delete(s)
@@ -231,54 +217,48 @@ RSpec.describe "The library itself" do
end
it "ships the correct set of files" do
- Dir.chdir(root) do
- git_list = shipped_files.split("\x0")
+ git_list = shipped_files.split("\x0")
- gem_list = Gem::Specification.load(gemspec.to_s).files
+ gem_list = Gem::Specification.load(gemspec.to_s).files
- expect(git_list.to_set).to eq(gem_list.to_set)
- end
+ expect(git_list.to_set).to eq(gem_list.to_set)
end
it "does not contain any warnings" do
- Dir.chdir(root) do
- exclusions = %w[
- lib/bundler/capistrano.rb
- lib/bundler/deployment.rb
- lib/bundler/gem_tasks.rb
- lib/bundler/vlad.rb
- lib/bundler/templates/gems.rb
- ]
- files_to_require = lib_tracked_files.split("\x0").grep(/\.rb$/) - exclusions
- files_to_require.reject! {|f| f.start_with?("lib/bundler/vendor") }
- files_to_require.map! {|f| f.chomp(".rb") }
- sys_exec!("ruby -w -Ilib") do |input, _, _|
- files_to_require.each do |f|
- input.puts "require '#{f.sub(%r{\Alib/}, "")}'"
- end
+ exclusions = %w[
+ lib/bundler/capistrano.rb
+ lib/bundler/deployment.rb
+ lib/bundler/gem_tasks.rb
+ lib/bundler/vlad.rb
+ lib/bundler/templates/gems.rb
+ ]
+ files_to_require = lib_tracked_files.split("\x0").grep(/\.rb$/) - exclusions
+ files_to_require.reject! {|f| f.start_with?("lib/bundler/vendor") }
+ files_to_require.map! {|f| File.expand_path("../#{f}", __dir__) }
+ sys_exec!("ruby -w") do |input, _, _|
+ files_to_require.each do |f|
+ input.puts "require '#{f}'"
end
+ end
- warnings = last_command.stdboth.split("\n")
- # ignore warnings around deprecated Object#=~ method in RubyGems
- warnings.reject! {|w| w =~ %r{rubygems\/version.rb.*deprecated\ Object#=~} }
+ warnings = last_command.stdboth.split("\n")
+ # ignore warnings around deprecated Object#=~ method in RubyGems
+ warnings.reject! {|w| w =~ %r{rubygems\/version.rb.*deprecated\ Object#=~} }
- expect(warnings).to be_well_formed
- end
+ expect(warnings).to be_well_formed
end
it "does not use require internally, but require_relative" do
- Dir.chdir(root) do
- exempt = %r{templates/|vendor/}
- all_bad_requires = []
- lib_tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- each_line(filename) do |line, number|
- line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" }
- end
+ exempt = %r{templates/|vendor/}
+ all_bad_requires = []
+ lib_tracked_files.split("\x0").each do |filename|
+ next if filename =~ exempt
+ each_line(filename) do |line, number|
+ line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" }
end
-
- expect(all_bad_requires).to be_empty, "#{all_bad_requires.size} internal requires that should use `require_relative`: #{all_bad_requires}"
end
+
+ expect(all_bad_requires).to be_empty, "#{all_bad_requires.size} internal requires that should use `require_relative`: #{all_bad_requires}"
end
private
diff --git a/spec/realworld/edgecases_spec.rb b/spec/realworld/edgecases_spec.rb
index a91e6a359e..48c37093b5 100644
--- a/spec/realworld/edgecases_spec.rb
+++ b/spec/realworld/edgecases_spec.rb
@@ -62,7 +62,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
end
it "is able to update a top-level dependency when there is a conflict on a shared transitive child" do
- # from https://github.com/bundler/bundler/issues/5031
+ # from https://github.com/rubygems/bundler/issues/5031
gemfile <<-G
source "https://rubygems.org"
@@ -194,7 +194,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
expect(lockfile).to include(rubygems_version("paperclip", "~> 5.1.0"))
end
- # https://github.com/bundler/bundler/issues/1500
+ # https://github.com/rubygems/bundler/issues/1500
it "does not fail install because of gem plugins" do
realworld_system_gems("open_gem --version 1.4.2", "rake --version 0.9.2")
gemfile <<-G
diff --git a/spec/resolver/platform_spec.rb b/spec/resolver/platform_spec.rb
index fee0cf1f1c..415c5458df 100644
--- a/spec/resolver/platform_spec.rb
+++ b/spec/resolver/platform_spec.rb
@@ -28,6 +28,98 @@ RSpec.describe "Resolving platform craziness" do
end
end
+ it "takes the latest ruby gem, even if an older platform specific version is available" do
+ @index = build_index do
+ gem "foo", "1.0.0"
+ gem "foo", "1.0.0", "x64-mingw32"
+ gem "foo", "1.1.0"
+ end
+ dep "foo"
+ platforms "x64-mingw32"
+
+ should_resolve_as %w[foo-1.1.0]
+ end
+
+ it "takes the ruby version if the platform version is incompatible" do
+ @index = build_index do
+ gem "bar", "1.0.0"
+ gem "foo", "1.0.0"
+ gem "foo", "1.0.0", "x64-mingw32" do
+ dep "bar", "< 1"
+ end
+ end
+ dep "foo"
+ platforms "x64-mingw32"
+
+ should_resolve_as %w[foo-1.0.0]
+ end
+
+ it "prefers the platform specific gem to the ruby version" do
+ @index = build_index do
+ gem "foo", "1.0.0"
+ gem "foo", "1.0.0", "x64-mingw32"
+ end
+ dep "foo"
+ platforms "x64-mingw32"
+
+ should_resolve_as %w[foo-1.0.0-x64-mingw32]
+ end
+
+ it "takes the latest ruby gem if the platform specific gem doesn't match the required_ruby_version" do
+ @index = build_index do
+ gem "foo", "1.0.0"
+ gem "foo", "1.0.0", "x64-mingw32"
+ gem "foo", "1.1.0"
+ gem "foo", "1.1.0", "x64-mingw32" do |s|
+ s.required_ruby_version = [">= 2.0", "< 2.4"]
+ end
+ gem "Ruby\0", "2.5.1"
+ end
+ dep "foo"
+ dep "Ruby\0", "2.5.1"
+ platforms "x64-mingw32"
+
+ should_resolve_as %w[foo-1.1.0]
+ end
+
+ it "takes the latest ruby gem with required_ruby_version if the platform specific gem doesn't match the required_ruby_version" do
+ @index = build_index do
+ gem "foo", "1.0.0"
+ gem "foo", "1.0.0", "x64-mingw32"
+ gem "foo", "1.1.0" do |s|
+ s.required_ruby_version = [">= 2.0"]
+ end
+ gem "foo", "1.1.0", "x64-mingw32" do |s|
+ s.required_ruby_version = [">= 2.0", "< 2.4"]
+ end
+ gem "Ruby\0", "2.5.1"
+ end
+ dep "foo"
+ dep "Ruby\0", "2.5.1"
+ platforms "x64-mingw32"
+
+ should_resolve_as %w[foo-1.1.0]
+ end
+
+ it "takes the latest ruby gem if the platform specific gem doesn't match the required_ruby_version with multiple platforms" do
+ @index = build_index do
+ gem "foo", "1.0.0"
+ gem "foo", "1.0.0", "x64-mingw32"
+ gem "foo", "1.1.0" do |s|
+ s.required_ruby_version = [">= 2.0"]
+ end
+ gem "foo", "1.1.0", "x64-mingw32" do |s|
+ s.required_ruby_version = [">= 2.0", "< 2.4"]
+ end
+ gem "Ruby\0", "2.5.1"
+ end
+ dep "foo"
+ dep "Ruby\0", "2.5.1"
+ platforms "x86_64-linux", "x64-mingw32"
+
+ should_resolve_as %w[foo-1.1.0]
+ end
+
describe "with mingw32" do
before :each do
@index = build_index do
@@ -90,11 +182,11 @@ RSpec.describe "Resolving platform craziness" do
end
end
- it "reports on the conflict" do
+ it "takes the ruby version as fallback" do
platforms "ruby", "java"
dep "foo"
- should_conflict_on "baz"
+ should_resolve_as %w[bar-1.0.0 baz-1.0.0 foo-1.0.0]
end
end
end
diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb
index 003be97cd6..e420594f52 100644
--- a/spec/runtime/executable_spec.rb
+++ b/spec/runtime/executable_spec.rb
@@ -9,6 +9,8 @@ RSpec.describe "Running bin/* commands" do
end
it "runs the bundled command when in the bundle" do
+ skip "exec format error" if Gem.win_platform?
+
bundle! "binstubs rack"
build_gem "rack", "2.0", :to_system => true do |s|
@@ -20,6 +22,8 @@ RSpec.describe "Running bin/* commands" do
end
it "allows the location of the gem stubs to be specified" do
+ skip "created in bin :/" if Gem.win_platform?
+
bundle! "binstubs rack", :path => "gbin"
expect(bundled_app("bin")).not_to exist
@@ -30,6 +34,8 @@ RSpec.describe "Running bin/* commands" do
end
it "allows absolute paths as a specification of where to install bin stubs" do
+ skip "exec format error" if Gem.win_platform?
+
bundle! "binstubs rack", :path => tmp("bin")
gembin tmp("bin/rackup")
@@ -38,28 +44,32 @@ RSpec.describe "Running bin/* commands" do
it "uses the default ruby install name when shebang is not specified" do
bundle! "binstubs rack"
- expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n")
+ expect(File.open(bundled_app("bin/rackup")).gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n")
end
it "allows the name of the shebang executable to be specified" do
+ skip "not created with custom name :/" if Gem.win_platform?
+
bundle! "binstubs rack", :shebang => "ruby-foo"
- expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env ruby-foo\n")
+ expect(File.open(bundled_app("bin/rackup")).gets).to eq("#!/usr/bin/env ruby-foo\n")
end
it "runs the bundled command when out of the bundle" do
+ skip "exec format error" if Gem.win_platform?
+
bundle! "binstubs rack"
build_gem "rack", "2.0", :to_system => true do |s|
s.executables = "rackup"
end
- Dir.chdir(tmp) do
- gembin "rackup"
- expect(out).to eq("1.0.0")
- end
+ gembin "rackup", :dir => tmp
+ expect(out).to eq("1.0.0")
end
it "works with gems in path" do
+ skip "exec format error" if Gem.win_platform?
+
build_lib "rack", :path => lib_path("rack") do |s|
s.executables = "rackup"
end
@@ -94,12 +104,16 @@ RSpec.describe "Running bin/* commands" do
end
it "does not generate bin stubs if the option was not specified" do
+ skip "generated :/" if Gem.win_platform?
+
bundle! "install"
expect(bundled_app("bin/rackup")).not_to exist
end
it "allows you to stop installing binstubs", :bundler => "< 3" do
+ skip "delete permission error" if Gem.win_platform?
+
bundle! "install --binstubs bin/"
bundled_app("bin/rackup").rmtree
bundle! "install --binstubs \"\""
@@ -143,6 +157,8 @@ RSpec.describe "Running bin/* commands" do
end
it "use BUNDLE_GEMFILE gemfile for binstub" do
+ skip "exec format error" if Gem.win_platform?
+
# context with bin/bundler w/ default Gemfile
bundle! "binstubs bundler"
diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb
index 74270a2316..d219556a4b 100644
--- a/spec/runtime/gem_tasks_spec.rb
+++ b/spec/runtime/gem_tasks_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe "require 'bundler/gem_tasks'" do
it "includes the relevant tasks" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
- sys_exec "#{rake} -T", "RUBYOPT" => "-I#{lib_dir}"
+ sys_exec "#{rake} -T", :env => { "RUBYOPT" => "-I#{lib_dir}" }
end
expect(err).to be_empty
@@ -47,7 +47,7 @@ RSpec.describe "require 'bundler/gem_tasks'" do
it "defines a working `rake install` task" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
- sys_exec "#{rake} install", "RUBYOPT" => "-I#{lib_dir}"
+ sys_exec "#{rake} install", :env => { "RUBYOPT" => "-I#{lib_dir}" }
end
expect(err).to be_empty
@@ -60,13 +60,11 @@ RSpec.describe "require 'bundler/gem_tasks'" do
context "rake build when path has spaces" do
before do
spaced_bundled_app = tmp.join("bundled app")
- FileUtils.mv bundled_app, spaced_bundled_app
- Dir.chdir(spaced_bundled_app)
+ FileUtils.cp_r bundled_app, spaced_bundled_app
+ bundle! "exec rake build", :dir => spaced_bundled_app
end
it "still runs successfully" do
- bundle! "exec rake build"
-
expect(err).to be_empty
end
end
diff --git a/spec/runtime/inline_spec.rb b/spec/runtime/inline_spec.rb
index 94d8b086a2..fb6c6e90ad 100644
--- a/spec/runtime/inline_spec.rb
+++ b/spec/runtime/inline_spec.rb
@@ -46,6 +46,8 @@ RSpec.describe "bundler/inline#gemfile" do
end
it "requires the gems" do
+ skip "gems not found" if Gem.win_platform?
+
script <<-RUBY
gemfile do
path "#{lib_path}" do
@@ -95,6 +97,8 @@ RSpec.describe "bundler/inline#gemfile" do
end
it "lets me use my own ui object" do
+ skip "prints just one CONFIRMED" if Gem.win_platform?
+
script <<-RUBY, :artifice => "endpoint"
require '#{lib_dir}/bundler'
class MyBundlerUI < Bundler::UI::Silent
@@ -229,16 +233,14 @@ RSpec.describe "bundler/inline#gemfile" do
1.13.6
G
- in_app_root do
- script <<-RUBY
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
+ script <<-RUBY
+ gemfile do
+ source "#{file_uri_for(gem_repo1)}"
+ gem "rack"
+ end
- puts RACK
- RUBY
- end
+ puts RACK
+ RUBY
expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
@@ -261,16 +263,14 @@ RSpec.describe "bundler/inline#gemfile" do
it "installs inline gems when BUNDLE_GEMFILE is set to an empty string" do
ENV["BUNDLE_GEMFILE"] = ""
- in_app_root do
- script <<-RUBY
- gemfile do
- source "#{file_uri_for(gem_repo1)}"
- gem "rack"
- end
+ script <<-RUBY
+ gemfile do
+ source "#{file_uri_for(gem_repo1)}"
+ gem "rack"
+ end
- puts RACK
- RUBY
- end
+ puts RACK
+ RUBY
expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
@@ -333,4 +333,21 @@ RSpec.describe "bundler/inline#gemfile" do
expect(last_command).to be_success
expect(out).to include("BUNDLE_GEMFILE is empty")
end
+
+ it "resets BUNDLE_GEMFILE to the empty string if it wasn't set previously" do
+ ENV["BUNDLE_GEMFILE"] = nil
+ script <<-RUBY
+ gemfile do
+ source "#{file_uri_for(gem_repo1)}"
+ gem "rack"
+ end
+
+ puts "BUNDLE_GEMFILE is empty" if ENV["BUNDLE_GEMFILE"].empty?
+ system("#{Gem.ruby} -w -e '42'") # this should see original value of BUNDLE_GEMFILE
+ exit $?.exitstatus
+ RUBY
+
+ expect(last_command).to be_success
+ expect(out).to include("BUNDLE_GEMFILE is empty")
+ end
end
diff --git a/spec/runtime/load_spec.rb b/spec/runtime/load_spec.rb
index 7de67e247c..a406fbaf49 100644
--- a/spec/runtime/load_spec.rb
+++ b/spec/runtime/load_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe "Bundler.load" do
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
end
it "provides a list of the env dependencies" do
@@ -32,6 +33,7 @@ RSpec.describe "Bundler.load" do
gem "rack"
G
bundle! :install
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
end
it "provides a list of the env dependencies" do
@@ -101,7 +103,7 @@ RSpec.describe "Bundler.load" do
source "#{file_uri_for(gem_repo1)}"
gem "activerecord"
G
-
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
Bundler.load.specs.each do |spec|
expect(spec.to_yaml).not_to match(/^\s+source:/)
expect(spec.to_yaml).not_to match(/^\s+groups:/)
diff --git a/spec/runtime/platform_spec.rb b/spec/runtime/platform_spec.rb
index f7e93eacf1..70c7594395 100644
--- a/spec/runtime/platform_spec.rb
+++ b/spec/runtime/platform_spec.rb
@@ -113,11 +113,12 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
bundle! "install"
expect(the_bundle).to include_gems "platform_specific 1.0 RUBY"
+ expect(the_bundle).to not_include_gems "nokogiri"
end
end
it "allows specifying only-ruby-platform on windows with gemspec dependency" do
- build_lib("foo", "1.0", :path => ".") do |s|
+ build_lib("foo", "1.0", :path => bundled_app) do |s|
s.add_dependency "rack"
end
diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb
index 490b8c7631..a2e6ba7244 100644
--- a/spec/runtime/require_spec.rb
+++ b/spec/runtime/require_spec.rb
@@ -155,7 +155,7 @@ RSpec.describe "Bundler.require" do
begin
Bundler.require
rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR: \#{e.message}"
+ warn "ZOMG LOAD ERROR: \#{e.message}"
end
RUBY
run(cmd)
@@ -168,7 +168,6 @@ RSpec.describe "Bundler.require" do
build_lib "jquery-rails", "1.0.0" do |s|
s.write "lib/jquery/rails.rb", "puts 'jquery/rails'"
end
- lib_path("jquery-rails-1.0.0/lib/jquery-rails.rb").rmtree
end
it "requires gem names that are namespaced" do
@@ -229,7 +228,7 @@ RSpec.describe "Bundler.require" do
begin
Bundler.require
rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR" if e.message.include?("Could not open library 'libfuuu-1.0'")
+ warn "ZOMG LOAD ERROR" if e.message.include?("Could not open library 'libfuuu-1.0'")
end
RUBY
run(cmd)
@@ -241,7 +240,6 @@ RSpec.describe "Bundler.require" do
build_lib "load-fuuu", "1.0.0" do |s|
s.write "lib/load/fuuu.rb", "raise LoadError.new(\"cannot load such file -- load-bar\")"
end
- lib_path("load-fuuu-1.0.0/lib/load-fuuu.rb").rmtree
gemfile <<-G
path "#{lib_path}" do
@@ -253,7 +251,7 @@ RSpec.describe "Bundler.require" do
begin
Bundler.require
rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR: \#{e.message}"
+ warn "ZOMG LOAD ERROR: \#{e.message}"
end
RUBY
run(cmd)
@@ -436,6 +434,8 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
end
it "requires gems pinned to multiple platforms, including the current one" do
+ skip "platform issues" if Gem.win_platform?
+
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 39240b7404..f94efbea6a 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -218,7 +218,7 @@ RSpec.describe "Bundler.setup" do
Bundler.setup
R
- expect(bundled_app("Gemfile.lock")).not_to exist
+ expect(bundled_app_lock).not_to exist
end
it "doesn't change the Gemfile.lock if the setup fails" do
@@ -227,7 +227,7 @@ RSpec.describe "Bundler.setup" do
gem "rack"
G
- lockfile = File.read(bundled_app("Gemfile.lock"))
+ lockfile = File.read(bundled_app_lock)
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -241,7 +241,7 @@ RSpec.describe "Bundler.setup" do
Bundler.setup
R
- expect(File.read(bundled_app("Gemfile.lock"))).to eq(lockfile)
+ expect(File.read(bundled_app_lock)).to eq(lockfile)
end
it "makes a Gemfile.lock if setup succeeds" do
@@ -250,12 +250,12 @@ RSpec.describe "Bundler.setup" do
gem "rack"
G
- File.read(bundled_app("Gemfile.lock"))
+ File.read(bundled_app_lock)
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
run "1"
- expect(bundled_app("Gemfile.lock")).to exist
+ expect(bundled_app_lock).to exist
end
describe "$BUNDLE_GEMFILE" do
@@ -460,7 +460,7 @@ RSpec.describe "Bundler.setup" do
it "provides a good exception if the lockfile is unavailable" do
bundle "install"
- FileUtils.rm(bundled_app("Gemfile.lock"))
+ FileUtils.rm(bundled_app_lock)
break_git!
@@ -489,15 +489,16 @@ RSpec.describe "Bundler.setup" do
it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do
bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
- with_read_only("**/*") do
+ with_read_only("#{bundled_app}/**/*") do
expect(the_bundle).to include_gems "rack 1.0.0"
end
end
it "finds git gem when default bundle path becomes read only" do
+ bundle "config set --local path .bundle"
bundle "install"
- with_read_only("#{Bundler.bundle_path}/**/*") do
+ with_read_only("#{bundled_app(".bundle")}/**/*") do
expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -708,7 +709,7 @@ end
end
context "when the user has one set" do
- before { ENV["MANPATH"] = "/foo:" }
+ before { ENV["MANPATH"] = "/foo#{File::PATH_SEPARATOR}" }
it "adds the gem's man dir to the MANPATH" do
install_gemfile! <<-G
@@ -717,7 +718,7 @@ end
G
run! "puts ENV['MANPATH']"
- expect(out).to eq("#{default_bundle_path("gems/with_man-1.0/man")}:/foo")
+ expect(out).to eq("#{default_bundle_path("gems/with_man-1.0/man")}#{File::PATH_SEPARATOR}/foo")
end
end
@@ -793,6 +794,8 @@ end
let(:full_name) { "bundler-#{Bundler::VERSION}" }
before do
+ skip "symlink destination exists" if Gem.win_platform?
+
FileUtils.ln_sf(gem_home, symlinked_gem_home)
gems_dir = File.join(gem_home, "gems")
specifications_dir = File.join(gem_home, "specifications")
@@ -863,11 +866,9 @@ end
gem 'foo', '1.2.3', :path => 'vendor/foo'
G
- Dir.chdir(bundled_app.parent) do
- run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s }
- require 'foo'
- R
- end
+ run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app_gemfile.to_s }, :dir => bundled_app.parent
+ require 'foo'
+ R
expect(err).to be_empty
end
@@ -887,11 +888,9 @@ end
bundle :install
- Dir.chdir(bundled_app.parent) do
- run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s }
- require 'foo'
- R
- end
+ run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app_gemfile.to_s }, :dir => bundled_app.parent
+ require 'foo'
+ R
expect(err).to be_empty
end
@@ -899,17 +898,17 @@ end
describe "with git gems that don't have gemspecs" do
before :each do
- build_git "no-gemspec", :gemspec => false
+ build_git "no_gemspec", :gemspec => false
install_gemfile <<-G
- gem "no-gemspec", "1.0", :git => "#{lib_path("no-gemspec-1.0")}"
+ gem "no_gemspec", "1.0", :git => "#{lib_path("no_gemspec-1.0")}"
G
end
it "loads the library via a virtual spec" do
run <<-R
- require 'no-gemspec'
- puts NOGEMSPEC
+ require 'no_gemspec'
+ puts NO_GEMSPEC
R
expect(out).to eq("1.0")
@@ -1015,6 +1014,8 @@ end
end
it "error intelligently if the gemspec has a LoadError" do
+ skip "whitespace issue?" if Gem.win_platform?
+
ref = update_git "bar", :gemspec => false do |s|
s.write "bar.gemspec", "require 'foobarbaz'"
end.ref_for("HEAD")
@@ -1202,11 +1203,13 @@ end
describe "default gem activation" do
let(:exemptions) do
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
+ exempts = if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
%w[did_you_mean]
else
%w[io-console openssl]
end << "bundler"
+ exempts << "fiddle" if Gem.win_platform? && Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
+ exempts
end
let(:activation_warning_hack) { strip_whitespace(<<-RUBY) }
@@ -1256,6 +1259,8 @@ end
end
it "activates no gems with bundle exec that is loaded" do
+ skip "not executable" if Gem.win_platform?
+
install_gemfile! ""
create_file("script.rb", "#!/usr/bin/env ruby\n\n#{code}")
FileUtils.chmod(0o777, bundled_app("script.rb"))
@@ -1263,6 +1268,27 @@ end
expect(out).to eq("{}")
end
+ it "does not load net-http-pipeline too early" do
+ build_repo4 do
+ build_gem "net-http-pipeline", "1.0.1"
+ end
+
+ system_gems "net-http-pipeline-1.0.1", :gem_repo => gem_repo4 do
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo4)}"
+ gem "net-http-pipeline", "1.0.1"
+ G
+
+ bundle "config set --local path vendor/bundle"
+
+ bundle! :install
+
+ bundle! :check
+
+ expect(out).to eq("The Gemfile's dependencies are satisfied")
+ end
+ end
+
Gem::Specification.select(&:default_gem?).map(&:name).each do |g|
it "activates newer versions of #{g}" do
skip if exemptions.include?(g)
@@ -1346,7 +1372,7 @@ end
end
it "takes care of requiring rubygems" do
- sys_exec("#{Gem.ruby} -I#{lib_dir} -e \"puts require('bundler/setup')\"", "RUBYOPT" => "--disable=gems")
+ sys_exec("#{Gem.ruby} -I#{lib_dir} -e \"puts require('bundler/setup')\"", :env => { "RUBYOPT" => "--disable=gems" })
expect(last_command.stdboth).to eq("true")
end
diff --git a/spec/runtime/with_unbundled_env_spec.rb b/spec/runtime/with_unbundled_env_spec.rb
index 4aaf9d499c..81fdf0aaea 100644
--- a/spec/runtime/with_unbundled_env_spec.rb
+++ b/spec/runtime/with_unbundled_env_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe "Bundler.with_env helpers" do
it "should return the GEM_PATH present before bundle was activated" do
code = "print Bundler.original_env['GEM_PATH']"
- gem_path = ENV["GEM_PATH"] + ":/foo"
+ gem_path = ENV["GEM_PATH"] + "#{File::PATH_SEPARATOR}/foo"
with_gem_path_as(gem_path) do
bundle_exec_ruby!(code.dump)
expect(last_command.stdboth).to eq(gem_path)
@@ -35,9 +35,9 @@ RSpec.describe "Bundler.with_env helpers" do
create_file("exe.rb", <<-'RB')
count = ARGV.first.to_i
exit if count < 0
- STDERR.puts "#{count} #{ENV["PATH"].end_with?(":/foo")}"
+ STDERR.puts "#{count} #{ENV["PATH"].end_with?("#{File::PATH_SEPARATOR}/foo")}"
if count == 2
- ENV["PATH"] = "#{ENV["PATH"]}:/foo"
+ ENV["PATH"] = "#{ENV["PATH"]}#{File::PATH_SEPARATOR}/foo"
end
exec(Gem.ruby, __FILE__, (count - 1).to_s)
RB
@@ -170,6 +170,8 @@ RSpec.describe "Bundler.with_env helpers" do
end
it "runs system inside with_original_env" do
+ skip "obscure error" if Gem.win_platform?
+
system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
expect($?.exitstatus).to eq(42)
end
@@ -185,6 +187,8 @@ RSpec.describe "Bundler.with_env helpers" do
end
it "runs system inside with_clean_env" do
+ skip "obscure error" if Gem.win_platform?
+
system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib_dir} -rbundler -e '#{code}'")
expect($?.exitstatus).to eq(42)
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 0a49b46aaa..0074cb81d8 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -2,7 +2,6 @@
require_relative "support/path"
-$:.unshift Spec::Path.spec_dir.to_s
$:.unshift Spec::Path.lib_dir.to_s
require "bundler/psyched_yaml"
@@ -59,7 +58,6 @@ RSpec.configure do |config|
config.bisect_runner = :shell
- original_wd = Dir.pwd
original_env = ENV.to_hash
config.expect_with :rspec do |c|
@@ -105,7 +103,7 @@ RSpec.configure do |config|
ENV.replace(original_env)
reset!
system_gems []
- in_app_root
+
@command_executions = []
Bundler.ui.silence { example.run }
@@ -118,8 +116,6 @@ RSpec.configure do |config|
message
end
end
-
- Dir.chdir(original_wd)
end
config.after :suite do
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 76c9fff463..467a9f2ccd 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -394,7 +394,7 @@ module Spec
@_build_repo = File.basename(path)
yield
with_gem_path_as Path.base_system_gems do
- Dir.chdir(path) { gem_command! :generate_index }
+ gem_command! :generate_index, :dir => path
end
ensure
@_build_path = nil
@@ -551,6 +551,11 @@ module Spec
@files = {}
end
+ def capture(cmd, dir)
+ output, _status = Open3.capture2e(cmd, :chdir => dir)
+ output
+ end
+
def method_missing(*args, &blk)
@spec.send(*args, &blk)
end
@@ -623,7 +628,7 @@ module Spec
unless options[:no_default]
gem_source = options[:source] || "path@#{path}"
@files = _default_files.
- merge("lib/#{name}/source.rb" => "#{Builders.constantize(name)}_SOURCE = #{gem_source.to_s.dump}").
+ merge("lib/#{entrypoint}/source.rb" => "#{Builders.constantize(name)}_SOURCE = #{gem_source.to_s.dump}").
merge(@files)
end
@@ -639,15 +644,20 @@ module Spec
end
def _default_files
- @_default_files ||= begin
- platform_string = " #{@spec.platform}" unless @spec.platform == Gem::Platform::RUBY
- { "lib/#{name}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'" }
- end
+ @_default_files ||= { "lib/#{entrypoint}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'" }
+ end
+
+ def entrypoint
+ name.tr("-", "/")
end
def _default_path
@context.tmp("libs", @spec.full_name)
end
+
+ def platform_string
+ " #{@spec.platform}" unless @spec.platform == Gem::Platform::RUBY
+ end
end
class GitBuilder < LibBuilder
@@ -655,14 +665,12 @@ module Spec
path = options[:path] || _default_path
source = options[:source] || "git@#{path}"
super(options.merge(:path => path, :source => source))
- Dir.chdir(path) do
- `git init`
- `git add *`
- `git config user.email "lol@wut.com"`
- `git config user.name "lolwut"`
- `git config commit.gpgsign false`
- `git commit -m "OMG INITIAL COMMIT"`
- end
+ capture("git init", path)
+ capture("git add *", path)
+ capture("git config user.email \"lol@wut.com\"", path)
+ capture("git config user.name \"lolwut\"", path)
+ capture("git config commit.gpgsign false", path)
+ capture("git commit -m \"OMG INITIAL COMMIT\"", path)
end
end
@@ -670,15 +678,14 @@ module Spec
def _build(options)
path = options[:path] || _default_path
super(options.merge(:path => path))
- Dir.chdir(path) do
- `git init --bare`
- end
+ capture("git init --bare", path)
end
end
class GitUpdater < LibBuilder
- def silently(str)
- `#{str} 2>#{Bundler::NULL}`
+ def silently(str, dir)
+ output, _error, _status = Open3.capture3(str, :chdir => dir)
+ output
end
def _build(options)
@@ -686,34 +693,32 @@ module Spec
update_gemspec = options[:gemspec] || false
source = options[:source] || "git@#{libpath}"
- Dir.chdir(libpath) do
- silently "git checkout master"
+ silently "git checkout master", libpath
- if branch = options[:branch]
- raise "You can't specify `master` as the branch" if branch == "master"
- escaped_branch = Shellwords.shellescape(branch)
-
- if `git branch | grep #{escaped_branch}`.empty?
- silently("git branch #{escaped_branch}")
- end
+ if branch = options[:branch]
+ raise "You can't specify `master` as the branch" if branch == "master"
+ escaped_branch = Shellwords.shellescape(branch)
- silently("git checkout #{escaped_branch}")
- elsif tag = options[:tag]
- `git tag #{Shellwords.shellescape(tag)}`
- elsif options[:remote]
- silently("git remote add origin #{options[:remote]}")
- elsif options[:push]
- silently("git push origin #{options[:push]}")
+ if capture("git branch | grep #{escaped_branch}", libpath).empty?
+ silently("git branch #{escaped_branch}", libpath)
end
- current_ref = `git rev-parse HEAD`.strip
- _default_files.keys.each do |path|
- _default_files[path] += "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'"
- end
- super(options.merge(:path => libpath, :gemspec => update_gemspec, :source => source))
- `git add *`
- `git commit -m "BUMP"`
+ silently("git checkout #{escaped_branch}", libpath)
+ elsif tag = options[:tag]
+ capture("git tag #{Shellwords.shellescape(tag)}", libpath)
+ elsif options[:remote]
+ silently("git remote add origin #{options[:remote]}", libpath)
+ elsif options[:push]
+ silently("git push origin #{options[:push]}", libpath)
+ end
+
+ current_ref = silently("git rev-parse HEAD", libpath).strip
+ _default_files.keys.each do |path|
+ _default_files[path] += "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'"
end
+ super(options.merge(:path => libpath, :gemspec => update_gemspec, :source => source))
+ capture("git add *", libpath)
+ capture("git commit -m \"BUMP\"", libpath)
end
end
@@ -734,7 +739,7 @@ module Spec
def git(cmd)
Bundler::SharedHelpers.with_clean_git_env do
- Dir.chdir(@path) { `git #{cmd}`.strip }
+ Open3.capture2e("git #{cmd}", :chdir => path)[0].strip
end
end
end
@@ -767,7 +772,10 @@ module Spec
class PluginBuilder < GemBuilder
def _default_files
- @_default_files ||= super.merge("plugins.rb" => "")
+ @_default_files ||= {
+ "lib/#{name}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'",
+ "plugins.rb" => "",
+ }
end
end
diff --git a/spec/support/command_execution.rb b/spec/support/command_execution.rb
index b3c289979f..68e5c56c75 100644
--- a/spec/support/command_execution.rb
+++ b/spec/support/command_execution.rb
@@ -3,18 +3,7 @@
module Spec
CommandExecution = Struct.new(:command, :working_directory, :exitstatus, :stdout, :stderr) do
def to_s
- c = Shellwords.shellsplit(command.strip).map {|s| s.include?("\n") ? " \\\n <<EOS\n#{s.gsub(/^/, " ").chomp}\nEOS" : Shellwords.shellescape(s) }
- c = c.reduce("") do |acc, elem|
- concat = acc + " " + elem
-
- last_line = concat.match(/.*\z/)[0]
- if last_line.size >= 100
- acc + " \\\n " + elem
- else
- concat
- end
- end
- "$ #{c.strip}"
+ "$ #{command}"
end
alias_method :inspect, :to_s
diff --git a/spec/support/filters.rb b/spec/support/filters.rb
index 4ce6648cdc..229c79d7c1 100644
--- a/spec/support/filters.rb
+++ b/spec/support/filters.rb
@@ -40,6 +40,8 @@ RSpec.configure do |config|
config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0])
config.filter_run_excluding :ruby_repo => !ENV["GEM_COMMAND"].nil?
config.filter_run_excluding :no_color_tty => Gem.win_platform? || !ENV["GITHUB_ACTION"].nil?
+ config.filter_run_excluding :permissions => Gem.win_platform?
+ config.filter_run_excluding :readline => Gem.win_platform?
config.filter_run_when_matching :focus unless ENV["CI"]
end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index e9c9e766cf..dde8daaf6f 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -59,18 +59,6 @@ module Spec
last_command.exitstatus
end
- def in_app_root(&blk)
- Dir.chdir(bundled_app, &blk)
- end
-
- def in_app_root2(&blk)
- Dir.chdir(bundled_app2, &blk)
- end
-
- def in_app_root_custom(root, &blk)
- Dir.chdir(root, &blk)
- end
-
def run(cmd, *args)
opts = args.last.is_a?(Hash) ? args.pop : {}
groups = args.map(&:inspect).join(", ")
@@ -84,7 +72,7 @@ module Spec
begin
#{ruby}
rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR" if e.message.include?("-- #{name}")
+ warn "ZOMG LOAD ERROR" if e.message.include?("-- #{name}")
end
RUBY
opts = args.last.is_a?(Hash) ? args.pop : {}
@@ -92,7 +80,7 @@ module Spec
run(cmd, *args)
end
- def bundle(cmd, options = {})
+ def bundle(cmd, options = {}, &block)
with_sudo = options.delete(:sudo)
sudo = with_sudo == :preserve_env ? "sudo -E" : "sudo" if with_sudo
@@ -126,6 +114,8 @@ module Spec
load_path << spec_dir
load_path_str = "-I#{load_path.join(File::PATH_SEPARATOR)}"
+ dir = options.delete(:dir) || bundled_app
+
args = options.map do |k, v|
case v
when nil
@@ -140,7 +130,7 @@ module Spec
end.join
cmd = "#{sudo} #{Gem.ruby} #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}"
- sys_exec(cmd, env) {|i, o, thr| yield i, o, thr if block_given? }
+ sys_exec(cmd, { :env => env, :dir => dir }, &block)
end
bang :bundle
@@ -167,10 +157,8 @@ module Spec
end
def ruby(ruby, options = {})
- env = options.delete(:env) || {}
- ruby = ruby.gsub(/["`\$]/) {|m| "\\#{m}" }
lib_option = options[:no_lib] ? "" : " -I#{lib_dir}"
- sys_exec(%(#{Gem.ruby}#{lib_option} -w -e "#{ruby}"), env)
+ sys_exec(%(#{Gem.ruby}#{lib_option} -w -e #{ruby.shellescape}), options)
end
bang :ruby
@@ -179,22 +167,22 @@ module Spec
begin
#{ruby}
rescue LoadError => e
- $stderr.puts "ZOMG LOAD ERROR"# if e.message.include?("-- #{name}")
+ warn "ZOMG LOAD ERROR" if e.message.include?("-- #{name}")
end
R
end
- def gembin(cmd)
+ def gembin(cmd, options = {})
old = ENV["RUBYOPT"]
ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -I#{lib_dir}"
cmd = bundled_app("bin/#{cmd}") unless cmd.to_s.include?("/")
- sys_exec(cmd.to_s)
+ sys_exec(cmd.to_s, options)
ensure
ENV["RUBYOPT"] = old
end
- def gem_command(command, args = "")
- sys_exec("#{Path.gem_bin} #{command} #{args}")
+ def gem_command(command, options = {})
+ sys_exec("#{Path.gem_bin} #{command}", options)
end
bang :gem_command
@@ -202,11 +190,14 @@ module Spec
"#{Gem.ruby} -S #{ENV["GEM_PATH"]}/bin/rake"
end
- def sys_exec(cmd, env = {})
- command_execution = CommandExecution.new(cmd.to_s, Dir.pwd)
+ def sys_exec(cmd, options = {})
+ env = options[:env] || {}
+ dir = options[:dir] || bundled_app
+ command_execution = CommandExecution.new(cmd.to_s, dir)
require "open3"
- Open3.popen3(env, cmd.to_s) do |stdin, stdout, stderr, wait_thr|
+ require "shellwords"
+ Open3.popen3(env, *cmd.shellsplit, :chdir => dir) do |stdin, stdout, stderr, wait_thr|
yield stdin, stdout, wait_thr if block_given?
stdin.close
@@ -250,7 +241,7 @@ module Spec
contents = args.shift
if contents.nil?
- File.open("Gemfile", "r", &:read)
+ File.open(bundled_app_gemfile, "r", &:read)
else
create_file("Gemfile", contents, *args)
end
@@ -260,7 +251,7 @@ module Spec
contents = args.shift
if contents.nil?
- File.open("Gemfile.lock", "r", &:read)
+ File.open(bundled_app_lock, "r", &:read)
else
create_file("Gemfile.lock", contents, *args)
end
@@ -293,7 +284,7 @@ module Spec
gems.each do |g|
if g == :bundler
with_built_bundler {|gem_path| install_gem(gem_path) }
- elsif g.to_s =~ %r{\A(?:[A-Z]:)?/.*\.gem\z}
+ elsif g.to_s =~ %r{\A(?:[a-zA-Z]:)?/.*\.gem\z}
install_gem(g)
else
install_gem("#{gem_repo}/gems/#{g}.gem")
@@ -304,12 +295,12 @@ module Spec
def install_gem(path)
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
- gem_command! :install, "--no-document --ignore-dependencies '#{path}'"
+ gem_command! "install --no-document --ignore-dependencies '#{path}'"
end
def with_built_bundler
with_root_gemspec do |gemspec|
- Dir.chdir(root) { gem_command! :build, gemspec.to_s }
+ gem_command! "build #{gemspec}", :dir => root
end
bundler_path = root + "bundler-#{Bundler::VERSION}.gem"
@@ -356,6 +347,8 @@ module Spec
end
def with_fake_man
+ skip "fake_man is not a Windows friendly binstub" if Gem.win_platform?
+
FileUtils.mkdir_p(tmp("fake_man"))
File.open(tmp("fake_man/man"), "w", 0o755) do |f|
f.puts "#!/usr/bin/env ruby\nputs ARGV.inspect\n"
@@ -367,7 +360,8 @@ module Spec
opts = gems.last.is_a?(Hash) ? gems.last : {}
path = opts.fetch(:path, system_gem_path)
if path == :bundle_path
- path = ruby!(<<-RUBY)
+ bundle_dir = opts.fetch(:bundle_dir, bundled_app)
+ path = ruby!(<<-RUBY, :dir => bundle_dir)
require "bundler"
begin
puts Bundler.bundle_path
@@ -416,7 +410,7 @@ module Spec
ENV["GEM_PATH"] = system_gem_path.to_s
gems.each do |gem|
- gem_command! :install, "--no-document #{gem}"
+ gem_command! "install --no-document #{gem}"
end
return unless block_given?
begin
@@ -504,7 +498,7 @@ module Spec
end
def revision_for(path)
- Dir.chdir(path) { `git rev-parse HEAD`.strip }
+ sys_exec("git rev-parse HEAD", :dir => path).strip
end
def with_read_only(pattern)
diff --git a/spec/support/indexes.rb b/spec/support/indexes.rb
index dc6e0bd1e9..7440523fc9 100644
--- a/spec/support/indexes.rb
+++ b/spec/support/indexes.rb
@@ -26,6 +26,10 @@ module Spec
end
end
source_requirements ||= {}
+ args[0] ||= [] # base
+ args[1] ||= Bundler::GemVersionPromoter.new # gem_version_promoter
+ args[2] ||= [] # additional_base_requirements
+ args[3] ||= @platforms # platforms
Bundler::Resolver.resolve(deps, @index, source_requirements, *args)
end
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index e1a08a30cc..87f1326448 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -128,7 +128,7 @@ module Spec
groups << opts
@errors = names.map do |name|
name, version, platform = name.split(/\s+/)
- require_path = name == "bundler" ? "#{lib_dir}/bundler" : name
+ require_path = name == "bundler" ? "#{lib_dir}/bundler" : name.tr("-", "/")
version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name)
begin
run! "require '#{require_path}.rb'; puts #{version_const}", *groups
@@ -145,7 +145,7 @@ module Spec
next unless source
begin
source_const = "#{Spec::Builders.constantize(name)}_SOURCE"
- run! "require '#{name}/source'; puts #{source_const}", *groups
+ run! "require '#{require_path}/source'; puts #{source_const}", *groups
rescue StandardError
next "#{name} does not have a source defined:\n#{indent(e)}"
end
@@ -214,11 +214,11 @@ module Spec
end
def lockfile_should_be(expected)
- expect(bundled_app("Gemfile.lock")).to have_lockfile(expected)
+ expect(bundled_app_lock).to have_lockfile(expected)
end
def gemfile_should_be(expected)
- expect(bundled_app("Gemfile")).to read_as(strip_whitespace(expected))
+ expect(bundled_app_gemfile).to read_as(strip_whitespace(expected))
end
end
end
diff --git a/spec/support/path.rb b/spec/support/path.rb
index 645da52c97..25206c9832 100644
--- a/spec/support/path.rb
+++ b/spec/support/path.rb
@@ -48,7 +48,13 @@ module Spec
def lib_tracked_files
skip "not in git working directory" unless git_root_dir?
- @lib_tracked_files ||= ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
+ @lib_tracked_files ||= ruby_core? ? sys_exec("git ls-files -z -- lib/bundler lib/bundler.rb", :dir => root) : sys_exec("git ls-files -z -- lib", :dir => root)
+ end
+
+ def man_tracked_files
+ skip "not in git working directory" unless git_root_dir?
+
+ @man_tracked_files ||= sys_exec("git ls-files -z -- man", :dir => root)
end
def tmp(*path)
@@ -96,6 +102,14 @@ module Spec
bundled_app("vendor/cache/#{path}.gem")
end
+ def bundled_app_gemfile
+ bundled_app("Gemfile")
+ end
+
+ def bundled_app_lock
+ bundled_app("Gemfile.lock")
+ end
+
def base_system_gems
tmp.join("gems/base")
end
@@ -158,8 +172,8 @@ module Spec
def with_root_gemspec
if ruby_core?
root_gemspec = root.join("bundler.gemspec")
- # Dir.chdir(root) for Dir.glob in gemspec
- spec = Dir.chdir(root) { Gem::Specification.load(gemspec.to_s) }
+ # `in_repo_root` for Dir.glob in gemspec
+ spec = in_repo_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)
@@ -180,6 +194,10 @@ module Spec
end
end
+ def in_repo_root
+ Dir.chdir(root) { yield }
+ end
+
extend self
private
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index ee9c750a52..b177fc690a 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -15,7 +15,7 @@ module Spec
}.freeze
DEPS = {
- "rack" => "~> 2.0",
+ "rack" => "2.0.8",
"rack-test" => "~> 1.1",
"artifice" => "~> 0.6.0",
"compact_index" => "~> 0.11.0",
@@ -51,24 +51,9 @@ module Spec
end
def setup
- require "fileutils"
-
- Gem.clear_paths
-
- ENV["BUNDLE_PATH"] = nil
- ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s
- ENV["PATH"] = [Path.bindir, Path.system_gem_path.join("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
+ install_test_deps
- manifest = DEPS.to_a.sort_by(&:first).map {|k, v| "#{k} => #{v}\n" }
- manifest_path = Path.base_system_gems.join("manifest.txt")
- # it's OK if there are extra gems
- if !manifest_path.file? || !(manifest - manifest_path.readlines).empty?
- FileUtils.rm_rf(Path.base_system_gems)
- FileUtils.mkdir_p(Path.base_system_gems)
- puts "installing gems for the tests to use..."
- install_gems(DEPS)
- manifest_path.open("wb") {|f| f << manifest.join }
- end
+ require "fileutils"
FileUtils.mkdir_p(Path.home)
FileUtils.mkdir_p(Path.tmpdir)
@@ -80,6 +65,32 @@ module Spec
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
end
+ def install_parallel_test_deps
+ require "parallel"
+
+ prev_env_test_number = ENV["TEST_ENV_NUMBER"]
+
+ begin
+ Parallel.processor_count.times do |n|
+ ENV["TEST_ENV_NUMBER"] = (n + 1).to_s
+
+ install_test_deps
+ end
+ ensure
+ ENV["TEST_ENV_NUMBER"] = prev_env_test_number
+ end
+ end
+
+ def install_test_deps
+ Gem.clear_paths
+
+ ENV["BUNDLE_PATH"] = nil
+ ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s
+ ENV["PATH"] = [Path.bindir, Path.system_gem_path.join("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
+
+ install_gems(DEPS)
+ end
+
private
def gem_load_and_activate(gem_name, bin_container)
@@ -95,10 +106,7 @@ module Spec
end
def install_gems(gems)
- reqs, no_reqs = gems.partition {|_, req| !req.nil? && !req.split(" ").empty? }
- no_reqs.map!(&:first)
- reqs.map! {|name, req| "'#{name}:#{req}'" }
- deps = reqs.concat(no_reqs).join(" ")
+ deps = gems.map {|name, req| "'#{name}:#{req}'" }.join(" ")
gem = ENV["GEM_COMMAND"] || "#{Gem.ruby} -S gem --backtrace"
cmd = "#{gem} install #{deps} --no-document --conservative"
system(cmd) || raise("Installing gems #{deps} for the tests to use failed!")
diff --git a/spec/support/rubygems_version_manager.rb b/spec/support/rubygems_version_manager.rb
index 854bce890d..8eab7749f9 100644
--- a/spec/support/rubygems_version_manager.rb
+++ b/spec/support/rubygems_version_manager.rb
@@ -44,10 +44,8 @@ private
def switch_local_copy_if_needed
return unless local_copy_switch_needed?
- Dir.chdir(local_copy_path) do
- sys_exec!("git remote update")
- sys_exec!("git checkout #{target_tag} --quiet")
- end
+ sys_exec!("git remote update", :dir => local_copy_path)
+ sys_exec!("git checkout #{target_tag} --quiet", :dir => local_copy_path)
ENV["RGV"] = local_copy_path.to_s
end
@@ -65,9 +63,7 @@ private
end
def local_copy_tag
- Dir.chdir(local_copy_path) do
- sys_exec!("git rev-parse --abbrev-ref HEAD")
- end
+ sys_exec!("git rev-parse --abbrev-ref HEAD", :dir => local_copy_path)
end
def local_copy_path
diff --git a/spec/update/gemfile_spec.rb b/spec/update/gemfile_spec.rb
index 8c2bd9ccbf..4a902e59e2 100644
--- a/spec/update/gemfile_spec.rb
+++ b/spec/update/gemfile_spec.rb
@@ -38,12 +38,10 @@ RSpec.describe "bundle update" do
it "uses the gemfile while in a subdirectory" do
bundled_app("subdir").mkpath
- Dir.chdir(bundled_app("subdir")) do
- bundle! "update", :all => true
- bundle "list"
+ bundle! "update", :all => true, :dir => bundled_app("subdir")
+ bundle "list", :dir => bundled_app("subdir")
- expect(out).to include("rack (1.0.0)")
- end
+ expect(out).to include("rack (1.0.0)")
end
end
end
diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb
index 752033c842..58cf18bba0 100644
--- a/spec/update/git_spec.rb
+++ b/spec/update/git_spec.rb
@@ -131,10 +131,8 @@ RSpec.describe "bundle update" do
s.add_dependency "submodule"
end
- Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
- `git commit -m "submodulator"`
- end
+ sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", :dir => lib_path("has_submodule-1.0")
+ sys_exec "git commit -m \"submodulator\"", :dir => lib_path("has_submodule-1.0")
end
it "it unlocks the source when submodules are added to a git source" do
@@ -259,14 +257,12 @@ RSpec.describe "bundle update" do
bundle "update --source foo"
- in_app_root do
- run <<-RUBY
- require 'foo'
- puts "WIN" if defined?(FOO_PREV_REF)
- RUBY
+ run <<-RUBY
+ require 'foo'
+ puts "WIN" if defined?(FOO_PREV_REF)
+ RUBY
- expect(out).to eq("WIN")
- end
+ expect(out).to eq("WIN")
end
it "unlocks gems that were originally pulled in by the source" do