From a0f50fc4a6c2348c446922120dc0ac33e517f1d1 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Sat, 9 Dec 2017 07:51:20 +0900 Subject: Fixed broken examples on Travis CI. * spec_helper.rb: Remove/Restore bundler files as default gems. It conflicts with some examples. * bundler/fetcher_spec.rb: Use dummy certification file instead of mock object. Because `File.read` was called with `bin/rspec` for gemspec loading. * support/buidlers.rb: An argument of `build_spec` conflicts some old versions of rubygems. * support/rubygems_ext.rb: Order gem dependency for Ruby 1.8.7-2.2.2 --- spec/bundler/fetcher_spec.rb | 12 ++++++++---- spec/spec_helper.rb | 7 +++++++ spec/support/builders.rb | 2 +- spec/support/rubygems_ext.rb | 3 ++- 4 files changed, 18 insertions(+), 6 deletions(-) (limited to 'spec') 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(" ") -- cgit v1.2.1