summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSHIBATA Hiroshi <hsbt@ruby-lang.org>2017-12-09 07:51:20 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2017-12-09 07:51:20 +0900
commita0f50fc4a6c2348c446922120dc0ac33e517f1d1 (patch)
treeec904a342a073f2c3b6fc4ead57ebf15fe13b169
parent10f20fa33bc36371cbad00106487c6eb22616ec7 (diff)
downloadbundler-a0f50fc4a6c2348c446922120dc0ac33e517f1d1.tar.gz
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
-rw-r--r--spec/bundler/fetcher_spec.rb12
-rw-r--r--spec/spec_helper.rb7
-rw-r--r--spec/support/builders.rb2
-rw-r--r--spec/support/rubygems_ext.rb3
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(" ")