diff options
-rw-r--r-- | spec/bundler/fetcher_spec.rb | 12 | ||||
-rw-r--r-- | spec/spec_helper.rb | 7 | ||||
-rw-r--r-- | spec/support/builders.rb | 2 | ||||
-rw-r--r-- | spec/support/rubygems_ext.rb | 3 |
4 files changed, 18 insertions, 6 deletions
diff --git a/spec/bundler/fetcher_spec.rb b/spec/bundler/fetcher_spec.rb index f9e52e09c0..184b9efa64 100644 --- a/spec/bundler/fetcher_spec.rb +++ b/spec/bundler/fetcher_spec.rb @@ -95,11 +95,15 @@ RSpec.describe Bundler::Fetcher do context "when bunder ssl ssl configuration is set" do before do + cert = File.join(Spec::Path.tmpdir, "cert") + File.open(cert, "w") {|f| f.write "PEM" } allow(Bundler.settings).to receive(:[]).and_return(nil) - allow(Bundler.settings).to receive(:[]).with(:ssl_client_cert).and_return("/cert") - expect(File).to receive(:read).with("/cert").and_return("") - expect(OpenSSL::X509::Certificate).to receive(:new).and_return("cert") - expect(OpenSSL::PKey::RSA).to receive(:new).and_return("key") + allow(Bundler.settings).to receive(:[]).with(:ssl_client_cert).and_return(cert) + expect(OpenSSL::X509::Certificate).to receive(:new).with("PEM").and_return("cert") + expect(OpenSSL::PKey::RSA).to receive(:new).with("PEM").and_return("key") + end + after do + FileUtils.rm File.join(Spec::Path.tmpdir, "cert") end it "use bundler configuration" do expect(fetcher.send(:connection).cert).to eq("cert") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 766ed8f955..1b3be98442 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -101,6 +101,8 @@ RSpec.configure do |config| original_wd = Dir.pwd original_env = ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) } + original_default_specs = Dir[File.join(Gem.default_dir, "specifications", "default", "bundler*")] + original_site_ruby_dirs = $LOAD_PATH.select {|path| path =~ /site_ruby/ }.map {|path| File.join(path, "bundler*") }.compact.map {|path| Dir[path] }.flatten config.expect_with :rspec do |c| c.syntax = :expect @@ -108,6 +110,11 @@ RSpec.configure do |config| config.before :all do build_repo1 + (original_default_specs + original_site_ruby_dirs).each {|s| FileUtils.mv(s, s + ".org") } + end + + config.after :all do + (original_default_specs + original_site_ruby_dirs).each {|s| FileUtils.mv(s + ".org", s) if File.exist?(s + ".org") } end config.before :each do diff --git a/spec/support/builders.rb b/spec/support/builders.rb index e8208eacd9..377ca35523 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -391,7 +391,7 @@ module Spec index end - def build_spec(name, version, platform = nil, &block) + def build_spec(name, version = "0.0.1", platform = nil, &block) Array(version).map do |v| Gem::Specification.new do |s| s.name = name diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index 3f88215e43..3627e5a71d 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -54,7 +54,8 @@ module Spec def self.install_gems(gems) reqs, no_reqs = gems.partition {|_, req| !req.nil? && !req.split(" ").empty? } - reqs = reqs.sort_by {|name, _| name == "rack" ? 0 : 1 } # TODO: remove when we drop ruby 1.8.7 support + # TODO: remove when we drop ruby 1.8.7-2.2.2 support + reqs = reqs.sort_by {|name, _| name == "rack" ? 0 : 1 }.sort_by {|name, _| name =~ /rack/ ? 0 : 1 } no_reqs.map!(&:first) reqs.map! {|name, req| "'#{name}:#{req}'" } deps = reqs.concat(no_reqs).join(" ") |