diff options
Diffstat (limited to 'spec/bundler/bundler/env_spec.rb')
-rw-r--r-- | spec/bundler/bundler/env_spec.rb | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/spec/bundler/bundler/env_spec.rb b/spec/bundler/bundler/env_spec.rb index 5d3aeec226..7997cb0c40 100644 --- a/spec/bundler/bundler/env_spec.rb +++ b/spec/bundler/bundler/env_spec.rb @@ -4,7 +4,7 @@ require "bundler/settings" require "openssl" RSpec.describe Bundler::Env do - let(:git_proxy_stub) { Bundler::Source::Git::GitProxy.new(nil, nil, nil) } + let(:git_proxy_stub) { Bundler::Source::Git::GitProxy.new(nil, nil) } describe "#report" do it "prints the environment" do @@ -34,8 +34,6 @@ 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") @@ -43,8 +41,6 @@ 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 allow(File).to receive(:exist?) allow(File).to receive(:exist?).with("/a/b/c/.gem").and_return(true) @@ -92,7 +88,7 @@ RSpec.describe Bundler::Env do allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) end - let(:output) { described_class.report(:print_gemfile => true) } + let(:output) { described_class.report(print_gemfile: true) } it "prints the Gemfile" do expect(output).to include("Gemfile") @@ -106,7 +102,7 @@ RSpec.describe Bundler::Env do end context "when there no Gemfile and print_gemfile is true" do - let(:output) { described_class.report(:print_gemfile => true) } + let(:output) { described_class.report(print_gemfile: true) } it "prints the environment" do expect(output).to start_with("## Environment") @@ -118,7 +114,7 @@ RSpec.describe Bundler::Env do bundle "config set https://localgemserver.test/ user:pass" end - let(:output) { described_class.report(:print_gemfile => true) } + let(:output) { described_class.report(print_gemfile: true) } it "prints the config with redacted values" do expect(output).to include("https://localgemserver.test") @@ -127,9 +123,23 @@ RSpec.describe Bundler::Env do end end + context "when there's bundler config with OAuth token credentials" do + before do + bundle "config set https://localgemserver.test/ api_token:x-oauth-basic" + end + + let(:output) { described_class.report(print_gemfile: true) } + + it "prints the config with redacted values" do + expect(output).to include("https://localgemserver.test") + expect(output).to include("[REDACTED]:x-oauth-basic") + expect(output).to_not include("api_token:x-oauth-basic") + end + end + context "when Gemfile contains a gemspec and print_gemspecs is true" do let(:gemspec) do - strip_whitespace(<<-GEMSPEC) + <<~GEMSPEC Gem::Specification.new do |gem| gem.name = "foo" gem.author = "Fumofu" @@ -148,7 +158,7 @@ RSpec.describe Bundler::Env do end it "prints the gemspec" do - output = described_class.report(:print_gemspecs => true) + output = described_class.report(print_gemspecs: true) expect(output).to include("foo.gemspec") expect(output).to include(gemspec) @@ -167,8 +177,8 @@ RSpec.describe Bundler::Env do 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)) + output = described_class.report(print_gemspecs: true) + expect(output).to include(<<~ENV) ## Gemfile ### Gemfile @@ -207,7 +217,7 @@ RSpec.describe Bundler::Env do context "when the git version is OS specific" do it "includes OS specific information with the version number" do - expect(git_proxy_stub).to receive(:git).with("--version"). + expect(git_proxy_stub).to receive(:git_local).with("--version"). and_return("git version 1.2.3 (Apple Git-BS)") expect(Bundler::Source::Git::GitProxy).to receive(:new).and_return(git_proxy_stub) |