summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.codeclimate.yml1
-rw-r--r--.rubocop_todo.yml42
-rw-r--r--.travis.yml5
-rw-r--r--Rakefile6
-rwxr-xr-xbin/rake2
-rwxr-xr-xbin/rspec2
-rwxr-xr-xbin/rubocop4
-rw-r--r--bundler.gemspec4
-rw-r--r--lib/bundler.rb61
-rw-r--r--lib/bundler/cli.rb44
-rw-r--r--lib/bundler/cli/binstubs.rb5
-rw-r--r--lib/bundler/cli/doctor.rb95
-rw-r--r--lib/bundler/cli/exec.rb12
-rw-r--r--lib/bundler/cli/gem.rb2
-rw-r--r--lib/bundler/cli/install.rb5
-rw-r--r--lib/bundler/definition.rb71
-rw-r--r--lib/bundler/dsl.rb32
-rw-r--r--lib/bundler/env.rb2
-rw-r--r--lib/bundler/environment.rb42
-rw-r--r--lib/bundler/environment_preserver.rb2
-rw-r--r--lib/bundler/fetcher.rb1
-rw-r--r--lib/bundler/fetcher/base.rb10
-rw-r--r--lib/bundler/fetcher/compact_index.rb36
-rw-r--r--lib/bundler/fetcher/dependency.rb13
-rw-r--r--lib/bundler/fetcher/downloader.rb2
-rw-r--r--lib/bundler/friendly_errors.rb6
-rw-r--r--lib/bundler/gem_helper.rb4
-rw-r--r--lib/bundler/gem_version_promoter.rb9
-rw-r--r--lib/bundler/graph.rb29
-rw-r--r--lib/bundler/index.rb10
-rw-r--r--lib/bundler/inline.rb4
-rw-r--r--lib/bundler/installer.rb30
-rw-r--r--lib/bundler/installer/gem_installer.rb28
-rw-r--r--lib/bundler/installer/parallel_installer.rb42
-rw-r--r--lib/bundler/lazy_specification.rb10
-rw-r--r--lib/bundler/lockfile_parser.rb6
-rw-r--r--lib/bundler/mirror.rb4
-rw-r--r--lib/bundler/postit_trampoline.rb96
-rw-r--r--lib/bundler/retry.rb3
-rw-r--r--lib/bundler/rubygems_ext.rb11
-rw-r--r--lib/bundler/rubygems_gem_installer.rb6
-rw-r--r--lib/bundler/rubygems_integration.rb167
-rw-r--r--lib/bundler/runtime.rb27
-rw-r--r--lib/bundler/settings.rb17
-rw-r--r--lib/bundler/setup.rb9
-rw-r--r--lib/bundler/shared_helpers.rb8
-rw-r--r--lib/bundler/source/gemspec.rb4
-rw-r--r--lib/bundler/source/git.rb9
-rw-r--r--lib/bundler/source/git/git_proxy.rb8
-rw-r--r--lib/bundler/source/path.rb4
-rw-r--r--lib/bundler/source/rubygems.rb2
-rw-r--r--lib/bundler/templates/Gemfile1
-rw-r--r--lib/bundler/ui/shell.rb6
-rw-r--r--lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb3
-rw-r--r--lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb18
-rw-r--r--man/bundle-binstubs.ronn29
-rw-r--r--man/bundle-package.ronn2
-rw-r--r--man/bundle.ronn3
-rw-r--r--man/gemfile.5.ronn2
-rw-r--r--spec/bundler/bundler_spec.rb4
-rw-r--r--spec/bundler/cli_spec.rb11
-rw-r--r--spec/bundler/dsl_spec.rb2
-rw-r--r--spec/bundler/endpoint_specification_spec.rb6
-rw-r--r--spec/bundler/env_spec.rb13
-rw-r--r--spec/bundler/environment_preserver_spec.rb18
-rw-r--r--spec/bundler/fetcher/compact_index_spec.rb30
-rw-r--r--spec/bundler/fetcher/dependency_spec.rb9
-rw-r--r--spec/bundler/fetcher/downloader_spec.rb2
-rw-r--r--spec/bundler/friendly_errors_spec.rb22
-rw-r--r--spec/bundler/gem_helper_spec.rb10
-rw-r--r--spec/bundler/gem_version_promoter_spec.rb30
-rw-r--r--spec/bundler/mirror_spec.rb10
-rw-r--r--spec/bundler/retry_spec.rb33
-rw-r--r--spec/bundler/settings_spec.rb3
-rw-r--r--spec/bundler/shared_helpers_spec.rb19
-rw-r--r--spec/bundler/source/git/git_proxy_spec.rb82
-rw-r--r--spec/bundler/uri_credentials_filter_spec.rb3
-rw-r--r--spec/cache/gems_spec.rb16
-rw-r--r--spec/cache/git_spec.rb14
-rw-r--r--spec/cache/path_spec.rb6
-rw-r--r--spec/commands/binstubs_spec.rb4
-rw-r--r--spec/commands/clean_spec.rb4
-rw-r--r--spec/commands/config_spec.rb13
-rw-r--r--spec/commands/console_spec.rb2
-rw-r--r--spec/commands/doctor_spec.rb61
-rw-r--r--spec/commands/exec_spec.rb35
-rw-r--r--spec/commands/help_spec.rb22
-rw-r--r--spec/commands/install_spec.rb53
-rw-r--r--spec/commands/package_spec.rb16
-rw-r--r--spec/commands/show_spec.rb6
-rw-r--r--spec/commands/update_spec.rb68
-rw-r--r--spec/commands/viz_spec.rb50
-rw-r--r--spec/install/allow_offline_install_spec.rb92
-rw-r--r--spec/install/binstubs_spec.rb2
-rw-r--r--spec/install/bundler_spec.rb6
-rw-r--r--spec/install/deploy_spec.rb12
-rw-r--r--spec/install/force_spec.rb4
-rw-r--r--spec/install/gemfile/gemspec_spec.rb186
-rw-r--r--spec/install/gemfile/git_spec.rb104
-rw-r--r--spec/install/gemfile/groups_spec.rb76
-rw-r--r--spec/install/gemfile/install_if.rb6
-rw-r--r--spec/install/gemfile/path_spec.rb78
-rw-r--r--spec/install/gemfile/platform_spec.rb30
-rw-r--r--spec/install/gemfile/ruby_spec.rb8
-rw-r--r--spec/install/gemfile/sources_spec.rb33
-rw-r--r--spec/install/gemfile_spec.rb2
-rw-r--r--spec/install/gems/compact_index_spec.rb91
-rw-r--r--spec/install/gems/dependency_api_spec.rb70
-rw-r--r--spec/install/gems/env_spec.rb20
-rw-r--r--spec/install/gems/flex_spec.rb38
-rw-r--r--spec/install/gems/mirror_spec.rb4
-rw-r--r--spec/install/gems/resolving_spec.rb24
-rw-r--r--spec/install/gems/standalone_spec.rb4
-rw-r--r--spec/install/gems/sudo_spec.rb12
-rw-r--r--spec/install/gemspecs_spec.rb6
-rw-r--r--spec/install/git_spec.rb2
-rw-r--r--spec/install/path_spec.rb16
-rw-r--r--spec/install/prereleases_spec.rb8
-rw-r--r--spec/install/security_policy_spec.rb6
-rw-r--r--spec/install/upgrade_spec.rb26
-rw-r--r--spec/lock/git_spec.rb2
-rw-r--r--spec/lock/lockfile_spec.rb18
-rw-r--r--spec/other/bundle_ruby_spec.rb26
-rw-r--r--spec/other/ext_spec.rb8
-rw-r--r--spec/other/major_deprecation_spec.rb15
-rw-r--r--spec/other/platform_spec.rb4
-rw-r--r--spec/other/trampoline_spec.rb27
-rw-r--r--spec/plugins/install_spec.rb2
-rw-r--r--spec/plugins/source/example_spec.rb18
-rw-r--r--spec/quality_spec.rb31
-rw-r--r--spec/realworld/dependency_api_spec.rb5
-rw-r--r--spec/realworld/edgecases_spec.rb4
-rw-r--r--spec/realworld/gemfile_source_header_spec.rb5
-rw-r--r--spec/realworld/mirror_probe_spec.rb7
-rw-r--r--spec/resolver/basic_spec.rb1
-rw-r--r--spec/runtime/inline_spec.rb4
-rw-r--r--spec/runtime/platform_spec.rb4
-rw-r--r--spec/runtime/require_spec.rb14
-rw-r--r--spec/runtime/setup_spec.rb57
-rw-r--r--spec/runtime/with_clean_env_spec.rb4
-rw-r--r--spec/spec_helper.rb24
-rw-r--r--spec/support/artifice/fail.rb23
-rw-r--r--spec/support/builders.rb28
-rw-r--r--spec/support/helpers.rb70
-rw-r--r--spec/support/matchers.rb196
-rw-r--r--spec/support/rubygems_ext.rb9
-rw-r--r--spec/support/silent_logger.rb9
-rw-r--r--spec/support/sometimes.rb3
-rw-r--r--spec/support/the_bundle.rb31
-rw-r--r--spec/update/git_spec.rb20
150 files changed, 2294 insertions, 1136 deletions
diff --git a/.codeclimate.yml b/.codeclimate.yml
index 7e652fa1f4..b8d91f14c4 100644
--- a/.codeclimate.yml
+++ b/.codeclimate.yml
@@ -22,3 +22,4 @@ exclude_paths:
- lib/bundler/templates/**/*.tt
- man/*
- spec/**/*
+- Rakefile
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 686c189839..3a23005c2b 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
-# on 2016-03-29 17:34:30 -0500 using RuboCop version 0.39.0.
+# on 2016-07-27 12:41:39 -0500 using RuboCop version 0.41.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@@ -45,28 +45,23 @@ Lint/UselessAccessModifier:
Exclude:
- 'lib/bundler/fetcher.rb'
-# Offense count: 7
+# Offense count: 6
Lint/UselessAssignment:
Exclude:
- - 'lib/bundler/graph.rb'
- 'lib/bundler/index.rb'
- 'lib/bundler/installer.rb'
-# Offense count: 1331
+# Offense count: 1686
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 207
-# Offense count: 2
+# Offense count: 3
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 6
-# Offense count: 55
-Metrics/PerceivedComplexity:
- Max: 51
-
# Offense count: 6
# Cop supports --auto-correct.
Performance/RedundantBlockCall:
@@ -104,13 +99,13 @@ Style/CaseEquality:
- 'lib/bundler/match_platform.rb'
- 'lib/bundler/rubygems_ext.rb'
-# Offense count: 22
+# Offense count: 23
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Enabled: false
-# Offense count: 11
+# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly.
# SupportedStyles: assign_to_condition, assign_inside_condition
@@ -127,7 +122,7 @@ Style/ConditionalAssignment:
- 'lib/bundler/source/git.rb'
- 'lib/bundler/source/rubygems.rb'
-# Offense count: 119
+# Offense count: 138
Style/Documentation:
Enabled: false
@@ -164,32 +159,38 @@ Style/IndentArray:
EnforcedStyle: consistent
# Offense count: 2
+# Configuration parameters: EnforcedStyle, SupportedStyles.
+# SupportedStyles: module_function, extend_self
Style/ModuleFunction:
Exclude:
- 'lib/bundler/shared_helpers.rb'
- 'spec/support/path.rb'
-# Offense count: 1
+# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
-# SupportedStyles: aligned, indented
+# SupportedStyles: aligned, indented, indented_relative_to_receiver
Style/MultilineMethodCallIndentation:
- Enabled: false
+ Exclude:
+ - 'lib/bundler/cli/common.rb'
+ - 'spec/bundler/plugin/source_list_spec.rb'
-# Offense count: 4
+# Offense count: 3
+# Cop supports --auto-correct.
Style/NestedParenthesizedCalls:
Exclude:
- 'lib/bundler/resolver.rb'
- 'spec/commands/lock_spec.rb'
- 'spec/runtime/setup_spec.rb'
-# Offense count: 8
+# Offense count: 9
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
Style/PredicateName:
Exclude:
+ - 'spec/**/*'
- 'lib/bundler/definition.rb'
- 'lib/bundler/installer/parallel_installer.rb'
- 'lib/bundler/settings.rb'
@@ -198,6 +199,7 @@ Style/PredicateName:
- 'lib/bundler/source/path.rb'
# Offense count: 25
+# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: compact, exploded
Style/RaiseArgs:
@@ -217,7 +219,7 @@ Style/SpaceAroundOperators:
Exclude:
- 'lib/bundler/retry.rb'
-# Offense count: 11
+# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
# SupportedStyles: comma, consistent_comma, no_comma
@@ -231,14 +233,12 @@ Style/TrailingCommaInLiteral:
- 'lib/bundler/ruby_version.rb'
- 'lib/bundler/similarity_detector.rb'
- 'spec/support/artifice/endpoint.rb'
- - 'spec/support/rubygems_ext.rb'
-# Offense count: 19
+# Offense count: 18
# Cop supports --auto-correct.
Style/UnneededInterpolation:
Exclude:
- 'lib/bundler/cli/config.rb'
- - 'lib/bundler/definition.rb'
- 'lib/bundler/env.rb'
- 'spec/bundler/shared_helpers_spec.rb'
- 'spec/cache/git_spec.rb'
diff --git a/.travis.yml b/.travis.yml
index f1aeb66244..f8dd2dd7ca 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,9 @@
language: ruby
script: rake spec:travis
-before_script: travis_retry rake spec:travis:deps
+before_script:
+ - travis_retry rake spec:travis:deps
+ - travis_retry rake man:build
+ - travis_retry rake spec:rubygems:clone_rubygems_$RGV
branches:
only:
diff --git a/Rakefile b/Rakefile
index 10914534da..7c4a2eb0a4 100644
--- a/Rakefile
+++ b/Rakefile
@@ -39,7 +39,7 @@ namespace :spec do
deps = Hash[BUNDLER_SPEC.development_dependencies.map do |d|
[d.name, d.requirement.to_s]
end]
- deps["rubocop"] ||= "= 0.39.0" if RUBY_VERSION >= "1.9.3" # can't go in the gemspec because of the ruby version requirement
+ deps["rubocop"] ||= "= 0.41.2" if RUBY_VERSION >= "1.9.3" # can't go in the gemspec because of the ruby version requirement
# JRuby can't build ronn or rdiscount, so we skip that
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
@@ -93,7 +93,7 @@ begin
if RUBY_VERSION >= "1.9.3"
# can't go in the gemspec because of the ruby version requirement
- gem "rubocop", "= 0.39.0"
+ gem "rubocop", "= 0.41.2"
require "rubocop/rake_task"
RuboCop::RakeTask.new
end
@@ -131,7 +131,7 @@ begin
(branches + releases).each do |rg|
desc "Run specs with Rubygems #{rg}"
RSpec::Core::RakeTask.new(rg) do |t|
- t.rspec_opts = %w(--format documentation --color)
+ t.rspec_opts = %w(--format progress --color)
t.ruby_opts = %w(-w)
end
diff --git a/bin/rake b/bin/rake
index 29b6d6f4aa..ebb192fd50 100755
--- a/bin/rake
+++ b/bin/rake
@@ -8,7 +8,7 @@ require "rubygems"
bundler_spec = Gem::Specification.load(File.expand_path("../../bundler.gemspec", __FILE__))
bundler_spec.dependencies.each do |dep|
begin
- gem dep.name, dep.requirement.to_s
+ gem dep.name, dep.requirement
rescue Gem::LoadError => e
$stderr.puts "#{e.message} (#{e.class})"
end
diff --git a/bin/rspec b/bin/rspec
index 388fe57382..39109d66f2 100755
--- a/bin/rspec
+++ b/bin/rspec
@@ -7,7 +7,7 @@ require "rubygems"
bundler_spec = Gem::Specification.load(File.expand_path("../../bundler.gemspec", __FILE__))
bundler_spec.dependencies.each do |dep|
- gem dep.name, dep.requirement.to_s
+ gem dep.name, dep.requirement
end
Gem.finish_resolve if Gem.respond_to?(:finish_resolve)
diff --git a/bin/rubocop b/bin/rubocop
index 9e0e1488ad..78641c589f 100755
--- a/bin/rubocop
+++ b/bin/rubocop
@@ -7,10 +7,10 @@ require "rubygems"
bundler_spec = Gem::Specification.load(File.expand_path("../../bundler.gemspec", __FILE__))
bundler_spec.dependencies.each do |dep|
- gem dep.name, dep.requirement.to_s
+ gem dep.name, dep.requirement
end
-gem "rubocop", "= 0.39.0"
+gem "rubocop", "= 0.41.2"
Gem.finish_resolve if Gem.respond_to?(:finish_resolve)
diff --git a/bundler.gemspec b/bundler.gemspec
index 3b3cbf46f5..f67c538fd6 100644
--- a/bundler.gemspec
+++ b/bundler.gemspec
@@ -20,9 +20,9 @@ Gem::Specification.new do |s|
s.add_development_dependency "automatiek", "~> 0.1.0"
s.add_development_dependency "mustache", "0.99.6"
s.add_development_dependency "rake", "~> 10.0"
- s.add_development_dependency "rdiscount", "~> 2.1.8"
+ s.add_development_dependency "rdiscount", "~> 2.2"
s.add_development_dependency "ronn", "~> 0.7.3"
- s.add_development_dependency "rspec", "~> 3.0"
+ s.add_development_dependency "rspec", "~> 3.5"
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
# we don't check in man pages, but we need to ship them because
diff --git a/lib/bundler.rb b/lib/bundler.rb
index aa30663a46..f5fdcf87d7 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -25,7 +25,6 @@ module Bundler
autoload :Deprecate, "bundler/deprecate"
autoload :Dsl, "bundler/dsl"
autoload :EndpointSpecification, "bundler/endpoint_specification"
- autoload :Environment, "bundler/environment"
autoload :Env, "bundler/env"
autoload :Fetcher, "bundler/fetcher"
autoload :GemHelper, "bundler/gem_helper"
@@ -33,8 +32,8 @@ module Bundler
autoload :GemVersionPromoter, "bundler/gem_version_promoter"
autoload :Graph, "bundler/graph"
autoload :Index, "bundler/index"
- autoload :Installer, "bundler/installer"
autoload :Injector, "bundler/injector"
+ autoload :Installer, "bundler/installer"
autoload :LazySpecification, "bundler/lazy_specification"
autoload :LockfileParser, "bundler/lockfile_parser"
autoload :MatchPlatform, "bundler/match_platform"
@@ -43,16 +42,16 @@ module Bundler
autoload :RemoteSpecification, "bundler/remote_specification"
autoload :Resolver, "bundler/resolver"
autoload :Retry, "bundler/retry"
- autoload :RubyVersion, "bundler/ruby_version"
autoload :RubyDsl, "bundler/ruby_dsl"
+ autoload :RubyGemsGemInstaller, "bundler/rubygems_gem_installer"
+ autoload :RubyVersion, "bundler/ruby_version"
autoload :Runtime, "bundler/runtime"
autoload :Settings, "bundler/settings"
autoload :SharedHelpers, "bundler/shared_helpers"
- autoload :SpecSet, "bundler/spec_set"
- autoload :StubSpecification, "bundler/stub_specification"
autoload :Source, "bundler/source"
autoload :SourceList, "bundler/source_list"
- autoload :RubyGemsGemInstaller, "bundler/rubygems_gem_installer"
+ autoload :SpecSet, "bundler/spec_set"
+ autoload :StubSpecification, "bundler/stub_specification"
autoload :UI, "bundler/ui"
autoload :URICredentialsFilter, "bundler/uri_credentials_filter"
@@ -89,7 +88,7 @@ module Bundler
def setup(*groups)
# Return if all groups are already loaded
- return @setup if defined?(@setup)
+ return @setup if defined?(@setup) && @setup
definition.validate_ruby!
@@ -112,7 +111,8 @@ module Bundler
end
def environment
- Bundler::Environment.new(root, definition)
+ SharedHelpers.major_deprecation "Bundler.environment has been removed in favor of Bundler.load"
+ load
end
# Returns an instance of Bundler::Definition for given Gemfile and lockfile
@@ -124,19 +124,18 @@ module Bundler
@definition = nil if unlock
@definition ||= begin
configure
- upgrade_lockfile
Definition.build(default_gemfile, default_lockfile, unlock)
end
end
def locked_gems
- return @locked_gems if defined?(@locked_gems)
- if Bundler.default_lockfile.exist?
- lock = Bundler.read_file(Bundler.default_lockfile)
- @locked_gems = LockfileParser.new(lock)
- else
- @locked_gems = nil
- end
+ @locked_gems ||=
+ if defined?(@definition) && @definition
+ definition.locked_gems
+ elsif Bundler.default_lockfile.exist?
+ lock = Bundler.read_file(Bundler.default_lockfile)
+ LockfileParser.new(lock)
+ end
end
def ruby_scope
@@ -223,8 +222,8 @@ EOF
Bundler::SharedHelpers.major_deprecation("`Bundler.clean_env` has weird edge cases, use `.original_env` instead")
env = original_env
- if env.key?("BUNDLE_ORIG_MANPATH")
- env["MANPATH"] = env["BUNDLE_ORIG_MANPATH"]
+ if env.key?("BUNDLER_ORIG_MANPATH")
+ env["MANPATH"] = env["BUNDLER_ORIG_MANPATH"]
end
env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
@@ -394,6 +393,15 @@ EOF
@root = nil
@settings = nil
@definition = nil
+ @setup = nil
+ @load = nil
+ @locked_gems = nil
+ @bundle_path = nil
+ @bin_path = nil
+ return unless defined?(@rubygems) && @rubygems
+ rubygems.undo_replacements
+ rubygems.reset
+ @rubygems = nil
end
private
@@ -409,17 +417,13 @@ EOF
def eval_gemspec(path, contents)
eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
rescue ScriptError, StandardError => e
- original_line = e.backtrace.find {|line| line.include?(path.to_s) }
- msg = String.new
- msg << "There was a #{e.class} while loading #{path.basename}: \n#{e.message}"
- msg << " from\n #{original_line}" if original_line
- msg << "\n"
+ msg = "There was an error while loading `#{path.basename}`: #{e.message}"
if e.is_a?(LoadError) && RUBY_VERSION >= "1.9"
- msg << "\nDoes it try to require a relative path? That's been removed in Ruby 1.9."
+ msg += "\nDoes it try to require a relative path? That's been removed in Ruby 1.9"
end
- raise GemspecError, msg
+ raise GemspecError, Dsl::DSLError.new(msg, path, e.backtrace, contents)
end
def configure_gem_home_and_path
@@ -451,13 +455,6 @@ EOF
Bundler.rubygems.clear_paths
end
- def upgrade_lockfile
- lockfile = default_lockfile
- return unless lockfile.exist? && lockfile.read(3) == "---"
- Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..."
- lockfile.rmtree
- end
-
# @param env [Hash]
def with_env(env)
backup = ENV.to_hash
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index ed81ffbf35..a20c76b30f 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -16,6 +16,10 @@ module Bundler
Bundler::SharedHelpers.print_major_deprecations!
end
+ def self.dispatch(*)
+ super {|i| i.send(:print_command) }
+ end
+
def initialize(*args)
super
Bundler.reset!
@@ -39,7 +43,8 @@ module Bundler
Bundler.ui.warn(
"The RUBYGEMS_GEMDEPS environment variable is set. This enables RubyGems' " \
"experimental Gemfile mode, which may conflict with Bundler and cause unexpected errors. " \
- "To remove this warning, unset RUBYGEMS_GEMDEPS.", :wrap => true)
+ "To remove this warning, unset RUBYGEMS_GEMDEPS.", :wrap => true
+ )
end
end
@@ -68,7 +73,8 @@ module Bundler
bundle-package
bundle-update
bundle-platform
- gemfile.5)
+ gemfile.5
+ )
if manpages.include?(command)
root = File.expand_path("../man", __FILE__)
@@ -468,6 +474,21 @@ module Bundler
Inject.new(options, name, version, gems).run
end
+ desc "doctor [OPTIONS]", "Checks the bundle for common problems"
+ long_desc <<-D
+ Doctor scans the OS dependencies of each of the gems requested in the Gemfile. If
+ missing dependencies are detected, Bundler prints them and exits status 1.
+ Otherwise, Bundler prints a success message and exits with a status of 0.
+ D
+ method_option "gemfile", :type => :string, :banner =>
+ "Use the specified gemfile instead of Gemfile"
+ method_option "quiet", :type => :boolean, :banner =>
+ "Only output warnings and errors."
+ def doctor
+ require "bundler/cli/doctor"
+ Doctor.new(options).run
+ end
+
if Bundler.settings[:plugins]
require "bundler/cli/plugin"
desc "plugin SUBCOMMAND ...ARGS", "manage the bundler plugins"
@@ -489,10 +510,12 @@ module Bundler
else
args
end
- elsif command.nil?
- abort("Could not find command \"#{args.join(" ")}\".")
- else
+ elsif help_used
+ args = args.dup
+ args.delete_at(help_used)
["help", command || args].flatten.compact
+ else
+ args
end
end
@@ -517,5 +540,16 @@ module Bundler
Bundler.reset!
end
end
+
+ def print_command
+ return unless ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"] || Bundler.ui.debug?
+ _, _, config = @_initializer
+ current_command = config[:current_command].name
+ return if %w(exec version check platform show help).include?(current_command)
+ command = ["bundle", current_command] + args
+ command << Thor::Options.to_switches(options)
+ command.reject!(&:empty?)
+ Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}"
+ end
end
end
diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb
index e8982e90b4..f7a27b01bb 100644
--- a/lib/bundler/cli/binstubs.rb
+++ b/lib/bundler/cli/binstubs.rb
@@ -21,10 +21,11 @@ module Bundler
end
gems.each do |gem_name|
- spec = installer.specs.find {|s| s.name == gem_name }
+ spec = Bundler.definition.specs.find {|s| s.name == gem_name }
unless spec
raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(
- gem_name, Bundler.definition.specs)
+ gem_name, Bundler.definition.specs
+ )
end
if spec.name == "bundler"
diff --git a/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb
new file mode 100644
index 0000000000..8fd862a1c2
--- /dev/null
+++ b/lib/bundler/cli/doctor.rb
@@ -0,0 +1,95 @@
+# frozen_string_literal: true
+
+require "rbconfig"
+
+module Bundler
+ class CLI::Doctor
+ DARWIN_REGEX = /\s+(.+) \(compatibility /
+ LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/
+
+ attr_reader :options
+
+ def initialize(options)
+ @options = options
+ end
+
+ def otool_available?
+ system("otool --version 2>&1 >#{Bundler::NULL}")
+ end
+
+ def ldd_available?
+ !system("ldd --help 2>&1 >#{Bundler::NULL}").nil?
+ end
+
+ def dylibs_darwin(path)
+ output = `/usr/bin/otool -L "#{path}"`.chomp
+ dylibs = output.split("\n")[1..-1].map {|l| l.match(DARWIN_REGEX).captures[0] }.uniq
+ # ignore @rpath and friends
+ dylibs.reject {|dylib| dylib.start_with? "@" }
+ end
+
+ def dylibs_ldd(path)
+ output = `/usr/bin/ldd "#{path}"`.chomp
+ output.split("\n").map do |l|
+ match = l.match(LDD_REGEX)
+ next if match.nil?
+ match.captures[0]
+ end.compact
+ end
+
+ def dylibs(path)
+ case RbConfig::CONFIG["host_os"]
+ when /darwin/
+ return [] unless otool_available?
+ dylibs_darwin(path)
+ when /(linux|solaris|bsd)/
+ return [] unless ldd_available?
+ dylibs_ldd(path)
+ else # Windows, etc.
+ Bundler.ui.warn("Dynamic library check not supported on this platform.")
+ []
+ end
+ end
+
+ def bundles_for_gem(spec)
+ Dir.glob("#{spec.full_gem_path}/**/*.bundle")
+ end
+
+ def run
+ Bundler.ui.level = "error" if options[:quiet]
+
+ broken_links = {}
+
+ begin
+ definition = Bundler.definition
+ definition.validate_ruby!
+ not_installed = definition.missing_specs
+ raise GemNotFound if not_installed.any?
+ rescue GemNotFound
+ Bundler.ui.warn "This bundle's gems must be installed to run this command."
+ Bundler.ui.warn "Install missing gems with `bundle install`."
+ exit 0
+ end
+
+ definition.specs.each do |spec|
+ bundles_for_gem(spec).each do |bundle|
+ bad_paths = dylibs(bundle).select {|f| !File.exist?(f) }
+ if bad_paths.any?
+ broken_links[spec] ||= []
+ broken_links[spec].concat(bad_paths)
+ end
+ end
+ end
+
+ if broken_links.any?
+ Bundler.ui.error "The following gems are missing OS dependencies"
+ broken_links.each do |spec, paths|
+ paths.uniq.each do |path|
+ Bundler.ui.error " * #{spec.name}: #{path}"
+ end
+ end
+ exit 1
+ end
+ end
+ end
+end
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb
index 4371887f2a..8240fc2342 100644
--- a/lib/bundler/cli/exec.rb
+++ b/lib/bundler/cli/exec.rb
@@ -25,7 +25,11 @@ module Bundler
if bin_path = Bundler.which(cmd)
return kernel_load(bin_path, *args) if ruby_shebang?(bin_path)
# First, try to exec directly to something in PATH
- kernel_exec([bin_path, cmd], *args)
+ if Bundler.current_ruby.jruby_18?
+ kernel_exec(bin_path, *args)
+ else
+ kernel_exec([bin_path, cmd], *args)
+ end
else
# exec using the given command
kernel_exec(cmd, *args)
@@ -59,6 +63,7 @@ module Bundler
args.pop if args.last.is_a?(Hash)
ARGV.replace(args)
$0 = file
+ Process.setproctitle(process_title(file, args)) if Process.respond_to?(:setproctitle)
ui = Bundler.ui
Bundler.ui = nil
require "bundler/setup"
@@ -74,9 +79,14 @@ module Bundler
abort "#{e.class}: #{e.message}\n #{backtrace.join("\n ")}"
end
+ def process_title(file, args)
+ "#{file} #{args.join(" ")}".strip
+ end
+
def ruby_shebang?(file)
possibilities = [
"#!/usr/bin/env ruby\n",
+ "#!/usr/bin/env jruby\n",
"#!#{Gem.ruby}\n",
]
first_line = File.open(file, "rb") {|f| f.read(possibilities.map(&:size).max) }
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index 72a1880c52..27f4262e30 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -126,7 +126,7 @@ module Bundler
executables.each do |file|
path = target.join(file)
- executable = (path.stat.mode | 0111)
+ executable = (path.stat.mode | 0o111)
path.chmod(executable)
end
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 2dee4a5a77..5c7b8c5b0b 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -68,7 +68,7 @@ module Bundler
definition = Bundler.definition
definition.validate_ruby!
- Installer.install(Bundler.root, definition, options)
+ installer = Installer.install(Bundler.root, definition, options)
Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.settings[:frozen]
Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
@@ -83,7 +83,7 @@ module Bundler
end
unless Bundler.settings["ignore_messages"]
- Installer.post_install_messages.to_a.each do |name, msg|
+ installer.post_install_messages.to_a.each do |name, msg|
print_post_install_message(name, msg) unless Bundler.settings["ignore_messages.#{name}"]
end
end
@@ -125,6 +125,7 @@ module Bundler
return if ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"].nil?
installed_version = Gem::Version.new(ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"].dup)
running_version = Gem::Version.new(Bundler::VERSION)
+ return if Gem::Requirement.new(installed_version).satisfied_by?(running_version)
if Bundler.settings[:warned_version].nil? || running_version > Gem::Version.new(Bundler.settings[:warned_version])
Bundler.settings[:warned_version] = running_version
Bundler.ui.warn "You're running Bundler #{installed_version} but this " \
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index b7db1179a0..726e9d261b 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -7,7 +7,15 @@ module Bundler
class Definition
include GemHelpers
- attr_reader :dependencies, :platforms, :ruby_version, :locked_deps, :gem_version_promoter
+ attr_reader(
+ :dependencies,
+ :gem_version_promoter,
+ :locked_deps,
+ :locked_gems,
+ :platforms,
+ :requires,
+ :ruby_version
+ )
# Given a gemfile and lockfile creates a Bundler definition
#
@@ -60,15 +68,15 @@ module Bundler
if lockfile && File.exist?(lockfile)
@lockfile_contents = Bundler.read_file(lockfile)
- locked = LockfileParser.new(@lockfile_contents)
- @platforms = locked.platforms
- @locked_bundler_version = locked.bundler_version
- @locked_ruby_version = locked.ruby_version
+ @locked_gems = LockfileParser.new(@lockfile_contents)
+ @platforms = @locked_gems.platforms
+ @locked_bundler_version = @locked_gems.bundler_version
+ @locked_ruby_version = @locked_gems.ruby_version
if unlock != true
- @locked_deps = locked.dependencies
- @locked_specs = SpecSet.new(locked.specs)
- @locked_sources = locked.sources
+ @locked_deps = @locked_gems.dependencies
+ @locked_specs = SpecSet.new(@locked_gems.specs)
+ @locked_sources = @locked_gems.sources
else
@unlock = {}
@locked_deps = []
@@ -78,6 +86,7 @@ module Bundler
else
@unlock = {}
@platforms = []
+ @locked_gems = nil
@locked_deps = []
@locked_specs = SpecSet.new([])
@locked_sources = []
@@ -107,6 +116,8 @@ module Bundler
@dependency_changes = converge_dependencies
@local_changes = converge_locals
+ @requires = compute_requires
+
fixup_dependency_types!
end
@@ -215,7 +226,7 @@ module Bundler
end
def current_dependencies
- dependencies.reject {|d| !d.should_include? }
+ dependencies.select(&:should_include?)
end
def specs_for(groups)
@@ -510,14 +521,14 @@ module Bundler
# Check if the specs of the given source changed
# according to the locked source.
def specs_changed?(source)
- locked = @locked_sources.find(source)
+ locked = @locked_sources.find {|s| s == source }
- !locked || dependencies_for_source_changed?(source) || specs_for_source_changed?(source)
+ !locked || dependencies_for_source_changed?(source, locked) || specs_for_source_changed?(source)
end
- def dependencies_for_source_changed?(source)
+ def dependencies_for_source_changed?(source, locked_source = source)
deps_for_source = @dependencies.select {|s| s.source == source }
- locked_deps_for_source = @locked_deps.select {|s| s.source == source }
+ locked_deps_for_source = @locked_deps.select {|s| s.source == locked_source }
Set.new(deps_for_source) != Set.new(locked_deps_for_source)
end
@@ -544,9 +555,10 @@ module Bundler
end
end
- locals.any? do |source, changed|
+ sources_with_changes = locals.select do |source, changed|
changed || specs_changed?(source)
- end
+ end.map(&:first)
+ !sources_with_changes.each {|source| @unlock[:sources] << source.name }.empty?
end
def converge_paths
@@ -555,9 +567,22 @@ module Bundler
end
end
+ def converge_path_source_to_gemspec_source(source)
+ return source unless source.instance_of?(Source::Path)
+ gemspec_source = sources.path_sources.find {|s| s.is_a?(Source::Gemspec) && s.as_path_source == source }
+ gemspec_source || source
+ end
+
def converge_sources
changes = false
+ @locked_sources.map! do |source|
+ converge_path_source_to_gemspec_source(source)
+ end
+ @locked_specs.each do |spec|
+ spec.source &&= converge_path_source_to_gemspec_source(spec.source)
+ end
+
# Get the Rubygems sources from the Gemfile.lock
locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
# Get the Rubygems remotes from the Gemfile
@@ -602,6 +627,9 @@ module Bundler
elsif dep.source
dep.source = sources.get(dep.source)
end
+ if dep.source.is_a?(Source::Gemspec)
+ dep.platforms.concat(@platforms.map {|p| Dependency::REVERSE_PLATFORM_MAP[p] }.flatten(1)).uniq!
+ end
end
Set.new(@dependencies) != Set.new(@locked_deps)
end
@@ -653,7 +681,7 @@ module Bundler
# then we unlock it.
# Path sources have special logic
- if s.source.instance_of?(Source::Path)
+ if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
other = s.source.specs[s].first
# If the spec is no longer in the path source, unlock it. This
@@ -768,5 +796,16 @@ module Bundler
# to an array. The first element will be the gem name (e.g. foo), the second will be the version number.
error.message.scan(/Could not find (\w+)-(\d+(?:\.\d+)+)/).flatten
end
+
+ def compute_requires
+ dependencies.reduce({}) do |requires, dep|
+ next requires unless dep.should_include?
+ requires[dep.name] = Array(dep.autorequire || dep.name).map do |file|
+ # Allow `require: true` as an alias for `require: <name>`
+ file == true ? dep.name : file
+ end
+ requires
+ end
+ end
end
end
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 0436b58f3a..b064c80d4c 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -38,7 +38,7 @@ module Bundler
original_gemfile = @gemfile
@gemfile = expanded_gemfile_path
contents ||= Bundler.read_file(gemfile.to_s)
- instance_eval(contents, gemfile.to_s, 1)
+ instance_eval(contents.dup.untaint, gemfile.to_s, 1)
rescue Exception => e
message = "There was an error " \
"#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
@@ -50,22 +50,22 @@ module Bundler
end
def gemspec(opts = nil)
- path = opts && opts[:path] || "."
- glob = opts && opts[:glob]
- name = opts && opts[:name] || "{,*}"
- development_group = opts && opts[:development_group] || :development
+ opts ||= {}
+ path = opts[:path] || "."
+ glob = opts[:glob]
+ name = opts[:name]
+ development_group = opts[:development_group] || :development
expanded_path = gemfile_root.join(path)
- gemspecs = Dir[File.join(expanded_path, "#{name}.gemspec")]
+ gemspecs = Dir[File.join(expanded_path, "{,*}.gemspec")].map {|g| Bundler.load_gemspec(g) }.compact
+ gemspecs.reject! {|s| s.name != name } if name
+ Index.sort_specs(gemspecs)
+ specs_by_name_and_version = gemspecs.group_by {|s| [s.name, s.version] }
- case gemspecs.size
+ case specs_by_name_and_version.size
when 1
- spec = Bundler.load_gemspec(gemspecs.first)
-
- unless spec
- raise InvalidOption, "There was an error loading the gemspec at " \
- "#{file}. Make sure you can build the gem, then try again"
- end
+ specs = specs_by_name_and_version.values.first
+ spec = specs.find {|s| s.match_platform(Gem::Platform.local) } || specs.first
@gemspecs << spec
@@ -74,7 +74,7 @@ module Bundler
group(development_group) do
spec.development_dependencies.each do |dep|
- gem dep.name, *(dep.requirement.as_list + [:type => :development, :platforms => gem_platforms])
+ gem dep.name, *(dep.requirement.as_list + [:type => :development])
end
end
when 0
@@ -417,7 +417,7 @@ module Bundler
# TODO: 2.0 upgrade from setting to default
if Bundler.settings[:disable_multisource]
- raise GemspecError, "Warning: this Gemfile contains multiple primary sources. " \
+ raise GemfileError, "Warning: this Gemfile contains multiple primary sources. " \
"Each source after the first must include a block to indicate which gems " \
"should come from that source. To downgrade this error to a warning, run " \
"`bundle config --delete disable_multisource`"
@@ -522,7 +522,7 @@ The :#{name} git source is deprecated, and will be removed in Bundler 2.0. Add t
lines = contents.lines.to_a
indent = " # "
- indicator = indent.tr('#', ">")
+ indicator = indent.tr("#", ">")
first_line = (line_numer.zero?)
last_line = (line_numer == (lines.count - 1))
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb
index 47e720a201..75edbf2b88 100644
--- a/lib/bundler/env.rb
+++ b/lib/bundler/env.rb
@@ -75,7 +75,7 @@ module Bundler
end
def git_version
- Bundler::Source::Git::GitProxy.new(nil, nil, nil).version
+ Bundler::Source::Git::GitProxy.new(nil, nil, nil).full_version
rescue Bundler::Source::Git::GitNotInstalledError
"not installed"
end
diff --git a/lib/bundler/environment.rb b/lib/bundler/environment.rb
deleted file mode 100644
index b12a146a77..0000000000
--- a/lib/bundler/environment.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-# frozen_string_literal: true
-module Bundler
- class Environment
- attr_reader :root
-
- def initialize(root, definition)
- @root = root
- @definition = definition
-
- env_file = Bundler.app_config_path.join("environment.rb")
- env_file.rmtree if env_file.exist?
- end
-
- def inspect
- @definition.to_lock.inspect
- end
-
- def requested_specs
- @definition.requested_specs
- end
-
- def specs
- @definition.specs
- end
-
- def dependencies
- @definition.dependencies
- end
-
- def current_dependencies
- @definition.current_dependencies
- end
-
- def lock(opts = {})
- @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
- end
-
- def update(*gems)
- # Nothing
- end
- end
-end
diff --git a/lib/bundler/environment_preserver.rb b/lib/bundler/environment_preserver.rb
index 5aaa46b1d8..a891f4854d 100644
--- a/lib/bundler/environment_preserver.rb
+++ b/lib/bundler/environment_preserver.rb
@@ -6,7 +6,7 @@ module Bundler
def initialize(env, keys)
@original = env.to_hash
@keys = keys
- @prefix = "BUNDLE_ORIG_"
+ @prefix = "BUNDLER_ORIG_"
end
# @return [Hash]
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index 8d5a1666ea..0e890d491c 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -255,6 +255,7 @@ module Bundler
end
con.read_timeout = Fetcher.api_timeout
+ con.open_timeout = Fetcher.api_timeout
con.override_headers["User-Agent"] = user_agent
con.override_headers["X-Gemfile-Source"] = @remote.original_uri.to_s if @remote.original_uri
con
diff --git a/lib/bundler/fetcher/base.rb b/lib/bundler/fetcher/base.rb
index 6714ea2cd7..271729a534 100644
--- a/lib/bundler/fetcher/base.rb
+++ b/lib/bundler/fetcher/base.rb
@@ -36,6 +36,16 @@ module Bundler
def api_fetcher?
false
end
+
+ private
+
+ def log_specs(debug_msg)
+ if Bundler.ui.debug?
+ Bundler.ui.debug debug_msg
+ else
+ Bundler.ui.info ".", false
+ end
+ end
end
end
end
diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb
index c0e1b3b4cf..fb77451822 100644
--- a/lib/bundler/fetcher/compact_index.rb
+++ b/lib/bundler/fetcher/compact_index.rb
@@ -36,7 +36,7 @@ module Bundler
remaining_gems = gem_names.dup
until remaining_gems.empty?
- Bundler.ui.debug "Looking up gems #{remaining_gems.inspect}"
+ log_specs "Looking up gems #{remaining_gems.inspect}"
deps = compact_index_client.dependencies(remaining_gems)
next_gems = deps.map {|d| d[3].map(&:first).flatten(1) }.flatten(1).uniq
@@ -44,6 +44,8 @@ module Bundler
complete_gems.concat(deps.map(&:first)).uniq!
remaining_gems = next_gems - complete_gems
end
+ @bundle_worker.stop if @bundle_worker
+ @bundle_worker = nil # reset it. Not sure if necessary
gem_info
end
@@ -76,28 +78,44 @@ module Bundler
private
def compact_index_client
- @compact_index_client ||= begin
- compact_fetcher = lambda do |path, headers|
- downloader.fetch(fetch_uri + path, headers)
- end
-
+ @compact_index_client ||=
SharedHelpers.filesystem_access(cache_path) do
CompactIndexClient.new(cache_path, compact_fetcher)
end.tap do |client|
client.in_parallel = lambda do |inputs, &blk|
func = lambda {|object, _index| blk.call(object) }
- worker_name = "Compact Index (#{display_uri.host})"
- worker = Bundler::Worker.new(25, worker_name, func)
+ worker = bundle_worker(func)
inputs.each {|input| worker.enq(input) }
- inputs.map { worker.deq }.tap { worker.stop }
+ inputs.map { worker.deq }
end
end
+ end
+
+ def bundle_worker(func = nil)
+ @bundle_worker ||= begin
+ worker_name = "Compact Index (#{display_uri.host})"
+ Bundler::Worker.new(25, worker_name, func)
+ end
+ @bundle_worker.tap do |worker|
+ worker.instance_variable_set(:@func, func) if func
end
end
def cache_path
Bundler.user_cache.join("compact_index", remote.cache_slug)
end
+
+ def compact_fetcher
+ lambda do |path, headers|
+ begin
+ downloader.fetch(fetch_uri + path, headers)
+ rescue NetworkDownError => e
+ raise unless Bundler.settings[:allow_offline_install] && headers["If-None-Match"]
+ Bundler.ui.warn "Using the cached data for the new index because of a network error: #{e}"
+ Net::HTTPNotModified.new(nil, nil, nil)
+ end
+ end
+ end
end
end
end
diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb
index a145837a88..1cd5f9a213 100644
--- a/lib/bundler/fetcher/dependency.rb
+++ b/lib/bundler/fetcher/dependency.rb
@@ -23,7 +23,7 @@ module Bundler
def specs(gem_names, full_dependency_list = [], last_spec_list = [])
query_list = gem_names.uniq - full_dependency_list
- log_specs(query_list)
+ log_specs "Query List: #{query_list.inspect}"
return last_spec_list if query_list.empty?
@@ -76,17 +76,6 @@ module Bundler
uri.query = "gems=#{CGI.escape(gem_names.join(","))}" if gem_names.any?
uri
end
-
- private
-
- def log_specs(query_list)
- # only display the message on the first run
- if Bundler.ui.debug?
- Bundler.ui.debug "Query List: #{query_list.inspect}"
- else
- Bundler.ui.info ".", false
- end
- end
end
end
end
diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb
index a4ba4f3af8..c8d714c05a 100644
--- a/lib/bundler/fetcher/downloader.rb
+++ b/lib/bundler/fetcher/downloader.rb
@@ -14,7 +14,7 @@ module Bundler
raise HTTPError, "Too many redirects" if counter >= redirect_limit
response = request(uri, options)
- Bundler.ui.debug("HTTP #{response.code} #{response.message}")
+ Bundler.ui.debug("HTTP #{response.code} #{response.message} #{uri}")
case response
when Net::HTTPSuccess, Net::HTTPNotModified
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index a01c03f25c..df45dd6946 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -12,7 +12,7 @@ module Bundler
when YamlSyntaxError
Bundler.ui.error error.message
Bundler.ui.trace error.orig_exception
- when Dsl::DSLError
+ when Dsl::DSLError, GemspecError
Bundler.ui.error error.message
when GemRequireError
Bundler.ui.error error.message
@@ -89,8 +89,10 @@ module Bundler
end
def issues_url(exception)
+ message = exception.message.lines.first.tr(":", " ").chomp
+ message = message.split("-").first if exception.is_a?(Errno)
"https://github.com/bundler/bundler/search?q=" \
- "#{CGI.escape(exception.message.lines.first.chomp)}&type=Issues"
+ "#{CGI.escape(message)}&type=Issues"
end
end
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index a38136c36d..fdb2db7dbf 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -140,7 +140,7 @@ module Bundler
end
def tag_version
- sh "git tag -a -m \"Version #{version}\" #{version_tag}"
+ sh "git tag -m \"Version #{version}\" #{version_tag}"
Bundler.ui.confirm "Tagged #{version_tag}."
yield if block_given?
rescue
@@ -182,7 +182,7 @@ module Bundler
end
def gem_push?
- ! %w(n no nil false off 0).include?(ENV["gem_push"].to_s.downcase)
+ !%w(n no nil false off 0).include?(ENV["gem_push"].to_s.downcase)
end
end
end
diff --git a/lib/bundler/gem_version_promoter.rb b/lib/bundler/gem_version_promoter.rb
index c2e75adb46..d60d823d9c 100644
--- a/lib/bundler/gem_version_promoter.rb
+++ b/lib/bundler/gem_version_promoter.rb
@@ -120,14 +120,13 @@ module Bundler
result = spec_groups.sort do |a, b|
@a_ver = a.version
@b_ver = b.version
- case
- when major?
+ if major?
@a_ver <=> @b_ver
- when either_version_older_than_locked
+ elsif either_version_older_than_locked
@a_ver <=> @b_ver
- when segments_do_not_match(:major)
+ elsif segments_do_not_match(:major)
@b_ver <=> @a_ver
- when !minor? && segments_do_not_match(:minor)
+ elsif !minor? && segments_do_not_match(:minor)
@b_ver <=> @a_ver
else
@a_ver <=> @b_ver
diff --git a/lib/bundler/graph.rb b/lib/bundler/graph.rb
index c7e957ad7a..e145590430 100644
--- a/lib/bundler/graph.rb
+++ b/lib/bundler/graph.rb
@@ -17,7 +17,6 @@ module Bundler
@node_options = {}
@edge_options = {}
- _patching_gem_dependency_class
_populate_relations
end
@@ -36,10 +35,7 @@ module Bundler
tmp = Set.new
parent_dependencies.each do |dependency|
- # if the dependency is a prerelease, allow to_spec to be non-nil
- dependency.prerelease = true
-
- child_dependencies = dependency.to_spec.runtime_dependencies.to_set
+ child_dependencies = spec_for_dependency(dependency).runtime_dependencies.to_set
@relations[dependency.name] += child_dependencies.map(&:name).to_set
tmp += child_dependencies
@@ -74,7 +70,7 @@ module Bundler
when :node
if symbol_or_string_or_dependency.is_a?(Gem::Dependency)
label = symbol_or_string_or_dependency.name.dup
- label << "\n#{symbol_or_string_or_dependency.to_spec.version}" if @show_version
+ label << "\n#{spec_for_dependency(symbol_or_string_or_dependency).version}" if @show_version
else
label = symbol_or_string_or_dependency.to_s
end
@@ -90,25 +86,8 @@ module Bundler
label.nil? ? {} : { :label => label }
end
- def _patching_gem_dependency_class
- # method borrow from rubygems/dependency.rb
- # redefinition of matching_specs will also redefine to_spec and to_specs
- Gem::Dependency.class_eval do
- def matching_specs(platform_only = false)
- matches = Bundler.load.specs.select do |spec|
- name == spec.name &&
- requirement.satisfied_by?(spec.version)
- end
-
- if platform_only
- matches.select! do |spec|
- Gem::Platform.match spec.platform
- end
- end
-
- matches = matches.sort_by(&:sort_obj) # HACK: shouldn't be needed
- end
- end
+ def spec_for_dependency(dependency)
+ @env.requested_specs.find {|s| s.name == dependency.name }
end
class GraphVizClient
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index f0ee411df8..4529c57279 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -67,12 +67,20 @@ module Bundler
end
end
- results.sort_by do |s|
+ sort_specs(results)
+ end
+
+ def self.sort_specs(specs)
+ specs.sort_by do |s|
platform_string = s.platform.to_s
[s.version, platform_string == RUBY ? NULL : platform_string]
end
end
+ def sort_specs(specs)
+ self.class.sort_specs(specs)
+ end
+
def local_search(query, base = nil)
case query
when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
index 6f3cd6c132..dcaf22944c 100644
--- a/lib/bundler/inline.rb
+++ b/lib/bundler/inline.rb
@@ -60,8 +60,8 @@ def gemfile(install = false, options = {}, &gemfile)
Bundler.ui = ui if install
if install || missing_specs.call
- Bundler::Installer.install(Bundler.root, definition, :system => true)
- Bundler::Installer.post_install_messages.each do |name, message|
+ installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
+ installer.post_install_messages.each do |name, message|
Bundler.ui.info "Post-install message from #{name}:\n#{message}"
end
end
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index c19b2edbc0..aa0c5f1c8e 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -7,14 +7,15 @@ require "bundler/installer/standalone"
require "bundler/installer/gem_installer"
module Bundler
- class Installer < Environment
+ class Installer
class << self
- attr_accessor :post_install_messages, :ambiguous_gems
+ attr_accessor :ambiguous_gems
- Installer.post_install_messages = {}
Installer.ambiguous_gems = []
end
+ attr_reader :post_install_messages
+
# Begins the installation process for Bundler.
# For more information see the #run method on this class.
def self.install(root, definition, options = {})
@@ -23,6 +24,12 @@ module Bundler
installer
end
+ def initialize(root, definition)
+ @root = root
+ @definition = definition
+ @post_install_messages = {}
+ end
+
# Runs the install procedures for a specific Gemfile.
#
# Firstly, this method will check to see if Bundler.bundle_path exists
@@ -61,7 +68,7 @@ module Bundler
@definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
end
- if dependencies.empty?
+ if @definition.dependencies.empty?
Bundler.ui.warn "The Gemfile specifies no dependencies"
lock
return
@@ -108,7 +115,7 @@ module Bundler
next
end
- File.open(binstub_path, "w", 0777 & ~File.umask) do |f|
+ File.open(binstub_path, "w", 0o777 & ~File.umask) do |f|
f.puts ERB.new(template, nil, "-").result(binding)
end
end
@@ -138,7 +145,7 @@ module Bundler
spec.executables.each do |executable|
next if executable == "bundle"
executable_path = executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
- File.open "#{bin_path}/#{executable}", "w", 0755 do |f|
+ File.open "#{bin_path}/#{executable}", "w", 0o755 do |f|
f.puts ERB.new(template, nil, "-").result(binding)
end
end
@@ -160,7 +167,7 @@ module Bundler
def ensure_specs_are_compatible!
system_ruby = Bundler::RubyVersion.system
rubygems_version = Gem::Version.create(Gem::VERSION)
- specs.each do |spec|
+ @definition.specs.each do |spec|
if required_ruby_version = spec.required_ruby_version
unless required_ruby_version.satisfied_by?(system_ruby.gem_version)
raise InstallError, "#{spec.full_name} requires ruby version #{required_ruby_version}, " \
@@ -187,7 +194,10 @@ module Bundler
end
def install_in_parallel(size, standalone, force = false)
- ParallelInstaller.call(self, specs, size, standalone, force)
+ spec_installations = ParallelInstaller.call(self, @definition.specs, size, standalone, force)
+ spec_installations.each do |installation|
+ post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
+ end
end
def create_bundle_path
@@ -213,5 +223,9 @@ module Bundler
return if local
options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
end
+
+ def lock(opts = {})
+ @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
+ end
end
end
diff --git a/lib/bundler/installer/gem_installer.rb b/lib/bundler/installer/gem_installer.rb
index a91990d5f5..84dee979b5 100644
--- a/lib/bundler/installer/gem_installer.rb
+++ b/lib/bundler/installer/gem_installer.rb
@@ -15,16 +15,24 @@ module Bundler
post_install_message = spec_settings ? install_with_settings : install
Bundler.ui.debug "#{worker}: #{spec.name} (#{spec.version}) from #{spec.loaded_from}"
generate_executable_stubs
- post_install_message
-
+ return true, post_install_message
+ rescue Bundler::InstallHookError, Bundler::SecurityError
+ raise
rescue Errno::ENOSPC
- raise Bundler::InstallError, out_of_space_message
+ return false, out_of_space_message
rescue => e
- handle_exception(e)
+ return false, specific_failure_message(e)
end
private
+ def specific_failure_message(e)
+ message = "#{e.class}: #{e.message}\n"
+ message += " " + e.backtrace.join("\n ") + "\n\n" if Bundler.ui.debug?
+ message = message.lines.first + Bundler.ui.add_color(message.lines.drop(1).join, :clear)
+ message + Bundler.ui.add_color(failure_message, :red)
+ end
+
def failure_message
return install_error_message if spec.source.options["git"]
"#{install_error_message}\n#{gem_install_message}"
@@ -38,16 +46,6 @@ module Bundler
"Make sure that `gem install #{spec.name} -v '#{spec.version}'` succeeds before bundling."
end
- def handle_exception(e)
- # Die if install hook failed or gem signature is bad.
- raise e if e.is_a?(Bundler::InstallHookError) || e.is_a?(Bundler::SecurityError)
- # other failure, likely a native extension build failure
- Bundler.ui.info ""
- Bundler.ui.warn "#{e.class}: #{e.message}"
- Bundler.ui.debug e.backtrace.join("\n")
- raise Bundler::InstallError, failure_message
- end
-
def spec_settings
# Fetch the build settings, if there are any
Bundler.settings["build.#{spec.name}"]
@@ -63,7 +61,7 @@ module Bundler
end
def out_of_space_message
- "Your disk is out of space. Free some space to be able to install your bundle."
+ "#{install_error_message}\nYour disk is out of space. Free some space to be able to install your bundle."
end
def generate_executable_stubs
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
index d3ae86d174..12f11bb5f0 100644
--- a/lib/bundler/installer/parallel_installer.rb
+++ b/lib/bundler/installer/parallel_installer.rb
@@ -5,12 +5,13 @@ require "bundler/installer/gem_installer"
module Bundler
class ParallelInstaller
class SpecInstallation
- attr_accessor :spec, :name, :post_install_message, :state
+ attr_accessor :spec, :name, :post_install_message, :state, :error
def initialize(spec)
@spec = spec
@name = spec.name
@state = :none
@post_install_message = ""
+ @error = nil
end
def installed?
@@ -21,9 +22,17 @@ module Bundler
state == :enqueued
end
+ def failed?
+ state == :failed
+ end
+
+ def installation_attempted?
+ installed? || failed?
+ end
+
# Only true when spec in neither installed nor already enqueued
def ready_to_enqueue?
- !installed? && !enqueued?
+ !enqueued? && !installation_attempted?
end
def has_post_install_message?
@@ -80,17 +89,25 @@ module Bundler
def call
enqueue_specs
- process_specs until @specs.all?(&:installed?)
+ process_specs until @specs.all?(&:installed?) || @specs.any?(&:failed?)
+ handle_error if @specs.any?(&:failed?)
+ @specs
ensure
worker_pool && worker_pool.stop
end
def worker_pool
@worker_pool ||= Bundler::Worker.new @size, "Parallel Installer", lambda { |spec_install, worker_num|
- message = Bundler::GemInstaller.new(
+ gem_installer = Bundler::GemInstaller.new(
spec_install.spec, @installer, @standalone, worker_num, @force
- ).install_from_spec
- spec_install.post_install_message = message unless message.nil?
+ )
+ success, message = gem_installer.install_from_spec
+ if success && !message.nil?
+ spec_install.post_install_message = message
+ elsif !success
+ spec_install.state = :failed
+ spec_install.error = message
+ end
spec_install
}
end
@@ -102,13 +119,16 @@ module Bundler
# dequeue.
def process_specs
spec = worker_pool.deq
- spec.state = :installed
- collect_post_install_message spec if spec.has_post_install_message?
+ spec.state = :installed unless spec.failed?
enqueue_specs
end
- def collect_post_install_message(spec)
- Bundler::Installer.post_install_messages[spec.name] = spec.post_install_message
+ def handle_error
+ errors = @specs.select(&:failed?).map(&:error)
+ if exception = errors.find {|e| e.is_a?(Bundler::BundlerError) }
+ raise exception
+ end
+ raise Bundler::InstallError, errors.map(&:to_s).join("\n\n")
end
# Keys in the remains hash represent uninstalled gems specs.
@@ -119,8 +139,8 @@ module Bundler
def enqueue_specs
@specs.select(&:ready_to_enqueue?).each do |spec|
if spec.dependencies_installed? @specs
- worker_pool.enq spec
spec.state = :enqueued
+ worker_pool.enq spec
end
end
end
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index ccaa791cc8..36ff5c59ed 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -5,6 +5,8 @@ require "bundler/match_platform"
module Bundler
class LazySpecification
+ Identifier = Struct.new(:name, :version, :source, :platform, :dependencies)
+
include MatchPlatform
attr_reader :name, :version, :dependencies, :platform
@@ -61,11 +63,15 @@ module Bundler
end
def to_s
- @__to_s ||= "#{name} (#{version})"
+ @__to_s ||= if platform == Gem::Platform::RUBY || platform.nil?
+ "#{name} (#{version})"
+ else
+ "#{name} (#{version}-#{platform})"
+ end
end
def identifier
- @__identifier ||= [name, version, source, platform, dependencies].hash
+ @__identifier ||= Identifier.new(name, version, source, platform, dependencies)
end
private
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index d5b2844079..90da4ac608 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -207,8 +207,10 @@ module Bundler
def parse_spec(line)
if line =~ NAME_VERSION_4
name = $1
- version = Gem::Version.new($2)
- platform = $3 ? Gem::Platform.new($3) : Gem::Platform::RUBY
+ version = $2
+ platform = $3
+ version = Gem::Version.new(version)
+ platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
@current_spec = LazySpecification.new(name, version, platform)
@current_spec.source = @current_source
diff --git a/lib/bundler/mirror.rb b/lib/bundler/mirror.rb
index 655d2b3d07..a1f3aaefa2 100644
--- a/lib/bundler/mirror.rb
+++ b/lib/bundler/mirror.rb
@@ -43,7 +43,7 @@ module Bundler
private
def fetch_valid_mirror_for(uri)
- mirror = (@mirrors[URI(uri.to_s.downcase)] || Mirror.new(uri)).validate!(@prober)
+ mirror = (@mirrors[URI(uri.to_s.downcase)] || @mirrors[URI(uri.to_s).host] || Mirror.new(uri)).validate!(@prober)
mirror = Mirror.new(uri) unless mirror.valid?
mirror
end
@@ -121,7 +121,7 @@ module Bundler
if uri == "all"
@all = true
else
- @uri = Settings.normalize_uri(uri)
+ @uri = URI(uri).absolute? ? Settings.normalize_uri(uri) : uri
end
@value = value
end
diff --git a/lib/bundler/postit_trampoline.rb b/lib/bundler/postit_trampoline.rb
index 010293ea3c..dbb23aa4d9 100644
--- a/lib/bundler/postit_trampoline.rb
+++ b/lib/bundler/postit_trampoline.rb
@@ -1,62 +1,68 @@
# frozen_string_literal: true
+if ENV["BUNDLE_ENABLE_TRAMPOLINE"]
-module BundlerVendoredPostIt; end
-require "bundler/vendor/postit/lib/postit"
-require "rubygems"
+ module BundlerVendoredPostIt; end
+ require "bundler/vendor/postit/lib/postit"
+ require "rubygems"
-environment = BundlerVendoredPostIt::PostIt::Environment.new([])
-version = Gem::Requirement.new(environment.bundler_version)
+ environment = BundlerVendoredPostIt::PostIt::Environment.new([])
+ version = Gem::Requirement.new(environment.bundler_version)
-installed_version =
- if defined?(Bundler::VERSION)
- Bundler::VERSION
- else
- File.read(File.expand_path("../version.rb", __FILE__)) =~ /VERSION = "(.+)"/
- $1
- end
-installed_version &&= Gem::Version.new(installed_version)
-
-if !version.satisfied_by?(installed_version)
- begin
- installer = BundlerVendoredPostIt::PostIt::Installer.new(version)
- installer.install!
- rescue => e
- abort <<-EOS.strip
+ installed_version =
+ if defined?(Bundler::VERSION)
+ Bundler::VERSION
+ else
+ File.read(File.expand_path("../version.rb", __FILE__)) =~ /VERSION = "(.+)"/
+ $1
+ end
+ installed_version &&= Gem::Version.new(installed_version)
+
+ if !version.satisfied_by?(installed_version)
+ begin
+ installer = BundlerVendoredPostIt::PostIt::Installer.new(version)
+ unless installer.installed?
+ warn "Installing locked Bundler version #{version.to_s.gsub("= ", "")}..."
+ installer.install!
+ end
+ rescue => e
+ abort <<-EOS.strip
Installing the inferred bundler version (#{version}) failed.
If you'd like to update to the current bundler version (#{installed_version}) in this project, run `bundle update --bundler`.
The error was: #{e}
EOS
- end
+ end
- if deleted_spec = Gem.loaded_specs.delete("bundler")
- deleted_spec.full_require_paths.each {|path| $:.delete(path) }
- else
- $:.delete(File.expand_path("../..", __FILE__))
- end
- gem "bundler", version
-else
- begin
+ if deleted_spec = Gem.loaded_specs.delete("bundler")
+ deleted_spec.full_require_paths.each {|path| $:.delete(path) }
+ else
+ $:.delete(File.expand_path("../..", __FILE__))
+ end
gem "bundler", version
- rescue LoadError
- $:.unshift(File.expand_path("../..", __FILE__))
+ else
+ begin
+ gem "bundler", version
+ rescue LoadError
+ $:.unshift(File.expand_path("../..", __FILE__))
+ end
end
-end
-running_version = begin
- require "bundler/version"
- Bundler::VERSION
-rescue LoadError, NameError
- nil
-end
+ running_version = begin
+ require "bundler/version"
+ Bundler::VERSION
+ rescue LoadError, NameError
+ nil
+ end
-if Gem::Requirement.new(">= 1.13.pre".dup).satisfied_by?(Gem::Version.new(running_version))
ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"] = installed_version.to_s
-elsif ARGV.empty? || ARGV.any? {|a| %w(install i).include? a }
- puts <<-WARN.strip
+
+ if !Gem::Requirement.new(">= 1.13.pre".dup).satisfied_by?(Gem::Version.new(running_version)) && (ARGV.empty? || ARGV.any? {|a| %w(install i).include? a })
+ puts <<-WARN.strip
You're running Bundler #{installed_version} but this project uses #{running_version}. To update, run `bundle update --bundler`.
WARN
-end
+ end
+
+ if !Gem::Version.correct?(running_version.to_s) || !version.satisfied_by?(Gem::Version.create(running_version))
+ abort "The running bundler (#{running_version}) does not match the required `#{version}`"
+ end
-if !Gem::Version.correct?(running_version.to_s) || !version.satisfied_by?(Gem::Version.create(running_version))
- abort "The running bundler (#{running_version}) does not match the required `#{version}`"
-end
+end # unless ENV["BUNDLE_ENABLE_TRAMPOLINE"]
diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb
index bf4d6ab7f7..a7a72feed5 100644
--- a/lib/bundler/retry.rb
+++ b/lib/bundler/retry.rb
@@ -45,7 +45,8 @@ module Bundler
@failed = true
raise e if last_attempt? || @exceptions.any? {|k| e.is_a?(k) }
return true unless name
- Bundler.ui.warn "Retrying#{" #{name}" if name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}"
+ Bundler.ui.info "" unless Bundler.ui.debug? # Add new line incase dots preceded this
+ Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug?
end
def keep_trying?
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 88c446e11a..fc8eadd186 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -16,8 +16,15 @@ module Gem
class Specification
attr_accessor :remote, :location, :relative_loaded_from
- remove_method :source if instance_methods(false).include?(:source)
- attr_accessor :source
+ if instance_methods(false).map(&:to_sym).include?(:source)
+ remove_method :source
+ attr_writer :source
+ def source
+ (defined?(@source) && @source) || Gem::Source::Installed.new
+ end
+ else
+ attr_accessor :source
+ end
alias_method :rg_full_gem_path, :full_gem_path
alias_method :rg_loaded_from, :loaded_from
diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb
index 43637e1e60..e18f46268b 100644
--- a/lib/bundler/rubygems_gem_installer.rb
+++ b/lib/bundler/rubygems_gem_installer.rb
@@ -3,6 +3,12 @@ require "rubygems/installer"
module Bundler
class RubyGemsGemInstaller < Gem::Installer
+ unless respond_to?(:at)
+ def self.at(*args)
+ new(*args)
+ end
+ end
+
def check_executable_overwrite(filename)
# Bundler needs to install gems regardless of binstub overwriting
end
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index af2e2f2fca..c1bb6c7ab8 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -19,6 +19,10 @@ module Bundler
Gem::Requirement.new(req_str).satisfied_by?(version)
end
+ def initialize
+ @replaced_methods = {}
+ end
+
def version
self.class.version
end
@@ -132,6 +136,14 @@ module Bundler
Gem.path
end
+ def reset
+ Gem::Specification.reset
+ end
+
+ def post_reset_hooks
+ Gem.post_reset_hooks
+ end
+
def gem_cache
gem_path.map {|p| File.expand_path("cache", p) }
end
@@ -265,7 +277,9 @@ module Bundler
def download_gem(spec, uri, path)
uri = Bundler.settings.mirror_for(uri)
fetcher = Gem::RemoteFetcher.new(configuration[:http_proxy])
- fetcher.download(spec, uri, path)
+ Bundler::Retry.new("download gem #{uri}", Gem::RemoteFetcher::FetchError).attempts do
+ fetcher.download(spec, uri, path)
+ end
end
def security_policy_keys
@@ -283,13 +297,11 @@ module Bundler
def reverse_rubygems_kernel_mixin
# Disable rubygems' gem activation system
- ::Kernel.class_eval do
- if private_method_defined?(:gem_original_require)
- alias_method :rubygems_require, :require
- alias_method :require, :gem_original_require
+ kernel = (class << ::Kernel; self; end)
+ [kernel, ::Kernel].each do |k|
+ if k.private_method_defined?(:gem_original_require)
+ redefine_method(k, :require, k.instance_method(:gem_original_require))
end
-
- undef gem
end
end
@@ -298,41 +310,44 @@ module Bundler
executables = specs.map(&:executables).flatten
- ::Kernel.send(:define_method, :gem) do |dep, *reqs|
- if executables.include? File.basename(caller.first.split(":").first)
- break
- end
- reqs.pop if reqs.last.is_a?(Hash)
-
- unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
- dep = Gem::Dependency.new(dep, reqs)
- end
-
- spec = specs.find {|s| s.name == dep.name }
-
- if spec.nil?
+ kernel = (class << ::Kernel; self; end)
+ [kernel, ::Kernel].each do |kernel_class|
+ redefine_method(kernel_class, :gem) do |dep, *reqs|
+ if executables.include? File.basename(caller.first.split(":").first)
+ break
+ end
+ reqs.pop if reqs.last.is_a?(Hash)
- e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
- e.name = dep.name
- if e.respond_to?(:requirement=)
- e.requirement = dep.requirement
- else
- e.version_requirement = dep.requirement
+ unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
+ dep = Gem::Dependency.new(dep, reqs)
end
- raise e
- elsif dep !~ spec
- e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
- "Make sure all dependencies are added to Gemfile."
- e.name = dep.name
- if e.respond_to?(:requirement=)
- e.requirement = dep.requirement
- else
- e.version_requirement = dep.requirement
+
+ spec = specs.find {|s| s.name == dep.name }
+
+ if spec.nil?
+
+ e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
+ e.name = dep.name
+ if e.respond_to?(:requirement=)
+ e.requirement = dep.requirement
+ else
+ e.version_requirement = dep.requirement
+ end
+ raise e
+ elsif dep !~ spec
+ e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
+ "Make sure all dependencies are added to Gemfile."
+ e.name = dep.name
+ if e.respond_to?(:requirement=)
+ e.requirement = dep.requirement
+ else
+ e.version_requirement = dep.requirement
+ end
+ raise e
end
- raise e
- end
- true
+ true
+ end
end
end
@@ -463,9 +478,19 @@ module Bundler
end
end
- def redefine_method(klass, method, &block)
+ def undo_replacements
+ @replaced_methods.each do |(sym, klass), method|
+ redefine_method(klass, sym, method)
+ end
+ post_reset_hooks.reject! do |proc|
+ proc.binding.eval("__FILE__") == __FILE__
+ end
+ @replaced_methods.clear
+ end
+
+ def redefine_method(klass, method, unbound_method = nil, &block)
begin
- if klass.instance_method(method) && method != :initialize
+ if (instance_method = klass.instance_method(method)) && method != :initialize
# doing this to ensure we also get private methods
klass.send(:remove_method, method)
end
@@ -473,7 +498,12 @@ module Bundler
# method isn't defined
nil
end
- klass.send(:define_method, method, &block)
+ @replaced_methods[[method, klass]] = instance_method
+ if unbound_method
+ klass.send(:define_method, method, unbound_method)
+ elsif block
+ klass.send(:define_method, method, &block)
+ end
end
# Rubygems 1.4 through 1.6
@@ -489,11 +519,11 @@ module Bundler
def stub_rubygems(specs)
# Rubygems versions lower than 1.7 use SourceIndex#from_gems_in
source_index_class = (class << Gem::SourceIndex; self; end)
- source_index_class.send(:define_method, :from_gems_in) do |*args|
- source_index = Gem::SourceIndex.new
- source_index.spec_dirs = *args
- source_index.add_specs(*specs)
- source_index
+ redefine_method(source_index_class, :from_gems_in) do |*args|
+ Gem::SourceIndex.new.tap do |source_index|
+ source_index.spec_dirs = *args
+ source_index.add_specs(*specs)
+ end
end
end
@@ -510,6 +540,13 @@ module Bundler
# which is too strict for the kinds of checks we care about. As a
# result, validation is disabled on versions of RubyGems below 1.7.
end
+
+ def post_reset_hooks
+ []
+ end
+
+ def reset
+ end
end
# Rubygems versions 1.3.6 and 1.3.7
@@ -688,25 +725,23 @@ module Bundler
end
end
- if RubygemsIntegration.provides?(">= 2.1.0")
- @rubygems = RubygemsIntegration::MoreFuture.new
- elsif RubygemsIntegration.provides?(">= 1.99.99")
- @rubygems = RubygemsIntegration::Future.new
- elsif RubygemsIntegration.provides?(">= 1.8.20")
- @rubygems = RubygemsIntegration::MoreModern.new
- elsif RubygemsIntegration.provides?(">= 1.8.5")
- @rubygems = RubygemsIntegration::Modern.new
- elsif RubygemsIntegration.provides?(">= 1.8.0")
- @rubygems = RubygemsIntegration::AlmostModern.new
- elsif RubygemsIntegration.provides?(">= 1.7.0")
- @rubygems = RubygemsIntegration::Transitional.new
- elsif RubygemsIntegration.provides?(">= 1.4.0")
- @rubygems = RubygemsIntegration::Legacy.new
- else # Rubygems 1.3.6 and 1.3.7
- @rubygems = RubygemsIntegration::Ancient.new
- end
-
- class << self
- attr_reader :rubygems
+ def self.rubygems
+ @rubygems ||= if RubygemsIntegration.provides?(">= 2.1.0")
+ RubygemsIntegration::MoreFuture.new
+ elsif RubygemsIntegration.provides?(">= 1.99.99")
+ RubygemsIntegration::Future.new
+ elsif RubygemsIntegration.provides?(">= 1.8.20")
+ RubygemsIntegration::MoreModern.new
+ elsif RubygemsIntegration.provides?(">= 1.8.5")
+ RubygemsIntegration::Modern.new
+ elsif RubygemsIntegration.provides?(">= 1.8.0")
+ RubygemsIntegration::AlmostModern.new
+ elsif RubygemsIntegration.provides?(">= 1.7.0")
+ RubygemsIntegration::Transitional.new
+ elsif RubygemsIntegration.provides?(">= 1.4.0")
+ RubygemsIntegration::Legacy.new
+ else # Rubygems 1.3.6 and 1.3.7
+ RubygemsIntegration::Ancient.new
+ end
end
end
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index 3a86fe9226..fda499cf5a 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -2,9 +2,14 @@
require "digest/sha1"
module Bundler
- class Runtime < Environment
+ class Runtime
include SharedHelpers
+ def initialize(root, definition)
+ @root = root
+ @definition = definition
+ end
+
def setup(*groups)
groups.map!(&:to_sym)
@@ -107,6 +112,24 @@ module Bundler
end
end
+ def self.definition_method(meth)
+ define_method(meth) do
+ raise ArgumentError, "no definition when calling Runtime##{meth}" unless @definition
+ @definition.send(meth)
+ end
+ end
+ private_class_method :definition_method
+
+ definition_method :requested_specs
+ definition_method :specs
+ definition_method :dependencies
+ definition_method :current_dependencies
+ definition_method :requires
+
+ def lock(opts = {})
+ @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
+ end
+
alias_method :gems, :specs
def cache(custom_path = nil)
@@ -247,7 +270,7 @@ module Bundler
def setup_manpath
# Store original MANPATH for restoration later in with_clean_env()
- ENV["BUNDLE_ORIG_MANPATH"] = ENV["MANPATH"]
+ ENV["BUNDLER_ORIG_MANPATH"] = ENV["MANPATH"]
# Add man/ subdirectories from activated bundles to MANPATH for man(1)
manuals = $LOAD_PATH.map do |path|
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index ff0b146054..094c859908 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -4,6 +4,7 @@ require "uri"
module Bundler
class Settings
BOOL_KEYS = %w(
+ allow_offline_install
cache_all
disable_local_branch_check
disable_shared_gems
@@ -44,12 +45,11 @@ module Bundler
key = key_for(name)
value = (@local_config[key] || ENV[key] || @global_config[key] || DEFAULT_CONFIG[name])
- case
- when value.nil?
+ if value.nil?
nil
- when is_bool(name) || value == "false"
+ elsif is_bool(name) || value == "false"
to_bool(value)
- when is_num(name)
+ elsif is_num(name)
value.to_i
else
value
@@ -276,11 +276,12 @@ module Bundler
}xo
def load_config(config_file)
- SharedHelpers.filesystem_access(config_file, :read) do
- valid_file = config_file && config_file.exist? && !config_file.size.zero?
+ return unless config_file
+ SharedHelpers.filesystem_access(config_file, :read) do |file|
+ valid_file = file.exist? && !file.size.zero?
return {} if ignore_config? || !valid_file
require "bundler/yaml_serializer"
- YAMLSerializer.load config_file.read
+ YAMLSerializer.load file.read
end
end
@@ -291,7 +292,7 @@ module Bundler
uri = "#{uri}/" unless uri =~ %r{/\Z}
uri = URI(uri)
unless uri.absolute?
- raise ArgumentError, "Gem sources must be absolute. You provided '#{uri}'."
+ raise ArgumentError, format("Gem sources must be absolute. You provided '%s'.", uri)
end
uri
end
diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb
index c888dabf2c..8b4b479778 100644
--- a/lib/bundler/setup.rb
+++ b/lib/bundler/setup.rb
@@ -20,9 +20,12 @@ if Bundler::SharedHelpers.in_bundle?
Bundler.setup
end
- # Add bundler to the load path after disabling system gems
- bundler_lib = File.expand_path("../..", __FILE__)
- $LOAD_PATH.unshift(bundler_lib) unless $LOAD_PATH.include?(bundler_lib)
+ unless ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"]
+ # Add bundler to the load path after disabling system gems
+ # This is guarenteed to be done already if we've trampolined
+ bundler_lib = File.expand_path("../..", __FILE__)
+ $LOAD_PATH.unshift(bundler_lib) unless $LOAD_PATH.include?(bundler_lib)
+ end
Bundler.ui = nil
end
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index efbedeb374..69543356a2 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -23,7 +23,7 @@ module Bundler
def default_gemfile
gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
- Pathname.new(gemfile)
+ Pathname.new(gemfile).untaint
end
def default_lockfile
@@ -32,7 +32,7 @@ module Bundler
case gemfile.basename.to_s
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
else Pathname.new("#{gemfile}.lock")
- end
+ end.untaint
end
def default_bundle_dir
@@ -102,7 +102,7 @@ module Bundler
#
# @see {Bundler::PermissionError}
def filesystem_access(path, action = :write)
- yield path
+ yield path.dup.untaint
rescue Errno::EACCES
raise PermissionError.new(path, action)
rescue Errno::EAGAIN
@@ -158,7 +158,7 @@ module Bundler
def search_up(*names)
previous = nil
- current = File.expand_path(SharedHelpers.pwd)
+ current = File.expand_path(SharedHelpers.pwd).untaint
until !File.directory?(current) || current == previous
if ENV["BUNDLE_SPEC_RUN"]
diff --git a/lib/bundler/source/gemspec.rb b/lib/bundler/source/gemspec.rb
index 37e9a43945..05e613277f 100644
--- a/lib/bundler/source/gemspec.rb
+++ b/lib/bundler/source/gemspec.rb
@@ -8,6 +8,10 @@ module Bundler
super
@gemspec = options["gemspec"]
end
+
+ def as_path_source
+ Path.new(options)
+ end
end
end
end
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index 5344ab694f..60fb555f0a 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -152,7 +152,7 @@ module Bundler
set_local!(app_cache_path) if has_app_cache? && !local?
if requires_checkout? && !@copied
- git_proxy.checkout
+ fetch
git_proxy.copy_to(install_path, submodules)
serialize_gemspecs_in(install_path)
@copied = true
@@ -288,6 +288,13 @@ module Bundler
def git_proxy
@git_proxy ||= GitProxy.new(cache_path, uri, ref, cached_revision, self)
end
+
+ def fetch
+ git_proxy.checkout
+ rescue GitError
+ raise unless Bundler.settings[:allow_offline_install]
+ Bundler.ui.warn "Using cached git data because of network errors"
+ end
end
end
end
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb
index 84d7fee6a9..693492f3d2 100644
--- a/lib/bundler/source/git/git_proxy.rb
+++ b/lib/bundler/source/git/git_proxy.rb
@@ -80,6 +80,10 @@ module Bundler
end
def version
+ git("--version").match(/(git version\s*)?((\.?\d+)+).*/)[2]
+ end
+
+ def full_version
git("--version").sub("git version", "").strip
end
@@ -110,7 +114,7 @@ module Bundler
FileUtils.rm_rf(p)
end
git_retry %(clone --no-checkout --quiet "#{path}" "#{destination}")
- File.chmod(((File.stat(destination).mode | 0777) & ~File.umask), destination)
+ File.chmod(((File.stat(destination).mode | 0o777) & ~File.umask), destination)
rescue Errno::EEXIST => e
file_path = e.message[%r{.*?(/.*)}, 1]
raise GitError, "Bundler could not install a gem because it needs to " \
@@ -143,7 +147,7 @@ module Bundler
end
def git_retry(command)
- Bundler::Retry.new("git #{command}", GitNotAllowedError).attempts do
+ Bundler::Retry.new("`git #{command}`", GitNotAllowedError).attempts do
git(command)
end
end
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 3c4d914fb3..69bb0c1af2 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -11,7 +11,7 @@ module Bundler
DEFAULT_GLOB = "{,*,*/*}.gemspec".freeze
def initialize(options)
- @options = options
+ @options = options.dup
@glob = options["glob"] || DEFAULT_GLOB
@allow_cached = false
@@ -60,7 +60,7 @@ module Bundler
end
def eql?(other)
- return unless other.class == Path || other.class == Gemspec
+ return unless other.class == self.class
expanded_path == expand(other.path) &&
version == other.version
end
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index d9606e7087..aedad7086d 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -134,7 +134,7 @@ module Bundler
installed_spec = nil
Bundler.rubygems.preserve_paths do
- installed_spec = Bundler::RubyGemsGemInstaller.new(
+ installed_spec = Bundler::RubyGemsGemInstaller.at(
path,
:install_dir => install_path.to_s,
:bin_dir => bin_path.to_s,
diff --git a/lib/bundler/templates/Gemfile b/lib/bundler/templates/Gemfile
index 3f953369c3..7db8998d32 100644
--- a/lib/bundler/templates/Gemfile
+++ b/lib/bundler/templates/Gemfile
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-# A sample Gemfile
source "https://rubygems.org"
# gem "rails"
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 195bd56a5c..5c1fa61568 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -17,8 +17,8 @@ module Bundler
@warning_history = []
end
- def add_color(string, color)
- @shell.set_color(string, color)
+ def add_color(string, *color)
+ @shell.set_color(string, *color)
end
def info(msg, newline = nil)
@@ -45,7 +45,7 @@ module Bundler
def debug?
# needs to be false instead of nil to be newline param to other methods
- level("debug")
+ level("debug") ? true : false
end
def quiet?
diff --git a/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb b/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb
index 1679c17c8a..9ab2722f18 100644
--- a/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb
+++ b/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb
@@ -60,9 +60,8 @@ class Bundler::CompactIndexClient
private
def update(local_path, remote_path)
- return if @endpoints.include?(remote_path)
+ return unless @endpoints.add?(remote_path)
@updater.update(local_path, url(remote_path))
- @endpoints << remote_path
end
def update_info(name)
diff --git a/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb b/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb
index a370fa402d..d2639ee717 100644
--- a/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb
+++ b/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+require "digest/md5"
class Bundler::CompactIndexClient
class Cache
attr_reader :directory
def initialize(directory)
@directory = Pathname.new(directory).expand_path
- FileUtils.mkdir_p info_path(nil)
+ info_roots.each {|dir| FileUtils.mkdir_p(dir) }
end
def names
@@ -59,7 +60,13 @@ class Bundler::CompactIndexClient
end
def info_path(name)
- directory.join("info", name.to_s)
+ name = name.to_s
+ if name =~ /[^a-z0-9_-]/
+ name += "-#{Digest::MD5.hexdigest(name).downcase}"
+ info_roots.last.join(name)
+ else
+ info_roots.first.join(name)
+ end
end
def specific_dependency(name, version, platform)
@@ -94,5 +101,12 @@ class Bundler::CompactIndexClient
dependency[-1] = dependency[-1].split("&") if dependency.size > 1
dependency
end
+
+ def info_roots
+ [
+ directory.join("info"),
+ directory.join("info-special-characters"),
+ ]
+ end
end
end
diff --git a/man/bundle-binstubs.ronn b/man/bundle-binstubs.ronn
new file mode 100644
index 0000000000..98dcce66e0
--- /dev/null
+++ b/man/bundle-binstubs.ronn
@@ -0,0 +1,29 @@
+bundle-binstubs(1) -- Install the binstubs of the listed gems
+=============================================================
+
+## SYNOPSIS
+
+`bundle binstubs` <GEM_NAME> [--force] [--path PATH] [--standalone]
+
+## DESCRIPTION
+
+This command generates binstubs for executables in `GEM_NAME`.
+Binstubs are put into `bin`, or the `--path` directory if one has been set.
+Calling binstubs with [GEM [GEM]] will create binstubs for all given gems.
+
+## OPTIONS
+
+* `--force`:
+ Overwrite existing binstubs if they exist.
+
+* `--path`:
+ The location to install the specified binstubs to. This defaults to `bin`.
+
+* `--standalone`:
+ Makes binstubs that can work without depending on Rubygems or Bundler at
+ runtime.
+
+## BUNDLE INSTALL --BINSTUBS
+
+To create binstubs for all the gems in the bundle you can use the `--binstubs`
+flag in [bundle install(1)][bundle-install].
diff --git a/man/bundle-package.ronn b/man/bundle-package.ronn
index eacb83b54d..512b037f51 100644
--- a/man/bundle-package.ronn
+++ b/man/bundle-package.ronn
@@ -27,7 +27,7 @@ in your local bundler configuration.
## REMOTE FETCHING
-By default, if you simply run [bundle install(1)][bundle-install] after running
+By default, if you run [bundle install(1)][bundle-install] after running
[bundle package(1)][bundle-package], bundler will still connect to `rubygems.org`
to check whether a platform-specific gem exists for any of the gems
in `vendor/cache`.
diff --git a/man/bundle.ronn b/man/bundle.ronn
index 55e2c4afe8..72faac048b 100644
--- a/man/bundle.ronn
+++ b/man/bundle.ronn
@@ -82,6 +82,9 @@ We divide `bundle` subcommands into primary commands and utilities.
* `bundle clean(1)`:
Clean up unused gems in your bundler directory
+* `bundle doctor(1)`:
+ Display warnings about common potential problems
+
## PLUGINS
When running a command that isn't listed in PRIMARY COMMANDS or UTILITIES,
diff --git a/man/gemfile.5.ronn b/man/gemfile.5.ronn
index 61f76a8714..da2157e971 100644
--- a/man/gemfile.5.ronn
+++ b/man/gemfile.5.ronn
@@ -42,7 +42,7 @@ credentials from being stored in plain text in version control.
bundle config gems.example.com user:password
-For some sources, like a company Gemfury account, it may be easier to simply
+For some sources, like a company Gemfury account, it may be easier to
include the credentials in the Gemfile as part of the source URL.
source "https://user:password@gems.example.com"
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index b9a8e52cc9..2ff9920614 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -19,7 +19,7 @@ describe Bundler do
end
it "catches YAML syntax errors" do
- expect { subject }.to raise_error(Bundler::GemspecError)
+ expect { subject }.to raise_error(Bundler::GemspecError, /error while loading `test.gemspec`/)
end
context "on Rubies with a settable YAML engine", :if => defined?(YAML::ENGINE) do
@@ -106,7 +106,7 @@ describe Bundler do
describe "#which" do
let(:executable) { "executable" }
- let(:path) { %w(/a /b c ../d "/e") }
+ let(:path) { %w(/a /b c ../d /e) }
let(:expected) { "executable" }
before do
diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb
index 3fe4938f97..ac704fb41d 100644
--- a/spec/bundler/cli_spec.rb
+++ b/spec/bundler/cli_spec.rb
@@ -14,7 +14,7 @@ describe "bundle executable" do
end
it "looks for a binary and executes it if it's named bundler-<task>" do
- File.open(tmp("bundler-testtasks"), "w", 0755) do |f|
+ File.open(tmp("bundler-testtasks"), "w", 0o755) do |f|
f.puts "#!/usr/bin/env ruby\nputs 'Hello, world'\n"
end
@@ -35,7 +35,7 @@ describe "bundle executable" do
bundle :install, :env => { "BUNDLE_GEMFILE" => "" }
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -54,6 +54,13 @@ describe "bundle executable" do
expect(out).not_to include("RUBYGEMS_GEMDEPS")
end
end
+
+ context "with --verbose" do
+ it "prints the running command" do
+ bundle! "config", :verbose => true
+ expect(out).to start_with("Running `bundle config --verbose` with bundler #{Bundler::VERSION}")
+ end
+ end
end
describe "bundler executable" do
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb
index 77d663d754..00d36dd55f 100644
--- a/spec/bundler/dsl_spec.rb
+++ b/spec/bundler/dsl_spec.rb
@@ -80,7 +80,7 @@ describe Bundler::Dsl do
it "handles syntax errors with a useful message" do
expect(Bundler).to receive(:read_file).with("Gemfile").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./)
+ 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
diff --git a/spec/bundler/endpoint_specification_spec.rb b/spec/bundler/endpoint_specification_spec.rb
index cdf81cd0f7..6718b24971 100644
--- a/spec/bundler/endpoint_specification_spec.rb
+++ b/spec/bundler/endpoint_specification_spec.rb
@@ -29,7 +29,8 @@ describe Bundler::EndpointSpecification do
it "should raise the original error" do
expect { subject.send(:build_dependency, name, [requirement1, requirement2]) }.to raise_error(
- ArgumentError, "Some error occurred")
+ ArgumentError, "Some error occurred"
+ )
end
end
@@ -44,7 +45,8 @@ describe Bundler::EndpointSpecification do
it "should raise a Bundler::GemspecError with invalid gemspec message" do
expect { subject.send(:build_dependency, name, [requirement1, requirement2]) }.to raise_error(
- Bundler::GemspecError, /Unfortunately, the gem foo \(1\.0\.0\) has an invalid gemspec/)
+ Bundler::GemspecError, /Unfortunately, the gem foo \(1\.0\.0\) has an invalid gemspec/
+ )
end
end
end
diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb
index 305fcce351..73d1f1d7df 100644
--- a/spec/bundler/env_spec.rb
+++ b/spec/bundler/env_spec.rb
@@ -3,7 +3,8 @@ require "spec_helper"
require "bundler/settings"
describe Bundler::Env do
- let(:env) { described_class.new }
+ let(:env) { described_class.new }
+ let(:git_proxy_stub) { Bundler::Source::Git::GitProxy.new(nil, nil, nil) }
describe "#report" do
it "prints the environment" do
@@ -72,5 +73,15 @@ describe Bundler::Env do
expect(output).to include(gemspec)
end
end
+
+ 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").
+ and_return("git version 1.2.3 (Apple Git-BS)")
+ expect(Bundler::Source::Git::GitProxy).to receive(:new).and_return(git_proxy_stub)
+
+ expect(env.report).to include("Git 1.2.3 (Apple Git-BS)")
+ end
+ end
end
end
diff --git a/spec/bundler/environment_preserver_spec.rb b/spec/bundler/environment_preserver_spec.rb
index 0c2913cc37..496646d654 100644
--- a/spec/bundler/environment_preserver_spec.rb
+++ b/spec/bundler/environment_preserver_spec.rb
@@ -9,7 +9,7 @@ describe Bundler::EnvironmentPreserver do
subject { preserver.backup }
it "should create backup entries" do
- expect(subject["BUNDLE_ORIG_foo"]).to eq("my-foo")
+ expect(subject["BUNDLER_ORIG_foo"]).to eq("my-foo")
end
it "should keep the original entry" do
@@ -17,7 +17,7 @@ describe Bundler::EnvironmentPreserver do
end
it "should not create backup entries for unspecified keys" do
- expect(subject.key?("BUNDLE_ORIG_bar")).to eq(false)
+ expect(subject.key?("BUNDLER_ORIG_bar")).to eq(false)
end
it "should not affect the original env" do
@@ -29,15 +29,15 @@ describe Bundler::EnvironmentPreserver do
let(:env) { { "foo" => "" } }
it "should not create backup entries" do
- expect(subject.key?("BUNDLE_ORIG_foo")).to eq(false)
+ expect(subject.key?("BUNDLER_ORIG_foo")).to eq(false)
end
end
context "when an original key is set" do
- let(:env) { { "foo" => "my-foo", "BUNDLE_ORIG_foo" => "orig-foo" } }
+ let(:env) { { "foo" => "my-foo", "BUNDLER_ORIG_foo" => "orig-foo" } }
- it "should keep the original value in the BUNDLE_ORIG_ variable" do
- expect(subject["BUNDLE_ORIG_foo"]).to eq("orig-foo")
+ it "should keep the original value in the BUNDLER_ORIG_ variable" do
+ expect(subject["BUNDLER_ORIG_foo"]).to eq("orig-foo")
end
it "should keep the variable" do
@@ -50,14 +50,14 @@ describe Bundler::EnvironmentPreserver do
subject { preserver.restore }
context "when an original key is set" do
- let(:env) { { "foo" => "my-foo", "BUNDLE_ORIG_foo" => "orig-foo" } }
+ let(:env) { { "foo" => "my-foo", "BUNDLER_ORIG_foo" => "orig-foo" } }
it "should restore the original value" do
expect(subject["foo"]).to eq("orig-foo")
end
it "should delete the backup value" do
- expect(subject.key?("BUNDLE_ORIG_foo")).to eq(false)
+ expect(subject.key?("BUNDLER_ORIG_foo")).to eq(false)
end
end
@@ -70,7 +70,7 @@ describe Bundler::EnvironmentPreserver do
end
context "when the original key is empty" do
- let(:env) { { "foo" => "my-foo", "BUNDLE_ORIG_foo" => "" } }
+ let(:env) { { "foo" => "my-foo", "BUNDLER_ORIG_foo" => "" } }
it "should keep the current value" do
expect(subject["foo"]).to eq("my-foo")
diff --git a/spec/bundler/fetcher/compact_index_spec.rb b/spec/bundler/fetcher/compact_index_spec.rb
index e111d8a3b6..f6c6ba2ee1 100644
--- a/spec/bundler/fetcher/compact_index_spec.rb
+++ b/spec/bundler/fetcher/compact_index_spec.rb
@@ -7,6 +7,10 @@ describe Bundler::Fetcher::CompactIndex do
let(:display_uri) { URI("http://sampleuri.com") }
let(:compact_index) { described_class.new(downloader, remote, display_uri) }
+ before do
+ allow(compact_index).to receive(:log_specs) {}
+ end
+
describe "#specs_for_names" do
it "has only one thread open at the end of the run" do
compact_index.specs_for_names(["lskdjf"])
@@ -20,5 +24,31 @@ describe Bundler::Fetcher::CompactIndex do
compact_index.specs_for_names(["lskdjf"])
end
+
+ context "logging" do
+ before { allow(compact_index).to receive(:log_specs).and_call_original }
+
+ context "with debug on" do
+ before do
+ allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(true)
+ end
+
+ it "should log at info level" do
+ expect(Bundler).to receive_message_chain(:ui, :debug).with('Looking up gems ["lskdjf"]')
+ compact_index.specs_for_names(["lskdjf"])
+ end
+ end
+
+ context "with debug off" do
+ before do
+ allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(false)
+ end
+
+ it "should log at info level" do
+ expect(Bundler).to receive_message_chain(:ui, :info).with(".", false)
+ compact_index.specs_for_names(["lskdjf"])
+ end
+ end
+ end
end
end
diff --git a/spec/bundler/fetcher/dependency_spec.rb b/spec/bundler/fetcher/dependency_spec.rb
index b11bcdcd79..bf7749d07a 100644
--- a/spec/bundler/fetcher/dependency_spec.rb
+++ b/spec/bundler/fetcher/dependency_spec.rb
@@ -201,7 +201,8 @@ describe Bundler::Fetcher::Dependency do
it "should log the query list at debug level" do
expect(Bundler).to receive_message_chain(:ui, :debug).with(
- "Query Gemcutter Dependency Endpoint API: foo,bar,bundler,rubocop")
+ "Query Gemcutter Dependency Endpoint API: foo,bar,bundler,rubocop"
+ )
subject.dependency_specs(gem_names)
end
@@ -267,7 +268,8 @@ describe Bundler::Fetcher::Dependency do
it "should return an api calling uri with the gems in the query" do
expect(subject.dependency_api_uri(gem_names).to_s).to eq(
- "http://gem-api.com/api/v1/dependencies?gems=foo%2Cbar%2Cbundler%2Crubocop")
+ "http://gem-api.com/api/v1/dependencies?gems=foo%2Cbar%2Cbundler%2Crubocop"
+ )
end
end
@@ -278,7 +280,8 @@ describe Bundler::Fetcher::Dependency do
it "should return an api calling uri with no query" do
expect(subject.dependency_api_uri(gem_names).to_s).to eq(
- "http://gem-api.com/api/v1/dependencies")
+ "http://gem-api.com/api/v1/dependencies"
+ )
end
end
end
diff --git a/spec/bundler/fetcher/downloader_spec.rb b/spec/bundler/fetcher/downloader_spec.rb
index 2d784b4421..8371bcfa6c 100644
--- a/spec/bundler/fetcher/downloader_spec.rb
+++ b/spec/bundler/fetcher/downloader_spec.rb
@@ -31,7 +31,7 @@ describe Bundler::Fetcher::Downloader do
let(:http_response) { Net::HTTPSuccess.new("1.1", 200, "Success") }
it "should log the HTTP response code and message to debug" do
- expect(Bundler).to receive_message_chain(:ui, :debug).with("HTTP 200 Success")
+ expect(Bundler).to receive_message_chain(:ui, :debug).with("HTTP 200 Success #{uri}")
subject.fetch(uri, options, counter)
end
end
diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb
index ae197a4bab..1d88403c0e 100644
--- a/spec/bundler/friendly_errors_spec.rb
+++ b/spec/bundler/friendly_errors_spec.rb
@@ -2,6 +2,7 @@
require "spec_helper"
require "bundler"
require "bundler/friendly_errors"
+require "cgi"
describe Bundler, "friendly errors" do
context "with invalid YAML in .gemrc" do
@@ -36,7 +37,7 @@ describe Bundler, "friendly errors" do
gem "rack"
G
- bundle :install, :env => { "DEBUG" => true }, :expect_err => true
+ bundle :install, :env => { "DEBUG" => true }
expect(err).to include("Failed to load #{home(".gemrc")}")
expect(exitstatus).to eq(0) if exitstatus
@@ -66,5 +67,24 @@ END
expect(Bundler::FriendlyErrors.issues_url(exception)).to eq("https://github.com/bundler/bundler/search?q=First+line+of+the+exception+message&type=Issues")
end
+
+ it "generates the url without colons" do
+ exception = Exception.new(<<END)
+Exception ::: with ::: colons :::
+END
+ issues_url = Bundler::FriendlyErrors.issues_url(exception)
+ expect(issues_url).not_to include("%3A")
+ expect(issues_url).to eq("https://github.com/bundler/bundler/search?q=#{CGI.escape("Exception with colons ")}&type=Issues")
+ end
+
+ it "removes information after - for Errono::EACCES" do
+ exception = Exception.new(<<END)
+Errno::EACCES: Permission denied @ dir_s_mkdir - /Users/foo/bar/
+END
+ allow(exception).to receive(:is_a?).with(Errno).and_return(true)
+ issues_url = Bundler::FriendlyErrors.issues_url(exception)
+ expect(issues_url).not_to include("/Users/foo/bar")
+ expect(issues_url).to eq("https://github.com/bundler/bundler/search?q=#{CGI.escape("Errno EACCES Permission denied @ dir_s_mkdir ")}&type=Issues")
+ end
end
end
diff --git a/spec/bundler/gem_helper_spec.rb b/spec/bundler/gem_helper_spec.rb
index def926e364..4e1af32c11 100644
--- a/spec/bundler/gem_helper_spec.rb
+++ b/spec/bundler/gem_helper_spec.rb
@@ -198,6 +198,10 @@ describe Bundler::GemHelper do
`git config user.name "name"`
`git config push.default simple`
end
+
+ # silence messages
+ allow(Bundler.ui).to receive(:confirm)
+ allow(Bundler.ui).to receive(:error)
end
context "fails" do
@@ -213,10 +217,6 @@ describe Bundler::GemHelper do
end
it "when there is no git remote" do
- # silence messages
- allow(Bundler.ui).to receive(:confirm)
- allow(Bundler.ui).to receive(:error)
-
Dir.chdir(app_path) { `git commit -a -m "initial commit"` }
expect { Rake.application["release"].invoke }.to raise_error(RuntimeError)
end
@@ -237,7 +237,7 @@ describe Bundler::GemHelper do
mock_confirm_message "Pushed git commits and tags."
expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
- Dir.chdir(app_path) { sys_exec("git push -u origin master", true) }
+ Dir.chdir(app_path) { sys_exec("git push -u origin master") }
Rake.application["release"].invoke
end
diff --git a/spec/bundler/gem_version_promoter_spec.rb b/spec/bundler/gem_version_promoter_spec.rb
index 5cbc74bcd9..9e5a7bb581 100644
--- a/spec/bundler/gem_version_promoter_spec.rb
+++ b/spec/bundler/gem_version_promoter_spec.rb
@@ -45,7 +45,8 @@ describe Bundler::GemVersionPromoter do
keep_locked(:level => :patch)
res = @gvp.filter_dep_specs(
build_spec_group("foo", %w(1.7.8 1.7.9 1.8.0)),
- build_spec("foo", "1.7.8").first)
+ build_spec("foo", "1.7.8").first
+ )
expect(versions(res)).to eq %w(1.7.9 1.7.8)
end
@@ -53,7 +54,8 @@ describe Bundler::GemVersionPromoter do
unlocking(:level => :patch)
res = @gvp.filter_dep_specs(
build_spec_group("foo", %w(1.7.8 1.7.9 1.8.0)),
- build_spec("foo", "1.7.8").first)
+ build_spec("foo", "1.7.8").first
+ )
expect(versions(res)).to eq %w(1.7.8 1.7.9)
end
@@ -61,7 +63,8 @@ describe Bundler::GemVersionPromoter do
unlocking(:level => :patch)
res = @gvp.filter_dep_specs(
build_spec_group("foo", %w(1.7.9 1.8.0 2.0.0)),
- build_spec("foo", "1.7.9").first)
+ build_spec("foo", "1.7.9").first
+ )
expect(versions(res)).to eq %w(1.7.9)
end
end
@@ -71,7 +74,8 @@ describe Bundler::GemVersionPromoter do
unlocking(:level => :minor)
res = @gvp.filter_dep_specs(
build_spec_group("foo", %w(0.2.0 0.3.0 0.3.1 0.9.0 1.0.0 2.0.0 2.0.1)),
- build_spec("foo", "0.2.0").first)
+ build_spec("foo", "0.2.0").first
+ )
expect(versions(res)).to eq %w(0.2.0 0.3.0 0.3.1 0.9.0)
end
@@ -79,7 +83,8 @@ describe Bundler::GemVersionPromoter do
keep_locked(:level => :minor)
res = @gvp.filter_dep_specs(
build_spec_group("foo", %w(0.2.0 0.3.0 0.3.1 0.9.0 1.0.0 2.0.0 2.0.1)),
- build_spec("foo", "0.2.0").first)
+ build_spec("foo", "0.2.0").first
+ )
expect(versions(res)).to eq %w(0.3.0 0.3.1 0.9.0 0.2.0)
end
end
@@ -89,7 +94,8 @@ describe Bundler::GemVersionPromoter do
keep_locked(:level => :patch)
res = @gvp.sort_dep_specs(
build_spec_group("foo", %w(1.5.4 1.6.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 2.0.0 2.0.1)),
- build_spec("foo", "1.7.7").first)
+ build_spec("foo", "1.7.7").first
+ )
expect(versions(res)).to eq %w(1.5.4 1.6.5 1.7.6 2.0.0 2.0.1 1.8.0 1.8.1 1.7.8 1.7.9 1.7.7)
end
@@ -97,7 +103,8 @@ describe Bundler::GemVersionPromoter do
unlocking(:level => :patch)
res = @gvp.sort_dep_specs(
build_spec_group("foo", %w(1.7.7 1.7.8 1.7.9 1.8.0)),
- build_spec("foo", "1.7.8").first)
+ build_spec("foo", "1.7.8").first
+ )
expect(versions(res)).to eq %w(1.7.7 1.8.0 1.7.8 1.7.9)
end
@@ -105,7 +112,8 @@ describe Bundler::GemVersionPromoter do
unlocking(:level => :patch)
res = @gvp.sort_dep_specs(
build_spec_group("foo", %w(1.7.7 1.7.8 1.7.9 1.7.15 1.8.0)),
- build_spec("foo", "1.7.8").first)
+ build_spec("foo", "1.7.8").first
+ )
expect(versions(res)).to eq %w(1.7.7 1.8.0 1.7.8 1.7.9 1.7.15)
end
@@ -113,7 +121,8 @@ describe Bundler::GemVersionPromoter do
unlocking(:level => :patch)
res = @gvp.sort_dep_specs(
build_spec_group("foo", %w(1.7.9 1.8.0 2.0.0)),
- build_spec("foo", "1.7.9").first)
+ build_spec("foo", "1.7.9").first
+ )
expect(versions(res)).to eq %w(2.0.0 1.8.0 1.7.9)
end
end
@@ -123,7 +132,8 @@ describe Bundler::GemVersionPromoter do
unlocking(:level => :minor)
res = @gvp.sort_dep_specs(
build_spec_group("foo", %w(0.2.0 0.3.0 0.3.1 0.9.0 1.0.0 2.0.0 2.0.1)),
- build_spec("foo", "0.2.0").first)
+ build_spec("foo", "0.2.0").first
+ )
expect(versions(res)).to eq %w(2.0.0 2.0.1 1.0.0 0.2.0 0.3.0 0.3.1 0.9.0)
end
end
diff --git a/spec/bundler/mirror_spec.rb b/spec/bundler/mirror_spec.rb
index bd6d9bc636..eb0ccf0bdf 100644
--- a/spec/bundler/mirror_spec.rb
+++ b/spec/bundler/mirror_spec.rb
@@ -154,6 +154,16 @@ describe Bundler::Settings::Mirrors do
expect(mirrors.for("http://rubygems.org/").uri).to eq(localhost_uri)
end
+ it "parses a relative mirror key and returns a mirror for the parsed http uri" do
+ mirrors.parse("mirror.rubygems.org", localhost_uri)
+ expect(mirrors.for("http://rubygems.org/").uri).to eq(localhost_uri)
+ end
+
+ it "parses a relative mirror key and returns a mirror for the parsed https uri" do
+ mirrors.parse("mirror.rubygems.org", localhost_uri)
+ expect(mirrors.for("https://rubygems.org/").uri).to eq(localhost_uri)
+ end
+
context "with a uri parsed already" do
before { mirrors.parse("mirror.http://rubygems.org/", localhost_uri) }
diff --git a/spec/bundler/retry_spec.rb b/spec/bundler/retry_spec.rb
index cafa099b51..665ba9f2df 100644
--- a/spec/bundler/retry_spec.rb
+++ b/spec/bundler/retry_spec.rb
@@ -46,4 +46,37 @@ describe Bundler::Retry do
end.to raise_error(error)
expect(attempts).to eq(1)
end
+
+ context "logging" do
+ let(:error) { Bundler::GemfileNotFound }
+ let(:failure_message) { "Retrying test due to error (2/2): #{error} #{error}" }
+
+ context "with debugging on" do
+ it "print error message with newline" do
+ allow(Bundler.ui).to receive(:debug?).and_return(true)
+ expect(Bundler.ui).to_not receive(:info)
+ expect(Bundler.ui).to receive(:warn).with(failure_message, true)
+
+ expect do
+ Bundler::Retry.new("test", [], 1).attempt do
+ raise error
+ end
+ end.to raise_error(error)
+ end
+ end
+
+ context "with debugging on" do
+ it "print error message with newlines" do
+ allow(Bundler.ui).to receive(:debug?).and_return(false)
+ expect(Bundler.ui).to receive(:info).with("")
+ expect(Bundler.ui).to receive(:warn).with(failure_message, false)
+
+ expect do
+ Bundler::Retry.new("test", [], 1).attempt do
+ raise error
+ end
+ end.to raise_error(error)
+ end
+ end
+ end
end
diff --git a/spec/bundler/settings_spec.rb b/spec/bundler/settings_spec.rb
index a4ac02c0fb..0f7d2a0138 100644
--- a/spec/bundler/settings_spec.rb
+++ b/spec/bundler/settings_spec.rb
@@ -204,7 +204,8 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow
it "reads older keys without trailing slashes" do
settings["mirror.https://rubygems.org"] = "http://rubygems-mirror.org"
expect(settings.mirror_for("https://rubygems.org/")).to eq(
- URI("http://rubygems-mirror.org/"))
+ URI("http://rubygems-mirror.org/")
+ )
end
end
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index 2ad0c98dba..4c0d61cf0a 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -27,7 +27,8 @@ describe Bundler::SharedHelpers do
it "raises a GemfileNotFound error" do
expect { subject.default_gemfile }.to raise_error(
- Bundler::GemfileNotFound, "Could not locate Gemfile")
+ Bundler::GemfileNotFound, "Could not locate Gemfile"
+ )
end
end
end
@@ -209,6 +210,10 @@ describe Bundler::SharedHelpers do
end
describe "#set_bundle_environment" do
+ before do
+ ENV["BUNDLE_GEMFILE"] = "Gemfile"
+ end
+
shared_examples_for "ENV['PATH'] gets set correctly" do
before { Dir.mkdir ".bundle" }
@@ -348,7 +353,8 @@ describe Bundler::SharedHelpers do
it "raises a PermissionError" do
expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
- Bundler::PermissionError)
+ Bundler::PermissionError
+ )
end
end
@@ -357,7 +363,8 @@ describe Bundler::SharedHelpers do
it "raises a TemporaryResourceError" do
expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
- Bundler::TemporaryResourceError)
+ Bundler::TemporaryResourceError
+ )
end
end
@@ -366,7 +373,8 @@ describe Bundler::SharedHelpers do
it "raises a VirtualProtocolError" do
expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
- Bundler::VirtualProtocolError)
+ Bundler::VirtualProtocolError
+ )
end
end
@@ -375,7 +383,8 @@ describe Bundler::SharedHelpers do
it "raises a OperationNotSupportedError" do
expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
- Bundler::OperationNotSupportedError)
+ Bundler::OperationNotSupportedError
+ )
end
end
end
diff --git a/spec/bundler/source/git/git_proxy_spec.rb b/spec/bundler/source/git/git_proxy_spec.rb
index 10741b89a7..ce6b79b2b2 100644
--- a/spec/bundler/source/git/git_proxy_spec.rb
+++ b/spec/bundler/source/git/git_proxy_spec.rb
@@ -32,4 +32,86 @@ describe Bundler::Source::Git::GitProxy do
subject.checkout
end
end
+
+ describe "#version" do
+ context "with a normal version number" do
+ before do
+ expect(subject).to receive(:git).with("--version").
+ and_return("git version 1.2.3")
+ end
+
+ it "returns the git version number" do
+ expect(subject.version).to eq("1.2.3")
+ end
+
+ it "does not raise an error when passed into Gem::Version.create" do
+ expect { Gem::Version.create subject.version }.not_to raise_error
+ end
+ end
+
+ context "with a OSX version number" do
+ before do
+ expect(subject).to receive(:git).with("--version").
+ and_return("git version 1.2.3 (Apple Git-BS)")
+ end
+
+ it "strips out OSX specific additions in the version string" do
+ expect(subject.version).to eq("1.2.3")
+ end
+
+ it "does not raise an error when passed into Gem::Version.create" do
+ expect { Gem::Version.create subject.version }.not_to raise_error
+ end
+ end
+
+ context "with a msysgit version number" do
+ before do
+ expect(subject).to receive(:git).with("--version").
+ and_return("git version 1.2.3.msysgit.0")
+ end
+
+ it "strips out msysgit specific additions in the version string" do
+ expect(subject.version).to eq("1.2.3")
+ end
+
+ it "does not raise an error when passed into Gem::Version.create" do
+ expect { Gem::Version.create subject.version }.not_to raise_error
+ end
+ end
+ end
+
+ describe "#full_version" do
+ context "with a normal version number" do
+ before do
+ expect(subject).to receive(:git).with("--version").
+ and_return("git version 1.2.3")
+ end
+
+ it "returns the git version number" do
+ expect(subject.full_version).to eq("1.2.3")
+ end
+ end
+
+ context "with a OSX version number" do
+ before do
+ expect(subject).to receive(:git).with("--version").
+ and_return("git version 1.2.3 (Apple Git-BS)")
+ end
+
+ it "does not strip out OSX specific additions in the version string" do
+ expect(subject.full_version).to eq("1.2.3 (Apple Git-BS)")
+ end
+ end
+
+ context "with a msysgit version number" do
+ before do
+ expect(subject).to receive(:git).with("--version").
+ and_return("git version 1.2.3.msysgit.0")
+ end
+
+ it "does not strip out msysgit specific additions in the version string" do
+ expect(subject.full_version).to eq("1.2.3.msysgit.0")
+ end
+ end
+ end
end
diff --git a/spec/bundler/uri_credentials_filter_spec.rb b/spec/bundler/uri_credentials_filter_spec.rb
index b890c0ce5f..70f71cecac 100644
--- a/spec/bundler/uri_credentials_filter_spec.rb
+++ b/spec/bundler/uri_credentials_filter_spec.rb
@@ -98,7 +98,8 @@ describe Bundler::URICredentialsFilter do
it "returns the string without the sensitive credentials" do
expect(subject.credential_filtered_string(str_to_filter, uri)).to eq(
- "This is a git message containing a uri https://x-oauth-basic@github.com/company/private-repo!")
+ "This is a git message containing a uri https://x-oauth-basic@github.com/company/private-repo!"
+ )
end
end
diff --git a/spec/cache/gems_spec.rb b/spec/cache/gems_spec.rb
index a1bb8751dd..474233a83c 100644
--- a/spec/cache/gems_spec.rb
+++ b/spec/cache/gems_spec.rb
@@ -24,14 +24,14 @@ describe "bundle cache" do
gem "omg"
G
- should_be_installed "omg 1.0.0"
+ expect(the_bundle).to include_gems "omg 1.0.0"
end
it "uses the cache as a source when installing gems with --local" do
system_gems []
bundle "install --local"
- should_be_installed("rack 1.0.0")
+ expect(the_bundle).to include_gems("rack 1.0.0")
end
it "does not reinstall gems from the cache if they exist on the system" do
@@ -43,7 +43,7 @@ describe "bundle cache" do
gem "rack"
G
- should_be_installed("rack 1.0.0")
+ expect(the_bundle).to include_gems("rack 1.0.0")
end
it "does not reinstall gems from the cache if they exist in the bundle" do
@@ -58,7 +58,7 @@ describe "bundle cache" do
end
bundle "install --local"
- should_be_installed("rack 1.0.0")
+ expect(the_bundle).to include_gems("rack 1.0.0")
end
it "creates a lockfile" do
@@ -89,7 +89,7 @@ describe "bundle cache" do
it "uses builtin gems" do
install_gemfile %(gem 'builtin_gem', '1.0.2')
- should_be_installed("builtin_gem 1.0.2")
+ expect(the_bundle).to include_gems("builtin_gem 1.0.2")
end
it "caches remote and builtin gems" do
@@ -115,7 +115,7 @@ describe "bundle cache" do
G
bundle "install --local"
- should_be_installed("builtin_gem_2 1.0.2")
+ expect(the_bundle).to include_gems("builtin_gem_2 1.0.2")
end
it "errors if the builtin gem isn't available to cache" do
@@ -149,7 +149,7 @@ describe "bundle cache" do
system_gems []
bundle "install --local"
- should_be_installed("rack 1.0.0", "foo 1.0")
+ expect(the_bundle).to include_gems("rack 1.0.0", "foo 1.0")
end
it "should not explode if the lockfile is not present" do
@@ -286,7 +286,7 @@ describe "bundle cache" do
gem "foo-bundler"
G
- should_be_installed "foo-bundler 1.0"
+ expect(the_bundle).to include_gems "foo-bundler 1.0"
end
end
end
diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb
index df77e39cb8..c15ee26c25 100644
--- a/spec/cache/git_spec.rb
+++ b/spec/cache/git_spec.rb
@@ -29,7 +29,7 @@ end
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file
FileUtils.rm_rf lib_path("foo-1.0")
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "copies repository to vendor cache and uses it even when installed with bundle --path" do
@@ -47,7 +47,7 @@ end
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
FileUtils.rm_rf lib_path("foo-1.0")
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "runs twice without exploding" do
@@ -62,7 +62,7 @@ end
expect(err).to lack_errors
FileUtils.rm_rf lib_path("foo-1.0")
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "tracks updates" do
@@ -124,22 +124,22 @@ end
end
Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", :expect_err => true
+ sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
`git commit -m "submodulator"`
end
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
git "#{lib_path("has_submodule-1.0")}", :submodules => true do
gem "has_submodule"
end
G
ref = git.ref_for("master", 11)
- bundle "#{cmd} --all", :expect_err => true
+ bundle "#{cmd} --all"
expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}")).to exist
expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}/submodule-1.0")).to exist
- should_be_installed "has_submodule 1.0"
+ expect(the_bundle).to include_gems "has_submodule 1.0"
end
it "displays warning message when detecting git repo in Gemfile" do
diff --git a/spec/cache/path_spec.rb b/spec/cache/path_spec.rb
index b81768102a..4233b3e88b 100644
--- a/spec/cache/path_spec.rb
+++ b/spec/cache/path_spec.rb
@@ -12,7 +12,7 @@ require "spec_helper"
bundle "#{cmd} --all"
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "copies when the path is outside the bundle " do
@@ -27,7 +27,7 @@ require "spec_helper"
expect(bundled_app("vendor/cache/foo-1.0/.bundlecache")).to be_file
FileUtils.rm_rf lib_path("foo-1.0")
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "copies when the path is outside the bundle and the paths intersect" do
@@ -45,7 +45,7 @@ require "spec_helper"
expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file
FileUtils.rm_rf libpath
- should_be_installed "#{libname} 1.0"
+ expect(the_bundle).to include_gems "#{libname} 1.0"
end
it "updates the path on each cache" do
diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb
index c400d7ecae..35c9d187a0 100644
--- a/spec/commands/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
@@ -93,7 +93,7 @@ describe "bundle binstubs <gem>" do
end
it "sets correct permissions for binstubs" do
- with_umask(0002) do
+ with_umask(0o002) do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -244,7 +244,7 @@ describe "bundle binstubs <gem>" do
bundle "config auto_install 1"
bundle "binstubs rack"
expect(out).to include("Installing rack 1.0.0")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "does nothing when already up to date" do
diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index 67d70b511c..72d422c3a2 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -460,7 +460,7 @@ describe "bundle clean" do
describe "when missing permissions" do
after do
- FileUtils.chmod(0755, default_bundle_path("cache"))
+ FileUtils.chmod(0o755, default_bundle_path("cache"))
end
it "returns a helpful error message" do
gemfile <<-G
@@ -479,7 +479,7 @@ describe "bundle clean" do
bundle :install
system_cache_path = default_bundle_path("cache")
- FileUtils.chmod(0500, system_cache_path)
+ FileUtils.chmod(0o500, system_cache_path)
bundle :clean, :force => true
diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb
index ad88af62d9..fce6102c29 100644
--- a/spec/commands/config_spec.rb
+++ b/spec/commands/config_spec.rb
@@ -16,7 +16,7 @@ describe ".bundle/config" do
expect(bundled_app(".bundle")).not_to exist
expect(tmp("foo/bar/config")).to exist
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "can provide a relative path with the environment variable" do
@@ -28,16 +28,7 @@ describe ".bundle/config" do
expect(bundled_app(".bundle")).not_to exist
expect(bundled_app("../foo/config")).to exist
- should_be_installed "rack 1.0.0"
- end
-
- it "removes environment.rb from BUNDLE_APP_CONFIG's path" do
- FileUtils.mkdir_p(tmp("foo/bar"))
- ENV["BUNDLE_APP_CONFIG"] = tmp("foo/bar").to_s
- bundle "install"
- FileUtils.touch tmp("foo/bar/environment.rb")
- should_be_installed "rack 1.0.0"
- expect(tmp("foo/bar/environment.rb")).not_to exist
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
diff --git a/spec/commands/console_spec.rb b/spec/commands/console_spec.rb
index b60ac2c9f6..131b47368b 100644
--- a/spec/commands/console_spec.rb
+++ b/spec/commands/console_spec.rb
@@ -102,6 +102,6 @@ describe "bundle console" do
end
expect(out).to include("Installing foo 1.0")
expect(out).to include("hello")
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
end
diff --git a/spec/commands/doctor_spec.rb b/spec/commands/doctor_spec.rb
new file mode 100644
index 0000000000..236138a6c8
--- /dev/null
+++ b/spec/commands/doctor_spec.rb
@@ -0,0 +1,61 @@
+# frozen_string_literal: true
+require "spec_helper"
+require "stringio"
+require "bundler/cli"
+require "bundler/cli/doctor"
+
+describe "bundle doctor" do
+ before(:each) do
+ @stdout = StringIO.new
+
+ [:error, :warn].each do |method|
+ allow(Bundler.ui).to receive(method).and_wrap_original do |m, message|
+ m.call message
+ @stdout.puts message
+ end
+ end
+ end
+
+ it "exits with no message if the installed gem has no C extensions" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle :install
+ Bundler::CLI::Doctor.new({}).run
+ expect(@stdout.string).to be_empty
+ end
+
+ it "exits with no message if the installed gem's C extension dylib breakage is fine" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle :install
+ doctor = Bundler::CLI::Doctor.new({})
+ expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
+ expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/lib/libSystem.dylib"]
+ allow(File).to receive(:exist?).and_call_original
+ allow(File).to receive(:exist?).with("/usr/lib/libSystem.dylib").and_return(true)
+ doctor.run
+ expect(@stdout.string).to be_empty
+ end
+
+ it "exits with a message if one of the linked libraries is missing" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle :install
+ doctor = Bundler::CLI::Doctor.new({})
+ expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
+ expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib"]
+ allow(File).to receive(:exist?).and_call_original
+ allow(File).to receive(:exist?).with("/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib").and_return(false)
+ expect { doctor.run }.to raise_error SystemExit
+ expect(@stdout.string).to include("libicui18n.57.1.dylib")
+ end
+end
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index cf10521fac..8163fc7725 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -102,7 +102,7 @@ describe "bundle exec" do
f.puts "#!/bin/sh"
f.puts "echo foobar"
end
- File.chmod(0744, "--verbose")
+ File.chmod(0o744, "--verbose")
with_path_as(".") do
bundle "exec -- --verbose"
end
@@ -128,7 +128,7 @@ describe "bundle exec" do
G
end
- bundle! "exec rackup", :expect_err => true
+ bundle! "exec rackup"
expect(out).to eq("0.9.1")
@@ -151,7 +151,7 @@ describe "bundle exec" do
bundle "exec rackup"
expect(out).to eq("0.9.1")
- should_not_be_installed "rack_middleware 1.0"
+ expect(the_bundle).not_to include_gems "rack_middleware 1.0"
end
it "does not duplicate already exec'ed RUBYOPT" do
@@ -232,7 +232,7 @@ describe "bundle exec" do
#!/usr/bin/env ruby
puts "args: #{ARGV.inspect}"
RUBY
- bundled_app("print_args").chmod(0755)
+ bundled_app("print_args").chmod(0o755)
end
it "shows executable's man page when --help is after the executable" do
@@ -320,7 +320,7 @@ describe "bundle exec" do
end
it "works when locked" do
- should_be_locked
+ expect(the_bundle).to be_locked
bundle "exec 'cd #{tmp("gems")} && rackup'"
expect(out).to include("1.0.0")
end
@@ -343,7 +343,7 @@ describe "bundle exec" do
end
it "works when locked" do
- should_be_locked
+ expect(the_bundle).to be_locked
bundle "exec fizz"
expect(out).to eq("1.0")
@@ -367,7 +367,7 @@ describe "bundle exec" do
end
it "works when locked" do
- should_be_locked
+ expect(the_bundle).to be_locked
bundle "exec fizz_git"
expect(out).to eq("1.0")
end
@@ -390,7 +390,7 @@ describe "bundle exec" do
end
it "works when locked" do
- should_be_locked
+ expect(the_bundle).to be_locked
bundle "exec fizz_no_gemspec"
expect(out).to eq("1.0")
end
@@ -425,11 +425,11 @@ describe "bundle exec" do
G
end
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
gem "foo", :path => "#{lib_path("foo-1.0")}"
G
- bundle "exec irb", :expect_err => true
+ bundle "exec irb"
expect(err).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid")
expect(err).to match('"TODO" is not a summary')
@@ -462,11 +462,13 @@ describe "bundle exec" do
puts "EXEC: \#{caller.grep(/load/).empty? ? 'exec' : 'load'}"
puts "ARGS: \#{$0} \#{ARGV.join(' ')}"
puts "RACK: \#{RACK}"
+ process_title = `ps -o args -p \#{Process.pid}`.split("\n", 2).last.strip
+ puts "PROCESS: \#{process_title}"
RUBY
before do
path.open("w") {|f| f << executable }
- path.chmod(0755)
+ path.chmod(0o755)
install_gemfile <<-G
gem "rack"
@@ -476,11 +478,16 @@ describe "bundle exec" do
let(:exec) { "EXEC: load" }
let(:args) { "ARGS: #{path} arg1 arg2" }
let(:rack) { "RACK: 1.0.0" }
+ let(:process) do
+ title = "PROCESS: #{path}"
+ title += " arg1 arg2" if RUBY_VERSION >= "2.1"
+ title
+ end
let(:exit_code) { 0 }
- let(:expected) { [exec, args, rack].join("\n") }
+ let(:expected) { [exec, args, rack, process].join("\n") }
let(:expected_err) { "" }
- subject { bundle "exec #{path} arg1 arg2", :expect_err => true }
+ subject { bundle "exec #{path} arg1 arg2" }
shared_examples_for "it runs" do
it "like a normally executed executable" do
@@ -511,7 +518,7 @@ describe "bundle exec" do
let(:exit_code) { 1 }
let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" }
let(:expected_err) do
- "RuntimeError: ERROR\n #{path}:7" +
+ "RuntimeError: ERROR\n #{path}:10" +
(Bundler.current_ruby.ruby_18? ? "" : ":in `<top (required)>'")
end
it_behaves_like "it runs"
diff --git a/spec/commands/help_spec.rb b/spec/commands/help_spec.rb
index 4e35ba3e6a..d59346f615 100644
--- a/spec/commands/help_spec.rb
+++ b/spec/commands/help_spec.rb
@@ -7,7 +7,7 @@ describe "bundle help" do
it "complains if older versions of bundler are installed", :if => rubygems_under_14 do
system_gems "bundler-0.8.1"
- bundle "help", :expect_err => true
+ bundle "help"
expect(err).to include("older than 0.9")
expect(err).to include("running `gem cleanup bundler`.")
end
@@ -28,7 +28,7 @@ describe "bundle help" do
it "simply outputs the txt file when there is no man on the path" do
with_path_as("") do
- bundle "help install", :expect_err => true
+ bundle "help install"
end
expect(out).to match(/BUNDLE-INSTALL/)
end
@@ -39,7 +39,7 @@ describe "bundle help" do
end
it "looks for a binary and executes it with --help option if it's named bundler-<task>" do
- File.open(tmp("bundler-testtasks"), "w", 0755) do |f|
+ File.open(tmp("bundler-testtasks"), "w", 0o755) do |f|
f.puts "#!/usr/bin/env ruby\nputs ARGV.join(' ')\n"
end
@@ -81,8 +81,20 @@ describe "bundle help" do
it "has helpful output when using --help flag for a non-existent command" do
with_fake_man do
- bundle "instill -h", :expect_err => true
+ bundle "instill -h"
+ end
+ expect(out).to include('Could not find command "instill".')
+ end
+
+ it "is called when only using the --help flag" do
+ with_fake_man do
+ bundle "--help"
+ end
+ expect(out).to eq(%(["#{root}/lib/bundler/man/bundle"]))
+
+ with_fake_man do
+ bundle "-h"
end
- expect(err).to include('Could not find command "instill -h --no-color".')
+ expect(out).to eq(%(["#{root}/lib/bundler/man/bundle"]))
end
end
diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb
index 524071d989..eb78ced86e 100644
--- a/spec/commands/install_spec.rb
+++ b/spec/commands/install_spec.rb
@@ -13,7 +13,7 @@ describe "bundle install with gem sources" do
end
it "does not make a lockfile if the install fails" do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
raise StandardError, "FAIL"
G
@@ -60,7 +60,7 @@ describe "bundle install with gem sources" do
lockfile = File.read(bundled_app("Gemfile.lock"))
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
raise StandardError, "FAIL"
G
@@ -83,7 +83,7 @@ describe "bundle install with gem sources" do
G
expect(default_bundle_path("gems/rack-1.0.0")).to exist
- should_be_installed("rack 1.0.0")
+ expect(the_bundle).to include_gems("rack 1.0.0")
end
it "fetches gems when multiple versions are specified" do
@@ -93,7 +93,7 @@ describe "bundle install with gem sources" do
G
expect(default_bundle_path("gems/rack-0.9.1")).to exist
- should_be_installed("rack 0.9.1")
+ expect(the_bundle).to include_gems("rack 0.9.1")
end
it "fetches gems when multiple versions are specified take 2" do
@@ -103,7 +103,7 @@ describe "bundle install with gem sources" do
G
expect(default_bundle_path("gems/rack-0.9.1")).to exist
- should_be_installed("rack 0.9.1")
+ expect(the_bundle).to include_gems("rack 0.9.1")
end
it "raises an appropriate error when gems are specified using symbols" do
@@ -120,7 +120,7 @@ describe "bundle install with gem sources" do
gem "rails"
G
- should_be_installed "actionpack 2.3.2", "rails 2.3.2"
+ expect(the_bundle).to include_gems "actionpack 2.3.2", "rails 2.3.2"
end
it "does the right version" do
@@ -129,7 +129,7 @@ describe "bundle install with gem sources" do
gem "rack", "0.9.1"
G
- should_be_installed "rack 0.9.1"
+ expect(the_bundle).to include_gems "rack 0.9.1"
end
it "does not install the development dependency" do
@@ -138,8 +138,8 @@ describe "bundle install with gem sources" do
gem "with_development_dependency"
G
- should_be_installed "with_development_dependency 1.0.0"
- should_not_be_installed "activesupport 2.3.5"
+ expect(the_bundle).to include_gems("with_development_dependency 1.0.0").
+ and not_include_gems("activesupport 2.3.5")
end
it "resolves correctly" do
@@ -149,7 +149,7 @@ describe "bundle install with gem sources" do
gem "rails"
G
- should_be_installed "activemerchant 1.0", "activesupport 2.3.2", "actionpack 2.3.2"
+ expect(the_bundle).to include_gems "activemerchant 1.0", "activesupport 2.3.2", "actionpack 2.3.2"
end
it "activates gem correctly according to the resolved gems" do
@@ -164,7 +164,7 @@ describe "bundle install with gem sources" do
gem "rails"
G
- should_be_installed "activemerchant 1.0", "activesupport 2.3.2", "actionpack 2.3.2"
+ expect(the_bundle).to include_gems "activemerchant 1.0", "activesupport 2.3.2", "actionpack 2.3.2"
end
it "does not reinstall any gem that is already available locally" do
@@ -181,7 +181,7 @@ describe "bundle install with gem sources" do
gem "activerecord", "2.3.2"
G
- should_be_installed "activesupport 2.3.2"
+ expect(the_bundle).to include_gems "activesupport 2.3.2"
end
it "works when the gemfile specifies gems that only exist in the system" do
@@ -192,7 +192,7 @@ describe "bundle install with gem sources" do
gem "foo"
G
- should_be_installed "rack 1.0.0", "foo 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0", "foo 1.0.0"
end
it "prioritizes local gems over remote gems" do
@@ -205,7 +205,7 @@ describe "bundle install with gem sources" do
gem "rack"
G
- should_be_installed "rack 1.0.0", "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
end
describe "with a gem that installs multiple platforms" do
@@ -264,21 +264,21 @@ describe "bundle install with gem sources" do
it "works" do
bundle "install --path vendor"
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "allows running bundle install --system without deleting foo" do
bundle "install --path vendor"
bundle "install --system"
FileUtils.rm_rf(bundled_app("vendor"))
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "allows running bundle install --system after deleting foo" do
bundle "install --path vendor"
FileUtils.rm_rf(bundled_app("vendor"))
bundle "install --system"
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
@@ -294,7 +294,7 @@ describe "bundle install with gem sources" do
gem "rack", "1.2"
G
- should_be_installed "rack 1.2", "activesupport 1.2.3"
+ expect(the_bundle).to include_gems "rack 1.2", "activesupport 1.2.3"
end
it "gives a useful error if no sources are set" do
@@ -302,7 +302,7 @@ describe "bundle install with gem sources" do
gem "rack"
G
- bundle :install, :expect_err => true
+ bundle :install
expect(out).to include("Your Gemfile has no gem server sources")
end
@@ -356,7 +356,7 @@ describe "bundle install with gem sources" do
context "and using an unsupported Ruby version" do
it "prints an error" do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
::RUBY_VERSION = '1.8.7'
ruby '~> 2.1'
G
@@ -366,7 +366,7 @@ describe "bundle install with gem sources" do
context "and using a supported Ruby version" do
before do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
::RUBY_VERSION = '2.1.3'
::RUBY_PATCHLEVEL = 100
ruby '~> 2.1.0'
@@ -392,7 +392,7 @@ describe "bundle install with gem sources" do
end
it "updates Gemfile.lock with updated incompatible ruby version" do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
::RUBY_VERSION = '2.2.3'
::RUBY_PATCHLEVEL = 100
ruby '~> 2.2.0'
@@ -462,7 +462,7 @@ describe "bundle install with gem sources" do
end
it "should display a proper message to explain the problem" do
- FileUtils.chmod(0500, bundled_app("vendor"))
+ FileUtils.chmod(0o500, bundled_app("vendor"))
bundle :install, :path => "vendor"
expect(out).to include(bundled_app("vendor").to_s)
@@ -498,5 +498,12 @@ describe "bundle install with gem sources" do
bundle :install, :env => { "BUNDLE_POSTIT_TRAMPOLINING_VERSION" => "999" }
expect(out).not_to include("You're running Bundler 999 but this project uses #{Bundler::VERSION}.")
end
+
+ it "should not print warning if versions match" do
+ bundle :init
+ bundle :install, :env => { "BUNDLE_POSTIT_TRAMPOLINING_VERSION" => Bundler::VERSION }
+ expect(out).to start_with("Running `bundle install --no-color` with bundler #{Bundler::VERSION}\nThe Gemfile specifies no dependencies")
+ expect(out).not_to include("You're running Bundler #{Bundler::VERSION} but this project uses #{Bundler::VERSION}.")
+ end
end
end
diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb
index 9c722b3491..a72b94a0b9 100644
--- a/spec/commands/package_spec.rb
+++ b/spec/commands/package_spec.rb
@@ -12,7 +12,7 @@ describe "bundle package" do
bundle "package --gemfile=NotGemfile"
ENV["BUNDLE_GEMFILE"] = "NotGemfile"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -127,7 +127,7 @@ describe "bundle package" do
source "file://#{gem_repo1}"
gem 'rack'
gemspec :name => 'mygem'
- gemspec :name => 'mygem_client'
+ gemspec :name => 'mygem_test'
D
bundle! "package --all"
@@ -151,7 +151,7 @@ describe "bundle package" do
bundle "package --path=#{bundled_app("test")}"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
expect(bundled_app("test/vendor/cache/")).to exist
end
end
@@ -165,7 +165,7 @@ describe "bundle package" do
bundle "package --no-install"
- should_not_be_installed "rack 1.0.0", :expect_err => true
+ expect(the_bundle).not_to include_gems "rack 1.0.0"
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
end
@@ -178,7 +178,7 @@ describe "bundle package" do
bundle "package --no-install"
bundle "install"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -236,7 +236,7 @@ describe "bundle install with gem sources" do
FileUtils.rm_rf gem_repo2
bundle "install --local"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "does not hit the remote at all" do
@@ -251,7 +251,7 @@ describe "bundle install with gem sources" do
FileUtils.rm_rf gem_repo2
bundle "install --deployment"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "does not reinstall already-installed gems" do
@@ -267,7 +267,7 @@ describe "bundle install with gem sources" do
bundle :install
expect(err).to lack_errors
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "ignores cached gems for the wrong platform" do
diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb
index b4f9c90c95..84352c5427 100644
--- a/spec/commands/show_spec.rb
+++ b/spec/commands/show_spec.rb
@@ -80,7 +80,7 @@ describe "bundle show" do
install_gemfile <<-G
gem "foo", :git => "#{lib_path("foo-1.0")}"
G
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
bundle :show
expect(out).to include("foo (1.0 #{@git.ref_for("master", 6)}")
@@ -95,7 +95,7 @@ describe "bundle show" do
install_gemfile <<-G
gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
G
- should_be_installed "foo 1.0.omg"
+ expect(the_bundle).to include_gems "foo 1.0.omg"
bundle :show
expect(out).to include("foo (1.0 #{@git.ref_for("omg", 6)}")
@@ -116,7 +116,7 @@ describe "bundle show" do
install_gemfile <<-G
gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}"
G
- should_be_installed "foo 1.0.0.pre.beta.1"
+ expect(the_bundle).to include_gems "foo 1.0.0.pre.beta.1"
bundle! :show
expect(out).to include("foo (1.0.0.pre.beta.1")
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index d86db69e8d..19fbb8388c 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -20,7 +20,7 @@ describe "bundle update" do
bundle "update"
expect(out).to include("Bundle updated!")
- should_be_installed "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
+ expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
it "doesn't delete the Gemfile.lock file if something goes wrong" do
@@ -49,17 +49,17 @@ describe "bundle update" do
end
bundle "update rack-obama"
- should_be_installed "rack 1.2", "rack-obama 1.0", "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 2.3.5"
end
end
describe "with an unknown dependency" do
it "should inform the user" do
- bundle "update halting-problem-solver", :expect_err => true
+ bundle "update halting-problem-solver"
expect(out).to include "Could not find gem 'halting-problem-solver'"
end
it "should suggest alternatives" do
- bundle "update active-support", :expect_err => true
+ bundle "update active-support"
expect(out).to include "Did you mean activesupport?"
end
end
@@ -68,7 +68,7 @@ describe "bundle update" do
it "should update the child dependency" do
update_repo2
bundle "update rack"
- should_be_installed "rack 1.2"
+ expect(the_bundle).to include_gems "rack 1.2"
end
end
@@ -92,8 +92,8 @@ describe "bundle update" do
build_gem "activesupport", "3.0"
end
bundle "update --group development"
- should_be_installed "activesupport 3.0"
- should_not_be_installed "rack 1.2"
+ expect(the_bundle).to include_gems "activesupport 3.0"
+ expect(the_bundle).not_to include_gems "rack 1.2"
end
context "when there is a source with the same name as a gem in a group" do
@@ -111,8 +111,8 @@ describe "bundle update" do
update_git "foo", "2.0", :path => lib_path("activesupport")
bundle "update --group development"
- should_be_installed "activesupport 3.0"
- should_not_be_installed "foo 2.0"
+ expect(the_bundle).to include_gems "activesupport 3.0"
+ expect(the_bundle).not_to include_gems "foo 2.0"
end
end
end
@@ -138,7 +138,7 @@ describe "bundle update" do
update_repo2 { build_gem "activesupport", "3.0" }
bundle "update --source activesupport"
- should_not_be_installed "activesupport 3.0"
+ expect(the_bundle).not_to include_gems "activesupport 3.0"
end
it "should update gems not included in the source that happen to have the same name" do
@@ -149,7 +149,7 @@ describe "bundle update" do
update_repo2 { build_gem "activesupport", "3.0" }
bundle "update --source activesupport"
- should_be_installed "activesupport 3.0"
+ expect(the_bundle).to include_gems "activesupport 3.0"
end
end
@@ -178,8 +178,8 @@ describe "bundle update" do
end
bundle "update --source harry"
- should_be_installed "harry 2.0"
- should_be_installed "fred 1.0"
+ expect(the_bundle).to include_gems "harry 2.0"
+ expect(the_bundle).to include_gems "fred 1.0"
end
end
@@ -211,9 +211,9 @@ describe "bundle update" do
end
bundle "update --source harry"
- should_be_installed "harry 2.0"
- should_be_installed "fred 1.0"
- should_be_installed "george 1.0"
+ expect(the_bundle).to include_gems "harry 2.0"
+ expect(the_bundle).to include_gems "fred 1.0"
+ expect(the_bundle).to include_gems "george 1.0"
end
end
end
@@ -238,7 +238,7 @@ describe "bundle update in more complicated situations" do
end
bundle "update thin"
- should_be_installed "thin 2.0", "rack 1.2", "rack-obama 1.0"
+ expect(the_bundle).to include_gems "thin 2.0", "rack 1.2", "rack-obama 1.0"
end
it "will update only from pinned source" do
@@ -255,7 +255,7 @@ describe "bundle update in more complicated situations" do
end
bundle "update"
- should_be_installed "thin 1.0"
+ expect(the_bundle).to include_gems "thin 1.0"
end
end
@@ -271,7 +271,7 @@ describe "bundle update without a Gemfile.lock" do
bundle "update"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -336,23 +336,23 @@ end
describe "bundle update --ruby" do
before do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
::RUBY_VERSION = '2.1.3'
::RUBY_PATCHLEVEL = 100
ruby '~> 2.1.0'
G
- bundle "update --ruby", :expect_err => true
+ bundle "update --ruby"
end
context "when the Gemfile removes the ruby" do
before do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
::RUBY_VERSION = '2.1.4'
::RUBY_PATCHLEVEL = 222
G
end
it "removes the Ruby from the Gemfile.lock" do
- bundle "update --ruby", :expect_err => true
+ bundle "update --ruby"
lockfile_should_be <<-L
GEM
@@ -371,14 +371,14 @@ describe "bundle update --ruby" do
context "when the Gemfile specified an updated Ruby version" do
before do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
::RUBY_VERSION = '2.1.4'
::RUBY_PATCHLEVEL = 222
ruby '~> 2.1.0'
G
end
it "updates the Gemfile.lock with the latest version" do
- bundle "update --ruby", :expect_err => true
+ bundle "update --ruby"
lockfile_should_be <<-L
GEM
@@ -400,14 +400,14 @@ describe "bundle update --ruby" do
context "when a different Ruby is being used than has been versioned" do
before do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
::RUBY_VERSION = '2.2.2'
::RUBY_PATCHLEVEL = 505
ruby '~> 2.1.0'
G
end
it "shows a helpful error message" do
- bundle "update --ruby", :expect_err => true
+ bundle "update --ruby"
expect(out).to include("Your Ruby version is 2.2.2, but your Gemfile specified ~> 2.1.0")
end
@@ -415,14 +415,14 @@ describe "bundle update --ruby" do
context "when updating Ruby version and Gemfile `ruby`" do
before do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
::RUBY_VERSION = '1.8.3'
::RUBY_PATCHLEVEL = 55
ruby '~> 1.8.0'
G
end
it "updates the Gemfile.lock with the latest version" do
- bundle "update --ruby", :expect_err => true
+ bundle "update --ruby"
lockfile_should_be <<-L
GEM
@@ -481,13 +481,13 @@ describe "bundle update conservative" do
it "single gem updates dependent gem to minor" do
bundle "update --patch foo"
- should_be_installed "foo 1.4.5", "bar 2.1.1", "qux 1.0.0"
+ expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.0"
end
it "update all" do
bundle "update --patch"
- should_be_installed "foo 1.4.5", "bar 2.1.1", "qux 1.0.1"
+ expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.1"
end
it "warns on minor or major increment elsewhere" ## include in prior test
@@ -497,7 +497,7 @@ describe "bundle update conservative" do
it "single gem updates dependent gem to major" do
bundle "update --minor foo"
- should_be_installed "foo 1.5.1", "bar 3.0.0", "qux 1.0.0"
+ expect(the_bundle).to include_gems "foo 1.5.1", "bar 3.0.0", "qux 1.0.0"
end
it "warns on major increment elsewhere" ## include in prior test
@@ -509,13 +509,13 @@ describe "bundle update conservative" do
it "patch preferred" do
bundle "update --patch foo bar --strict"
- should_be_installed "foo 1.4.4", "bar 2.0.5", "qux 1.0.0"
+ expect(the_bundle).to include_gems "foo 1.4.4", "bar 2.0.5", "qux 1.0.0"
end
it "minor preferred" do
bundle "update --minor --strict"
- should_be_installed "foo 1.5.0", "bar 2.1.1", "qux 1.1.0"
+ expect(the_bundle).to include_gems "foo 1.5.0", "bar 2.1.1", "qux 1.1.0"
end
end
diff --git a/spec/commands/viz_spec.rb b/spec/commands/viz_spec.rb
index ee5736c61d..f3fab9272c 100644
--- a/spec/commands/viz_spec.rb
+++ b/spec/commands/viz_spec.rb
@@ -7,6 +7,10 @@ describe "bundle viz", :ruby => "1.9.3", :if => Bundler.which("dot") do
Dir[graphviz_glob].first
end
+ before do
+ ENV["RUBYOPT"] = "-I #{graphviz_lib}"
+ end
+
it "graphs gems from the Gemfile" do
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -14,8 +18,27 @@ describe "bundle viz", :ruby => "1.9.3", :if => Bundler.which("dot") do
gem "rack-obama"
G
- bundle "viz", :env => { "RUBYOPT" => "-I #{graphviz_lib}" }
+ bundle! "viz"
expect(out).to include("gem_graph.png")
+
+ bundle! "viz", :format => "debug"
+ expect(out).to eq(strip_whitespace(<<-DOT).strip)
+ digraph Gemfile {
+ concentrate = "true";
+ normalize = "true";
+ nodesep = "0.55";
+ edge[ weight = "2"];
+ node[ fontname = "Arial, Helvetica, SansSerif"];
+ edge[ fontname = "Arial, Helvetica, SansSerif" , fontsize = "12"];
+ default [style = "filled", fillcolor = "#B9B9D5", shape = "box3d", fontsize = "16", label = "default"];
+ rack [style = "filled", fillcolor = "#B9B9D5", label = "rack"];
+ default -> rack [constraint = "false"];
+ "rack-obama" [style = "filled", fillcolor = "#B9B9D5", label = "rack-obama"];
+ default -> "rack-obama" [constraint = "false"];
+ "rack-obama" -> rack;
+ }
+ debugging bundle viz...
+ DOT
end
it "graphs gems that are prereleases" do
@@ -29,8 +52,27 @@ describe "bundle viz", :ruby => "1.9.3", :if => Bundler.which("dot") do
gem "rack-obama"
G
- bundle "viz", :env => { "RUBYOPT" => "-I #{graphviz_lib}" }
+ bundle! "viz"
expect(out).to include("gem_graph.png")
+
+ bundle! "viz", :format => :debug, :version => true
+ expect(out).to eq(strip_whitespace(<<-EOS).strip)
+ digraph Gemfile {
+ concentrate = "true";
+ normalize = "true";
+ nodesep = "0.55";
+ edge[ weight = "2"];
+ node[ fontname = "Arial, Helvetica, SansSerif"];
+ edge[ fontname = "Arial, Helvetica, SansSerif" , fontsize = "12"];
+ default [style = "filled", fillcolor = "#B9B9D5", shape = "box3d", fontsize = "16", label = "default"];
+ rack [style = "filled", fillcolor = "#B9B9D5", label = "rack\\n1.3.pre"];
+ default -> rack [constraint = "false"];
+ "rack-obama" [style = "filled", fillcolor = "#B9B9D5", label = "rack-obama\\n1.0"];
+ default -> "rack-obama" [constraint = "false"];
+ "rack-obama" -> rack;
+ }
+ debugging bundle viz...
+ EOS
end
context "--without option" do
@@ -44,7 +86,7 @@ describe "bundle viz", :ruby => "1.9.3", :if => Bundler.which("dot") do
end
G
- bundle "viz --without=rails", :env => { "RUBYOPT" => "-I #{graphviz_lib}" }
+ bundle! "viz --without=rails"
expect(out).to include("gem_graph.png")
end
@@ -62,7 +104,7 @@ describe "bundle viz", :ruby => "1.9.3", :if => Bundler.which("dot") do
end
G
- bundle "viz --without=rails:rack", :env => { "RUBYOPT" => "-I #{graphviz_lib}" }
+ bundle! "viz --without=rails:rack"
expect(out).to include("gem_graph.png")
end
end
diff --git a/spec/install/allow_offline_install_spec.rb b/spec/install/allow_offline_install_spec.rb
new file mode 100644
index 0000000000..44100ca97b
--- /dev/null
+++ b/spec/install/allow_offline_install_spec.rb
@@ -0,0 +1,92 @@
+# frozen_string_literal: true
+require "spec_helper"
+
+describe "bundle install with :allow_offline_install" do
+ before do
+ bundle "config allow_offline_install true"
+ end
+
+ context "with no cached data locally" do
+ it "still installs" do
+ install_gemfile! <<-G, :artifice => "compact_index"
+ source "http://testgemserver.local"
+ gem "rack-obama"
+ G
+ expect(the_bundle).to include_gem("rack 1.0")
+ end
+
+ it "still fails when the network is down" do
+ install_gemfile <<-G, :artifice => "fail"
+ source "http://testgemserver.local"
+ gem "rack-obama"
+ G
+ expect(out).to include("Could not reach host testgemserver.local.")
+ expect(the_bundle).to_not be_locked
+ end
+ end
+
+ context "with cached data locally" do
+ it "will install from the compact index" do
+ system_gems ["rack-1.0.0"]
+
+ install_gemfile! <<-G, :artifice => "compact_index"
+ source "http://testgemserver.local"
+ gem "rack-obama"
+ gem "rack", "< 1.0"
+ G
+
+ expect(the_bundle).to include_gems("rack-obama 1.0", "rack 0.9.1")
+
+ gemfile <<-G
+ source "http://testgemserver.local"
+ gem "rack-obama"
+ G
+
+ bundle! :update, :artifice => "fail"
+ expect(out).to include("Using the cached data for the new index because of a network error")
+
+ expect(the_bundle).to include_gems("rack-obama 1.0", "rack 1.0.0")
+ end
+
+ def break_git_remote_ops!
+ FileUtils.mkdir_p(tmp("broken_path"))
+ File.open(tmp("broken_path/git"), "w", 0o755) do |f|
+ f.puts strip_whitespace(<<-RUBY)
+ #!/usr/bin/env ruby
+ if %w(fetch --force --quiet --tags refs/heads/*:refs/heads/*).-(ARGV).empty? || %w(clone --bare --no-hardlinks --quiet).-(ARGV).empty?
+ warn "git remote ops have been disabled"
+ exit 1
+ end
+ ENV["PATH"] = ENV["PATH"].sub(/^.*?:/, "")
+ exec("git", *ARGV)
+ RUBY
+ end
+
+ old_path = ENV["PATH"]
+ ENV["PATH"] = "#{tmp("broken_path")}:#{ENV["PATH"]}"
+ yield if block_given?
+ ensure
+ ENV["PATH"] = old_path if block_given?
+ end
+
+ it "will install from a cached git repo" do
+ git = build_git "a", "1.0.0", :path => lib_path("a")
+ update_git("a", :path => git.path, :branch => "new_branch")
+ install_gemfile! <<-G
+ gem "a", :git => #{git.path.to_s.dump}
+ G
+
+ break_git_remote_ops! { bundle! :update }
+ expect(out).to include("Using cached git data because of network errors")
+ expect(the_bundle).to be_locked
+
+ break_git_remote_ops! do
+ install_gemfile! <<-G
+ gem "a", :git => #{git.path.to_s.dump}, :branch => "new_branch"
+ G
+ end
+ expect(out).to include("Using cached git data because of network errors")
+ expect(the_bundle).to be_locked
+ end
+ end
+end
diff --git a/spec/install/binstubs_spec.rb b/spec/install/binstubs_spec.rb
index fed43693c9..a7e0b847cc 100644
--- a/spec/install/binstubs_spec.rb
+++ b/spec/install/binstubs_spec.rb
@@ -16,7 +16,7 @@ describe "bundle install" do
config "BUNDLE_SYSTEM_BINDIR" => system_gem_path("altbin").to_s
bundle :install
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
expect(system_gem_path("altbin/rackup")).to exist
end
end
diff --git a/spec/install/bundler_spec.rb b/spec/install/bundler_spec.rb
index 901c68d2a8..9f06a48086 100644
--- a/spec/install/bundler_spec.rb
+++ b/spec/install/bundler_spec.rb
@@ -19,7 +19,7 @@ describe "bundle install" do
gem "rails", "3.0"
G
- should_be_installed "bundler #{Bundler::VERSION}"
+ expect(the_bundle).to include_gems "bundler #{Bundler::VERSION}"
end
it "are not added if not already present" do
@@ -27,7 +27,7 @@ describe "bundle install" do
source "file://#{gem_repo1}"
gem "rack"
G
- should_not_be_installed "bundler #{Bundler::VERSION}"
+ expect(the_bundle).not_to include_gems "bundler #{Bundler::VERSION}"
end
it "causes a conflict if explicitly requesting a different version" do
@@ -71,7 +71,7 @@ describe "bundle install" do
gem "rack"
G
- should_be_installed "multiple_versioned_deps 1.0.0"
+ expect(the_bundle).to include_gems "multiple_versioned_deps 1.0.0"
end
it "includes bundler in the bundle when it's a child dependency" do
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index 2156ad8786..c73cff5e80 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -38,7 +38,7 @@ describe "install with --deployment or --frozen" do
bundle "install --deployment"
bundle :install
expect(exitstatus).to eq(0) if exitstatus
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "still works if you are not in the app directory and specify --gemfile" do
@@ -47,7 +47,7 @@ describe "install with --deployment or --frozen" do
simulate_new_machine
bundle "install --gemfile #{tmp}/bundled_app/Gemfile --deployment"
Dir.chdir bundled_app
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "works if you exclude a group with a git gem" do
@@ -105,7 +105,7 @@ describe "install with --deployment or --frozen" do
bundle "install --deployment"
expect(exitstatus).to eq(0) if exitstatus
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
describe "with an existing lockfile" do
@@ -260,7 +260,7 @@ describe "install with --deployment or --frozen" do
gem "rack-obama"
G
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -272,7 +272,7 @@ describe "install with --deployment or --frozen" do
G
bundle :install
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
bundle "package --all"
expect(bundled_app("vendor/cache/foo")).to be_directory
@@ -288,7 +288,7 @@ describe "install with --deployment or --frozen" do
expect(out).not_to include("You have deleted from the Gemfile")
expect(out).to include("Using foo 1.0 from source at")
expect(out).to include("vendor/cache/foo")
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
end
end
diff --git a/spec/install/force_spec.rb b/spec/install/force_spec.rb
index 9209392d58..2027660cba 100644
--- a/spec/install/force_spec.rb
+++ b/spec/install/force_spec.rb
@@ -21,7 +21,7 @@ describe "bundle install" do
expect(out).to include "Using bundler"
expect(out).to include "Installing rack 1.0.0"
expect(rack_lib.open(&:read)).to eq("RACK = '1.0.0'\n")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "works on first bundle install" do
@@ -30,7 +30,7 @@ describe "bundle install" do
expect(exitstatus).to eq(0) if exitstatus
expect(out).to include "Using bundler"
expect(out).to include "Installing rack 1.0.0"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
end
diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb
index f860f55f13..9a6bd5f1e8 100644
--- a/spec/install/gemfile/gemspec_spec.rb
+++ b/spec/install/gemfile/gemspec_spec.rb
@@ -18,8 +18,8 @@ describe "bundle install from an existing gemspec" do
gemspec :path => '#{tmp.join("foo")}'
G
- should_be_installed "bar 1.0.0"
- should_be_installed "bar-dev 1.0.0", :groups => :development
+ expect(the_bundle).to include_gems "bar 1.0.0"
+ expect(the_bundle).to include_gems "bar-dev 1.0.0", :groups => :development
end
it "that is hidden should install runtime and development dependencies" do
@@ -35,8 +35,8 @@ describe "bundle install from an existing gemspec" do
gemspec :path => '#{tmp.join("foo")}'
G
- should_be_installed "bar 1.0.0"
- should_be_installed "bar-dev 1.0.0", :groups => :development
+ expect(the_bundle).to include_gems "bar 1.0.0"
+ expect(the_bundle).to include_gems "bar-dev 1.0.0", :groups => :development
end
it "should handle a list of requirements" do
@@ -52,13 +52,13 @@ describe "bundle install from an existing gemspec" do
gemspec :path => '#{tmp.join("foo")}'
G
- should_be_installed "baz 1.0"
+ expect(the_bundle).to include_gems "baz 1.0"
end
it "should raise if there are no gemspecs available" do
build_lib("foo", :path => tmp.join("foo"), :gemspec => false)
- error = install_gemfile(<<-G, :expect_err => true)
+ error = install_gemfile(<<-G)
source "file://#{gem_repo2}"
gemspec :path => '#{tmp.join("foo")}'
G
@@ -67,10 +67,10 @@ describe "bundle install from an existing gemspec" do
it "should raise if there are too many gemspecs available" do
build_lib("foo", :path => tmp.join("foo")) do |s|
- s.write("foo2.gemspec", "")
+ s.write("foo2.gemspec", build_spec("foo", "4.0").first.to_ruby)
end
- error = install_gemfile(<<-G, :expect_err => true)
+ error = install_gemfile(<<-G)
source "file://#{gem_repo2}"
gemspec :path => '#{tmp.join("foo")}'
G
@@ -84,13 +84,13 @@ describe "bundle install from an existing gemspec" do
s.add_development_dependency "bar-dev", "=1.0.0"
end
- install_gemfile(<<-G, :expect_err => true)
+ install_gemfile(<<-G)
source "file://#{gem_repo2}"
gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
G
- should_be_installed "bar 1.0.0"
- should_be_installed "bar-dev 1.0.0", :groups => :development
+ expect(the_bundle).to include_gems "bar 1.0.0"
+ expect(the_bundle).to include_gems "bar-dev 1.0.0", :groups => :development
end
it "should use a specific group for development dependencies" do
@@ -100,14 +100,14 @@ describe "bundle install from an existing gemspec" do
s.add_development_dependency "bar-dev", "=1.0.0"
end
- install_gemfile(<<-G, :expect_err => true)
+ install_gemfile(<<-G)
source "file://#{gem_repo2}"
gemspec :path => '#{tmp.join("foo")}', :name => 'foo', :development_group => :dev
G
- should_be_installed "bar 1.0.0"
- should_not_be_installed "bar-dev 1.0.0", :groups => :development
- should_be_installed "bar-dev 1.0.0", :groups => :dev
+ expect(the_bundle).to include_gems "bar 1.0.0"
+ expect(the_bundle).not_to include_gems "bar-dev 1.0.0", :groups => :development
+ expect(the_bundle).to include_gems "bar-dev 1.0.0", :groups => :dev
end
it "should match a lockfile even if the gemspec defines development dependencies" do
@@ -137,7 +137,7 @@ describe "bundle install from an existing gemspec" do
s.write "raise 'ahh' unless Dir.pwd == '#{tmp.join("foo")}'"
end
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
gemspec :path => '#{tmp.join("foo")}'
G
expect(@err).not_to match(/ahh/)
@@ -159,7 +159,7 @@ describe "bundle install from an existing gemspec" do
gemspec :path => '#{tmp.join("foo")}', :name => 'foo'
G
- should_be_installed "foo 1.0.0"
+ expect(the_bundle).to include_gems "foo 1.0.0"
end
context "when child gemspecs conflict with a released gemspec" do
@@ -182,7 +182,7 @@ describe "bundle install from an existing gemspec" do
gemspec
G
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
@@ -196,7 +196,17 @@ describe "bundle install from an existing gemspec" do
before do
build_lib("foo", :path => tmp.join("foo")) do |s|
s.add_dependency "rack", "=1.0.0"
- s.platform = platform if explicit_platform
+ end
+
+ if explicit_platform
+ create_file(
+ tmp.join("foo", "foo-#{platform}.gemspec"),
+ build_spec("foo", "1.0", platform) do
+ dep "rack", "=1.0.0"
+ @spec.authors = "authors"
+ @spec.summary = "summary"
+ end.first.to_ruby
+ )
end
gemfile <<-G
@@ -236,7 +246,7 @@ describe "bundle install from an existing gemspec" do
simulate_platform "java" do
results = bundle "install", :artifice => "endpoint"
expect(results).to include("Installing rack 1.0.0")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
end
@@ -250,7 +260,7 @@ describe "bundle install from an existing gemspec" do
simulate_platform "java" do
results = bundle "install", :artifice => "endpoint"
expect(results).to include("Installing rack 1.0.0")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
end
@@ -261,7 +271,139 @@ describe "bundle install from an existing gemspec" do
simulate_windows do
results = bundle "install", :artifice => "endpoint"
expect(results).to include("Installing rack 1.0.0")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+ end
+ end
+ end
+
+ context "bundled for ruby and jruby" do
+ let(:platform_specific_type) { :runtime }
+ let(:dependency) { "platform_specific" }
+ before do
+ build_repo2 do
+ build_gem "indirect_platform_specific" do |s|
+ s.add_runtime_dependency "platform_specific"
+ end
+ end
+
+ build_lib "foo", :path => "." do |s|
+ if platform_specific_type == :runtime
+ s.add_runtime_dependency dependency
+ elsif platform_specific_type == :development
+ s.add_development_dependency dependency
+ else
+ raise "wrong dependency type #{platform_specific_type}, can only be :development or :runtime"
+ end
+ end
+
+ %w(ruby jruby).each do |platform|
+ simulate_platform(platform) do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gemspec
+ G
+ end
+ end
+ end
+
+ context "on ruby" do
+ before do
+ simulate_platform("ruby")
+ bundle :install
+ end
+
+ context "as a runtime dependency" do
+ it "keeps java dependencies in the lockfile" do
+ expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
+ expect(lockfile).to eq strip_whitespace(<<-L)
+ PATH
+ remote: .
+ specs:
+ foo (1.0)
+ platform_specific
+
+ GEM
+ remote: file:#{gem_repo2}/
+ specs:
+ platform_specific (1.0)
+ platform_specific (1.0-java)
+
+ PLATFORMS
+ java
+ ruby
+
+ DEPENDENCIES
+ foo!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+ end
+
+ context "as a development dependency" do
+ let(:platform_specific_type) { :development }
+
+ it "keeps java dependencies in the lockfile" do
+ expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
+ expect(lockfile).to eq strip_whitespace(<<-L)
+ PATH
+ remote: .
+ specs:
+ foo (1.0)
+
+ GEM
+ remote: file:#{gem_repo2}/
+ specs:
+ platform_specific (1.0)
+ platform_specific (1.0-java)
+
+ PLATFORMS
+ java
+ ruby
+
+ DEPENDENCIES
+ foo!
+ platform_specific
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+ end
+
+ context "with an indirect platform-specific development dependency" do
+ let(:platform_specific_type) { :development }
+ let(:dependency) { "indirect_platform_specific" }
+
+ it "keeps java dependencies in the lockfile" do
+ expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY"
+ expect(lockfile).to eq strip_whitespace(<<-L)
+ PATH
+ remote: .
+ specs:
+ foo (1.0)
+
+ GEM
+ remote: file:#{gem_repo2}/
+ specs:
+ indirect_platform_specific (1.0)
+ platform_specific
+ platform_specific (1.0)
+ platform_specific (1.0-java)
+
+ PLATFORMS
+ java
+ ruby
+
+ DEPENDENCIES
+ foo!
+ indirect_platform_specific
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
end
end
end
diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb
index 4f24a0b162..bc9cc20870 100644
--- a/spec/install/gemfile/git_spec.rb
+++ b/spec/install/gemfile/git_spec.rb
@@ -17,7 +17,7 @@ describe "bundle install with git sources" do
end
it "fetches gems" do
- should_be_installed("foo 1.0")
+ expect(the_bundle).to include_gems("foo 1.0")
run <<-RUBY
require 'foo'
@@ -70,7 +70,6 @@ describe "bundle install with git sources" do
end
it "sets up git gem executables on the path" do
- pending_jruby_shebang_fix
bundle "exec foobar"
expect(out).to eq("1.0")
end
@@ -127,7 +126,7 @@ describe "bundle install with git sources" do
FileUtils.mv bundled_app, tmp("bundled_app.bck")
Dir.chdir tmp("bundled_app.bck")
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "can still install after moving the application directory" do
@@ -148,7 +147,7 @@ describe "bundle install with git sources" do
bundle "update foo"
- should_be_installed "foo 1.1", "rack 1.0"
+ expect(the_bundle).to include_gems "foo 1.1", "rack 1.0"
end
end
@@ -167,7 +166,7 @@ describe "bundle install with git sources" do
it "does not explode" do
bundle "install"
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
@@ -251,6 +250,27 @@ describe "bundle install with git sources" do
expect(out).to eq("LOCAL")
end
+ it "unlocks the source when the dependencies have changed while switching to the local" do
+ build_git "rack", "0.8"
+
+ FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
+
+ update_git "rack", "0.8", :path => lib_path("local-rack") do |s|
+ s.write "rack.gemspec", build_spec("rack", "0.8") { runtime "rspec", "> 0" }.first.to_ruby
+ s.write "lib/rack.rb", "puts :LOCAL"
+ end
+
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
+ G
+
+ bundle! %(config local.rack #{lib_path("local-rack")})
+ bundle! :install
+ run! "require 'rack'"
+ expect(out).to eq("LOCAL")
+ end
+
it "updates specs on runtime" do
system_gems "nokogiri-1.4.2"
@@ -382,7 +402,7 @@ describe "bundle install with git sources" do
# gem "thingy", :git => "git@notthere.fallingsnow.net:somebody/thingy.git"
# G
#
- # bundle :install, :expect_err => true
+ # bundle :install
#
# # p out
# # p err
@@ -399,7 +419,7 @@ describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}"
G
- should_be_installed "rack 0.8"
+ expect(the_bundle).to include_gems "rack 0.8"
end
it "installs dependencies from git even if a newer gem is available elsewhere" do
@@ -435,7 +455,7 @@ describe "bundle install with git sources" do
gem "rack", "1.0.0", :git => "#{lib_path("rack")}"
G
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "correctly unlocks when changing to a git source without versions" do
@@ -451,7 +471,7 @@ describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack")}"
G
- should_be_installed "rack 1.2"
+ expect(the_bundle).to include_gems "rack 1.2"
end
end
@@ -467,7 +487,7 @@ describe "bundle install with git sources" do
end
G
- should_be_installed "omg 1.0", "hi2u 1.0"
+ expect(the_bundle).to include_gems "omg 1.0", "hi2u 1.0"
end
end
@@ -499,8 +519,8 @@ describe "bundle install with git sources" do
gem "rails", "2.3.2"
G
- should_be_installed "foo 1.0"
- should_be_installed "rails 2.3.2"
+ expect(the_bundle).to include_gems "foo 1.0"
+ expect(the_bundle).to include_gems "rails 2.3.2"
end
it "runs the gemspec in the context of its parent directory" do
@@ -529,8 +549,8 @@ describe "bundle install with git sources" do
gem "rails", "2.3.2"
G
- should_be_installed "bar 1.0"
- should_be_installed "rails 2.3.2"
+ expect(the_bundle).to include_gems "bar 1.0"
+ expect(the_bundle).to include_gems "rails 2.3.2"
end
it "installs from git even if a rubygems gem is present" do
@@ -544,7 +564,7 @@ describe "bundle install with git sources" do
gem "foo", "1.0", :git => "#{lib_path("foo-1.0")}"
G
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "fakes the gem out if there is no gemspec" do
@@ -556,8 +576,8 @@ describe "bundle install with git sources" do
gem "rails", "2.3.2"
G
- should_be_installed("foo 1.0")
- should_be_installed("rails 2.3.2")
+ expect(the_bundle).to include_gems("foo 1.0")
+ expect(the_bundle).to include_gems("rails 2.3.2")
end
it "catches git errors and spits out useful output" do
@@ -565,7 +585,7 @@ describe "bundle install with git sources" do
gem "foo", "1.0", :git => "omgomg"
G
- bundle :install, :expect_err => true
+ bundle :install
expect(out).to include("Git error:")
expect(err).to include("fatal")
@@ -579,7 +599,7 @@ describe "bundle install with git sources" do
gem "foo", :git => "#{lib_path("foo space-1.0")}"
G
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "handles repos that have been force-pushed" do
@@ -590,21 +610,21 @@ describe "bundle install with git sources" do
gem 'forced'
end
G
- should_be_installed "forced 1.0"
+ expect(the_bundle).to include_gems "forced 1.0"
update_git "forced" do |s|
s.write "lib/forced.rb", "FORCED = '1.1'"
end
bundle "update"
- should_be_installed "forced 1.1"
+ expect(the_bundle).to include_gems "forced 1.1"
Dir.chdir(lib_path("forced-1.0")) do
`git reset --hard HEAD^`
end
bundle "update"
- should_be_installed "forced 1.0"
+ expect(the_bundle).to include_gems "forced 1.0"
end
it "ignores submodules if :submodule is not passed" do
@@ -613,18 +633,18 @@ describe "bundle install with git sources" 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", :expect_err => true
+ sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
`git commit -m "submodulator"`
end
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
git "#{lib_path("has_submodule-1.0")}" do
gem "has_submodule"
end
G
expect(out).to match(/could not find gem 'submodule/i)
- should_not_be_installed "has_submodule 1.0", :expect_err => true
+ expect(the_bundle).not_to include_gems "has_submodule 1.0"
end
it "handles repos with submodules" do
@@ -633,17 +653,17 @@ describe "bundle install with git sources" 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", :expect_err => true
+ sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
`git commit -m "submodulator"`
end
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
git "#{lib_path("has_submodule-1.0")}", :submodules => true do
gem "has_submodule"
end
G
- should_be_installed "has_submodule 1.0"
+ expect(the_bundle).to include_gems "has_submodule 1.0"
end
it "handles implicit updates when modifying the source info" do
@@ -748,7 +768,7 @@ describe "bundle install with git sources" do
gem "bar", :git => "#{lib_path("bar")}"
G
- should_be_installed "foo 1.0", "bar 1.0"
+ expect(the_bundle).to include_gems "foo 1.0", "bar 1.0"
end
it "doesn't explode when switching Gem to Git source" do
@@ -810,10 +830,10 @@ describe "bundle install with git sources" do
bundle "install"
expect(out).to_not match(/Revision.*does not exist/)
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
gem "foo", :git => "file://#{lib_path("foo-1.0")}", :ref => "deadbeef"
G
- bundle "install", :expect_err => true
+ bundle "install"
expect(out).to include("Revision deadbeef does not exist in the repository")
end
end
@@ -850,8 +870,8 @@ describe "bundle install with git sources" do
H
end
- bundle :install, :expect_err => true,
- :requires => [lib_path("install_hooks.rb")]
+ bundle :install,
+ :requires => [lib_path("install_hooks.rb")]
expect(err).to eq_err("Ran pre-install hook: foo-1.0")
end
@@ -870,8 +890,8 @@ describe "bundle install with git sources" do
H
end
- bundle :install, :expect_err => true,
- :requires => [lib_path("install_hooks.rb")]
+ bundle :install,
+ :requires => [lib_path("install_hooks.rb")]
expect(err).to eq_err("Ran post-install hook: foo-1.0")
end
@@ -890,8 +910,8 @@ describe "bundle install with git sources" do
H
end
- bundle :install, :expect_err => true,
- :requires => [lib_path("install_hooks.rb")]
+ bundle :install,
+ :requires => [lib_path("install_hooks.rb")]
expect(out).to include("failed for foo-1.0")
end
end
@@ -1098,7 +1118,7 @@ describe "bundle install with git sources" do
G
bundle :install
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
end
end
@@ -1108,13 +1128,13 @@ describe "bundle install with git sources" do
let(:credentials) { "user1:password1" }
it "does not display the password" do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
git "https://#{credentials}@github.com/company/private-repo" do
gem "foo"
end
G
- bundle :install, :expect_err => true
+ bundle :install
expect(out).to_not include("password1")
expect(out).to include("Fetching https://user1@github.com/company/private-repo")
end
@@ -1124,13 +1144,13 @@ describe "bundle install with git sources" do
let(:credentials) { "oauth_token" }
it "displays the oauth scheme but not the oauth token" do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
git "https://#{credentials}:x-oauth-basic@github.com/company/private-repo" do
gem "foo"
end
G
- bundle :install, :expect_err => true
+ bundle :install
expect(out).to_not include("oauth_token")
expect(out).to include("Fetching https://x-oauth-basic@github.com/company/private-repo")
end
diff --git a/spec/install/gemfile/groups_spec.rb b/spec/install/gemfile/groups_spec.rb
index 7d8768eca9..cb052b6c7a 100644
--- a/spec/install/gemfile/groups_spec.rb
+++ b/spec/install/gemfile/groups_spec.rb
@@ -15,11 +15,11 @@ describe "bundle install with groups" do
end
it "installs gems in the default group" do
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "installs gems in a group block into that group" do
- should_be_installed "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "activesupport 2.3.5"
load_error_run <<-R, "activesupport", :default
require 'activesupport'
@@ -30,7 +30,7 @@ describe "bundle install with groups" do
end
it "installs gems with inline :groups into those groups" do
- should_be_installed "thin 1.0"
+ expect(the_bundle).to include_gems "thin 1.0"
load_error_run <<-R, "thin", :default
require 'thin'
@@ -88,19 +88,19 @@ describe "bundle install with groups" do
it "installs gems in the default group" do
bundle :install, :without => "emo"
- should_be_installed "rack 1.0.0", :groups => [:default]
+ expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default]
end
it "does not install gems from the excluded group" do
bundle :install, :without => "emo"
- should_not_be_installed "activesupport 2.3.5", :groups => [:default]
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5", :groups => [:default]
end
it "does not install gems from the previously excluded group" do
bundle :install, :without => "emo"
- should_not_be_installed "activesupport 2.3.5"
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5"
bundle :install
- should_not_be_installed "activesupport 2.3.5"
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5"
end
it "does not say it installed gems from the excluded group" do
@@ -124,7 +124,7 @@ describe "bundle install with groups" do
G
bundle :install, :without => "emo"
- should_be_installed "activesupport 2.3.2", :groups => [:default]
+ expect(the_bundle).to include_gems "activesupport 2.3.2", :groups => [:default]
end
it "still works on a different machine and excludes gems" do
@@ -133,8 +133,8 @@ describe "bundle install with groups" do
simulate_new_machine
bundle :install, :without => "emo"
- should_be_installed "rack 1.0.0", :groups => [:default]
- should_not_be_installed "activesupport 2.3.5", :groups => [:default]
+ expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default]
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5", :groups => [:default]
end
it "still works when BUNDLE_WITHOUT is set" do
@@ -143,8 +143,8 @@ describe "bundle install with groups" do
bundle :install
expect(out).not_to include("activesupport")
- should_be_installed "rack 1.0.0", :groups => [:default]
- should_not_be_installed "activesupport 2.3.5", :groups => [:default]
+ expect(the_bundle).to include_gems "rack 1.0.0", :groups => [:default]
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5", :groups => [:default]
ENV["BUNDLE_WITHOUT"] = nil
end
@@ -153,56 +153,56 @@ describe "bundle install with groups" do
bundle :install, :without => "emo"
bundle 'install --without ""'
- should_be_installed "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "activesupport 2.3.5"
end
it "doesn't clear without when nothing is passed" do
bundle :install, :without => "emo"
bundle :install
- should_not_be_installed "activesupport 2.3.5"
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5"
end
it "does not install gems from the optional group" do
bundle :install
- should_not_be_installed "thin 1.0"
+ expect(the_bundle).not_to include_gems "thin 1.0"
end
it "does install gems from the optional group when requested" do
bundle :install, :with => "debugging"
- should_be_installed "thin 1.0"
+ expect(the_bundle).to include_gems "thin 1.0"
end
it "does install gems from the previously requested group" do
bundle :install, :with => "debugging"
- should_be_installed "thin 1.0"
+ expect(the_bundle).to include_gems "thin 1.0"
bundle :install
- should_be_installed "thin 1.0"
+ expect(the_bundle).to include_gems "thin 1.0"
end
it "does install gems from the optional groups requested with BUNDLE_WITH" do
ENV["BUNDLE_WITH"] = "debugging"
bundle :install
- should_be_installed "thin 1.0"
+ expect(the_bundle).to include_gems "thin 1.0"
ENV["BUNDLE_WITH"] = nil
end
it "clears with when passed an empty list" do
bundle :install, :with => "debugging"
bundle 'install --with ""'
- should_not_be_installed "thin 1.0"
+ expect(the_bundle).not_to include_gems "thin 1.0"
end
it "does remove groups from without when passed at with" do
bundle :install, :without => "emo"
bundle :install, :with => "emo"
- should_be_installed "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "activesupport 2.3.5"
end
it "does remove groups from with when passed at without" do
bundle :install, :with => "debugging"
bundle :install, :without => "debugging"
- should_not_be_installed "thin 1.0"
+ expect(the_bundle).not_to include_gems "thin 1.0"
end
it "errors out when passing a group to with and without" do
@@ -212,18 +212,18 @@ describe "bundle install with groups" do
it "can add and remove a group at the same time" do
bundle :install, :with => "debugging", :without => "emo"
- should_be_installed "thin 1.0"
- should_not_be_installed "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "thin 1.0"
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5"
end
it "does have no effect when listing a not optional group in with" do
bundle :install, :with => "emo"
- should_be_installed "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "activesupport 2.3.5"
end
it "does have no effect when listing an optional group in without" do
bundle :install, :without => "debugging"
- should_not_be_installed "thin 1.0"
+ expect(the_bundle).not_to include_gems "thin 1.0"
end
end
@@ -240,12 +240,12 @@ describe "bundle install with groups" do
it "installs gems in the default group" do
bundle :install, :without => "emo lolercoaster"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "installs the gem if any of its groups are installed" do
bundle "install --without emo"
- should_be_installed "rack 1.0.0", "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
end
describe "with a gem defined multiple times in different groups" do
@@ -266,22 +266,22 @@ describe "bundle install with groups" do
it "installs the gem w/ option --without emo" do
bundle "install --without emo"
- should_be_installed "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "activesupport 2.3.5"
end
it "installs the gem w/ option --without lolercoaster" do
bundle "install --without lolercoaster"
- should_be_installed "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "activesupport 2.3.5"
end
it "does not install the gem w/ option --without emo lolercoaster" do
bundle "install --without emo lolercoaster"
- should_not_be_installed "activesupport 2.3.5"
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5"
end
it "does not install the gem w/ option --without 'emo lolercoaster'" do
bundle "install --without 'emo lolercoaster'"
- should_not_be_installed "activesupport 2.3.5"
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5"
end
end
end
@@ -301,12 +301,12 @@ describe "bundle install with groups" do
it "installs gems in the default group" do
bundle :install, :without => "emo lolercoaster"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "installs the gem if any of its groups are installed" do
bundle "install --without emo"
- should_be_installed "rack 1.0.0", "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
end
end
end
@@ -352,14 +352,14 @@ describe "bundle install with groups" do
end
it "uses the correct versions even if --without was used on the original" do
- should_be_installed "rack 0.9.1"
- should_not_be_installed "rack_middleware 1.0"
+ expect(the_bundle).to include_gems "rack 0.9.1"
+ expect(the_bundle).not_to include_gems "rack_middleware 1.0"
simulate_new_machine
bundle :install
- should_be_installed "rack 0.9.1"
- should_be_installed "rack_middleware 1.0"
+ expect(the_bundle).to include_gems "rack 0.9.1"
+ expect(the_bundle).to include_gems "rack_middleware 1.0"
end
it "does not hit the remote a second time" do
diff --git a/spec/install/gemfile/install_if.rb b/spec/install/gemfile/install_if.rb
index 080a35b989..b1717ad583 100644
--- a/spec/install/gemfile/install_if.rb
+++ b/spec/install/gemfile/install_if.rb
@@ -15,9 +15,9 @@ describe "bundle install with install_if conditionals" do
gem "rack"
G
- should_be_installed("rack 1.0", "activesupport 2.3.5")
- should_not_be_installed("thin")
- should_not_be_installed("foo")
+ expect(the_bundle).to include_gems("rack 1.0", "activesupport 2.3.5")
+ expect(the_bundle).not_to include_gems("thin")
+ expect(the_bundle).not_to include_gems("foo")
lockfile_should_be <<-L
GEM
diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb
index 50fc1abac5..0a73335225 100644
--- a/spec/install/gemfile/path_spec.rb
+++ b/spec/install/gemfile/path_spec.rb
@@ -10,7 +10,7 @@ describe "bundle install with explicit source paths" do
gem 'foo'
G
- should_be_installed("foo 1.0")
+ expect(the_bundle).to include_gems("foo 1.0")
end
it "supports pinned paths" do
@@ -20,7 +20,7 @@ describe "bundle install with explicit source paths" do
gem 'foo', :path => "#{lib_path("foo-1.0")}"
G
- should_be_installed("foo 1.0")
+ expect(the_bundle).to include_gems("foo 1.0")
end
it "supports relative paths" do
@@ -32,7 +32,7 @@ describe "bundle install with explicit source paths" do
gem 'foo', :path => "#{relative_path}"
G
- should_be_installed("foo 1.0")
+ expect(the_bundle).to include_gems("foo 1.0")
end
it "expands paths" do
@@ -44,7 +44,7 @@ describe "bundle install with explicit source paths" do
gem 'foo', :path => "~/#{relative_path}"
G
- should_be_installed("foo 1.0")
+ expect(the_bundle).to include_gems("foo 1.0")
end
it "expands paths raise error with not existing user's home dir" do
@@ -68,7 +68,7 @@ describe "bundle install with explicit source paths" do
bundled_app("subdir").mkpath
Dir.chdir(bundled_app("subdir")) do
- should_be_installed("foo 1.0")
+ expect(the_bundle).to include_gems("foo 1.0")
end
end
@@ -118,7 +118,7 @@ describe "bundle install with explicit source paths" do
gem "omg", :path => "#{lib_path("omg")}"
G
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "prefers gemspecs closer to the path root" do
@@ -139,7 +139,7 @@ describe "bundle install with explicit source paths" do
# Installation of the 'gemfiles' gemspec would fail since it will be unable
# to require 'premailer.rb'
- should_be_installed "premailer 1.0.0"
+ expect(the_bundle).to include_gems "premailer 1.0.0"
end
it "warns on invalid specs", :rubygems => "1.7" do
@@ -154,7 +154,7 @@ describe "bundle install with explicit source paths" do
G
end
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
gem "foo", :path => "#{lib_path("foo-1.0")}"
G
@@ -179,8 +179,8 @@ describe "bundle install with explicit source paths" do
Dir.chdir(lib_path("foo")) do
bundle "install"
- should_be_installed "foo 1.0"
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
@@ -194,8 +194,8 @@ describe "bundle install with explicit source paths" do
gemspec :path => "#{lib_path("foo")}"
G
- should_be_installed "foo 1.0"
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "doesn't automatically unlock dependencies when using the gemspec syntax" do
@@ -214,8 +214,8 @@ describe "bundle install with explicit source paths" do
bundle "install"
- should_be_installed "foo 1.0"
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "doesn't automatically unlock dependencies when using the gemspec syntax and the gem has development dependencies" do
@@ -235,13 +235,13 @@ describe "bundle install with explicit source paths" do
bundle "install"
- should_be_installed "foo 1.0"
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "raises if there are multiple gemspecs" do
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.write "bar.gemspec"
+ s.write "bar.gemspec", build_spec("bar", "1.0").first.to_ruby
end
install_gemfile <<-G
@@ -261,12 +261,10 @@ describe "bundle install with explicit source paths" do
gemspec :path => "#{lib_path("foo")}", :name => "foo"
G
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "sets up executables" do
- pending_jruby_shebang_fix
-
build_lib "foo" do |s|
s.executables = "foobar"
end
@@ -275,7 +273,7 @@ describe "bundle install with explicit source paths" do
path "#{lib_path("foo-1.0")}"
gem 'foo'
G
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
bundle "exec foobar"
expect(out).to eq("1.0")
@@ -314,7 +312,7 @@ describe "bundle install with explicit source paths" do
end
G
- should_be_installed "omg 1.0", "hi2u 1.0"
+ expect(the_bundle).to include_gems "omg 1.0", "hi2u 1.0"
end
end
@@ -330,7 +328,7 @@ describe "bundle install with explicit source paths" do
gem "omg", :path => "#{lib_path("omg")}"
G
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "works when the path does not have a gemspec" do
@@ -340,9 +338,9 @@ describe "bundle install with explicit source paths" do
gem "foo", "1.0", :path => "#{lib_path("foo-1.0")}"
G
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "works when the path does not have a gemspec but there is a lockfile" do
@@ -373,7 +371,7 @@ describe "bundle install with explicit source paths" do
bundle :check, :env => { "DEBUG" => 1 }
expect(out).to match(/using resolution from the lockfile/)
- should_be_installed "rack-obama 1.0", "net-ssh 1.0"
+ expect(the_bundle).to include_gems "rack-obama 1.0", "net-ssh 1.0"
end
it "source path gems w/deps don't re-resolve without changes" do
@@ -393,7 +391,7 @@ describe "bundle install with explicit source paths" do
bundle :check, :env => { "DEBUG" => 1 }
expect(out).to match(/using resolution from the lockfile/)
- should_be_installed "rack-obama 1.0", "net-ssh 1.0"
+ expect(the_bundle).to include_gems "rack-obama 1.0", "net-ssh 1.0"
end
end
@@ -429,7 +427,7 @@ describe "bundle install with explicit source paths" do
bundle "install"
- should_be_installed "foo 2.0", "bar 1.0"
+ expect(the_bundle).to include_gems "foo 2.0", "bar 1.0"
end
it "unlocks all gems when a child dependency gem is updated" do
@@ -437,7 +435,7 @@ describe "bundle install with explicit source paths" do
bundle "install"
- should_be_installed "foo 1.0", "bar 2.0"
+ expect(the_bundle).to include_gems "foo 1.0", "bar 2.0"
end
end
@@ -458,7 +456,7 @@ describe "bundle install with explicit source paths" do
bundle "install"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -482,7 +480,7 @@ describe "bundle install with explicit source paths" do
gem "bar", :path => "#{lib_path("bar")}"
G
- should_be_installed "foo 1.0", "bar 1.0"
+ expect(the_bundle).to include_gems "foo 1.0", "bar 1.0"
end
it "switches the source when the gem existed in rubygems and the path was already being used for another gem" do
@@ -509,7 +507,7 @@ describe "bundle install with explicit source paths" do
end
G
- should_be_installed "bar 1.0"
+ expect(the_bundle).to include_gems "bar 1.0"
end
end
@@ -527,8 +525,8 @@ describe "bundle install with explicit source paths" 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/)
- should_be_installed "private_lib 2.2"
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "private_lib 2.2"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
end
@@ -549,8 +547,8 @@ describe "bundle install with explicit source paths" do
H
end
- bundle :install, :expect_err => true,
- :requires => [lib_path("install_hooks.rb")]
+ bundle :install,
+ :requires => [lib_path("install_hooks.rb")]
expect(err).to eq_err("Ran pre-install hook: foo-1.0")
end
@@ -569,8 +567,8 @@ describe "bundle install with explicit source paths" do
H
end
- bundle :install, :expect_err => true,
- :requires => [lib_path("install_hooks.rb")]
+ bundle :install,
+ :requires => [lib_path("install_hooks.rb")]
expect(err).to eq_err("Ran post-install hook: foo-1.0")
end
@@ -589,8 +587,8 @@ describe "bundle install with explicit source paths" do
H
end
- bundle :install, :expect_err => true,
- :requires => [lib_path("install_hooks.rb")]
+ bundle :install,
+ :requires => [lib_path("install_hooks.rb")]
expect(out).to include("failed for foo-1.0")
end
end
diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb
index a562a3bc11..58129bb313 100644
--- a/spec/install/gemfile/platform_spec.rb
+++ b/spec/install/gemfile/platform_spec.rb
@@ -22,7 +22,7 @@ describe "bundle install across platforms" do
gem "rack"
G
- should_be_installed "rack 0.9.1"
+ expect(the_bundle).to include_gems "rack 0.9.1"
end
it "pulls in the correct platform specific gem" do
@@ -48,7 +48,7 @@ describe "bundle install across platforms" do
gem "platform_specific"
G
- should_be_installed "platform_specific 1.0 JAVA"
+ expect(the_bundle).to include_gems "platform_specific 1.0 JAVA"
end
it "works with gems that have different dependencies" do
@@ -59,7 +59,7 @@ describe "bundle install across platforms" do
gem "nokogiri"
G
- should_be_installed "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
+ expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
simulate_new_machine
@@ -70,8 +70,8 @@ describe "bundle install across platforms" do
gem "nokogiri"
G
- should_be_installed "nokogiri 1.4.2"
- should_not_be_installed "weakling"
+ expect(the_bundle).to include_gems "nokogiri 1.4.2"
+ expect(the_bundle).not_to include_gems "weakling"
end
it "works the other way with gems that have different dependencies" do
@@ -85,7 +85,7 @@ describe "bundle install across platforms" do
simulate_platform "java"
bundle "install"
- should_be_installed "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
+ expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
end
it "fetches gems again after changing the version of Ruby" do
@@ -115,7 +115,7 @@ describe "bundle install with platform conditionals" do
end
G
- should_be_installed "nokogiri 1.4.2"
+ expect(the_bundle).to include_gems "nokogiri 1.4.2"
end
it "does not install gems tagged w/ another platforms" do
@@ -127,8 +127,8 @@ describe "bundle install with platform conditionals" do
end
G
- should_be_installed "rack 1.0"
- should_not_be_installed "nokogiri 1.4.2"
+ expect(the_bundle).to include_gems "rack 1.0"
+ expect(the_bundle).not_to include_gems "nokogiri 1.4.2"
end
it "installs gems tagged w/ the current platforms inline" do
@@ -136,7 +136,7 @@ describe "bundle install with platform conditionals" do
source "file://#{gem_repo1}"
gem "nokogiri", :platforms => :#{local_tag}
G
- should_be_installed "nokogiri 1.4.2"
+ expect(the_bundle).to include_gems "nokogiri 1.4.2"
end
it "does not install gems tagged w/ another platforms inline" do
@@ -145,8 +145,8 @@ describe "bundle install with platform conditionals" do
gem "rack"
gem "nokogiri", :platforms => :#{not_local_tag}
G
- should_be_installed "rack 1.0"
- should_not_be_installed "nokogiri 1.4.2"
+ expect(the_bundle).to include_gems "rack 1.0"
+ expect(the_bundle).not_to include_gems "nokogiri 1.4.2"
end
it "installs gems tagged w/ the current platform inline" do
@@ -154,7 +154,7 @@ describe "bundle install with platform conditionals" do
source "file://#{gem_repo1}"
gem "nokogiri", :platform => :#{local_tag}
G
- should_be_installed "nokogiri 1.4.2"
+ expect(the_bundle).to include_gems "nokogiri 1.4.2"
end
it "doesn't install gems tagged w/ another platform inline" do
@@ -162,7 +162,7 @@ describe "bundle install with platform conditionals" do
source "file://#{gem_repo1}"
gem "nokogiri", :platform => :#{not_local_tag}
G
- should_not_be_installed "nokogiri 1.4.2"
+ expect(the_bundle).not_to include_gems "nokogiri 1.4.2"
end
it "does not blow up on sources with all platform-excluded specs" do
@@ -217,6 +217,6 @@ describe "when a gem has no architecture" do
G
bundle :install, :fakeweb => "windows"
- should_be_installed "rcov 1.0.0"
+ expect(the_bundle).to include_gems "rcov 1.0.0"
end
end
diff --git a/spec/install/gemfile/ruby_spec.rb b/spec/install/gemfile/ruby_spec.rb
index d250e78693..1adbf10833 100644
--- a/spec/install/gemfile/ruby_spec.rb
+++ b/spec/install/gemfile/ruby_spec.rb
@@ -24,7 +24,7 @@ describe "ruby requirement" do
G
expect(exitstatus).to eq(0) if exitstatus
- should_be_installed "rack-obama 1.0"
+ expect(the_bundle).to include_gems "rack-obama 1.0"
end
it "allows removing the ruby version requirement" do
@@ -41,7 +41,7 @@ describe "ruby requirement" do
gem "rack"
G
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
expect(lockfile).not_to include("RUBY VERSION")
end
@@ -62,7 +62,7 @@ describe "ruby requirement" do
gem "rack"
G
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
expect(locked_ruby_version).to eq(Bundler::RubyVersion.system)
end
@@ -83,7 +83,7 @@ describe "ruby requirement" do
gem "rack"
G
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
expect(locked_ruby_version.versions).to eq(["5100"])
end
end
diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb
index 70ea9e30ce..fd11c3feab 100644
--- a/spec/install/gemfile/sources_spec.rb
+++ b/spec/install/gemfile/sources_spec.rb
@@ -35,14 +35,14 @@ describe "bundle install with gems on multiple sources" do
expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).to include("Installed from: file:#{gem_repo1}")
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
+ expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end
it "errors when disable_multisource is set" do
bundle "config disable_multisource true"
bundle :install
expect(out).to include("Each source after the first must include a block")
- expect(exitstatus).to eq(14) if exitstatus
+ expect(exitstatus).to eq(4) if exitstatus
end
end
@@ -65,7 +65,7 @@ describe "bundle install with gems on multiple sources" do
expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).to include("Installed from: file:#{gem_repo1}")
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
+ expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end
end
end
@@ -94,7 +94,8 @@ describe "bundle install with gems on multiple sources" do
it "installs the gems without any warning" do
bundle :install
expect(out).not_to include("Warning")
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
+ expect(the_bundle).to include_gems("rack-obama 1.0.0")
+ expect(the_bundle).to include_gems("rack 1.0.0", :source => "remote1")
end
it "can cache and deploy" do
@@ -106,7 +107,7 @@ describe "bundle install with gems on multiple sources" do
bundle "install --deployment"
expect(exitstatus).to eq(0) if exitstatus
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
+ expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0")
end
end
@@ -130,7 +131,7 @@ describe "bundle install with gems on multiple sources" do
it "installs the gems without any warning" do
bundle :install
expect(out).not_to include("Warning")
- should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
+ expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0")
end
end
@@ -166,7 +167,7 @@ describe "bundle install with gems on multiple sources" do
it "installs from the same source without any warning" do
bundle :install
expect(out).not_to include("Warning")
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
+ expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
end
@@ -183,7 +184,7 @@ describe "bundle install with gems on multiple sources" do
it "installs from the same source without any warning" do
bundle :install
expect(out).not_to include("Warning")
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
+ expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
end
end
@@ -209,7 +210,7 @@ describe "bundle install with gems on multiple sources" do
it "installs from the other source without any warning" do
bundle :install
expect(out).not_to include("Warning")
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
+ expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
end
@@ -230,7 +231,7 @@ describe "bundle install with gems on multiple sources" do
expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).to include("Installed from: file:#{gem_repo2}")
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
+ expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
end
@@ -256,7 +257,7 @@ describe "bundle install with gems on multiple sources" do
bundle :install
expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.")
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
+ 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
# when there is already a lock file, and the gems are missing, so try again
@@ -264,7 +265,7 @@ describe "bundle install with gems on multiple sources" do
bundle :install
expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.")
- should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
+ expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
end
end
@@ -316,7 +317,7 @@ describe "bundle install with gems on multiple sources" do
# Reproduction of https://github.com/bundler/bundler/issues/3298
it "does not unlock the installed gem on exec" do
- should_be_installed("rack 0.9.1")
+ expect(the_bundle).to include_gems("rack 0.9.1")
end
end
@@ -354,7 +355,7 @@ describe "bundle install with gems on multiple sources" do
it "installs the gems without any warning" do
bundle :install
expect(out).not_to include("Warning")
- should_be_installed("rack 1.0.0")
+ expect(the_bundle).to include_gems("rack 1.0.0")
end
end
@@ -412,8 +413,8 @@ describe "bundle install with gems on multiple sources" do
G
# 6. Which should update foo to 0.2, but not the (locked) bar 0.1
- should_be_installed("foo 0.2")
- should_be_installed("bar 0.1")
+ expect(the_bundle).to include_gems("foo 0.2")
+ expect(the_bundle).to include_gems("bar 0.1")
end
end
diff --git a/spec/install/gemfile_spec.rb b/spec/install/gemfile_spec.rb
index a0a1cb9a65..98abc30c86 100644
--- a/spec/install/gemfile_spec.rb
+++ b/spec/install/gemfile_spec.rb
@@ -22,7 +22,7 @@ describe "bundle install" do
bundle :install, :gemfile => bundled_app("NotGemfile")
ENV["BUNDLE_GEMFILE"] = "NotGemfile"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb
index e96936f01d..0edd1d20e7 100644
--- a/spec/install/gems/compact_index_spec.rb
+++ b/spec/install/gems/compact_index_spec.rb
@@ -13,7 +13,7 @@ describe "compact index api" do
bundle! :install, :artifice => "compact_index"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "should URI encode gem names" do
@@ -34,13 +34,34 @@ describe "compact index api" do
bundle! :install, :artifice => "compact_index"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed(
+ expect(the_bundle).to include_gems(
"rails 2.3.2",
"actionpack 2.3.2",
"activerecord 2.3.2",
"actionmailer 2.3.2",
"activeresource 2.3.2",
- "activesupport 2.3.2")
+ "activesupport 2.3.2"
+ )
+ end
+
+ it "should handle case sensitivity conflicts" do
+ build_repo4 do
+ build_gem "rack", "1.0" do |s|
+ s.add_runtime_dependency("Rack", "0.1")
+ end
+ build_gem "Rack", "0.1"
+ end
+
+ install_gemfile! <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4 }
+ source "#{source_uri}"
+ gem "rack", "1.0"
+ gem "Rack", "0.1"
+ G
+
+ # can't use `include_gems` here since the `require` will conflict on a
+ # case-insensitive FS
+ run! "Bundler.require; puts Gem.loaded_specs.values_at('rack', 'Rack').map(&:full_name)"
+ expect(out).to eq("rack-1.0\nRack-0.1")
end
it "should handle multiple gem dependencies on the same gem" do
@@ -50,7 +71,7 @@ describe "compact index api" do
G
bundle! :install, :artifice => "compact_index"
- should_be_installed "net-sftp 1.1.1"
+ expect(the_bundle).to include_gems "net-sftp 1.1.1"
end
it "should use the endpoint when using --deployment" do
@@ -62,7 +83,7 @@ describe "compact index api" do
bundle "install --deployment", :artifice => "compact_index"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "handles git dependencies that are in rubygems" do
@@ -80,7 +101,7 @@ describe "compact index api" do
bundle! :install, :artifice => "compact_index"
- should_be_installed("rails 2.3.2")
+ expect(the_bundle).to include_gems("rails 2.3.2")
end
it "handles git dependencies that are in rubygems using --deployment" do
@@ -98,7 +119,7 @@ describe "compact index api" do
bundle "install --deployment", :artifice => "compact_index"
- should_be_installed("rails 2.3.2")
+ expect(the_bundle).to include_gems("rails 2.3.2")
end
it "doesn't fail if you only have a git gem with no deps when using --deployment" do
@@ -112,7 +133,7 @@ describe "compact index api" do
bundle "install --deployment", :artifice => "compact_index"
expect(exitstatus).to eq(0) if exitstatus
- should_be_installed("foo 1.0")
+ expect(the_bundle).to include_gems("foo 1.0")
end
it "falls back when the API errors out" do
@@ -125,7 +146,7 @@ describe "compact index api" do
bundle! :install, :fakeweb => "windows"
expect(out).to include("Fetching source index from #{source_uri}")
- should_be_installed "rcov 1.0.0"
+ expect(the_bundle).to include_gems "rcov 1.0.0"
end
it "falls back when the API URL returns 403 Forbidden" do
@@ -136,7 +157,7 @@ describe "compact index api" do
bundle! :install, :verbose => true, :artifice => "compact_index_forbidden"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "falls back when the versions endpoint has a checksum mismatch" do
@@ -150,7 +171,7 @@ describe "compact index api" do
expect(out).to include <<-'WARN'
The checksum of /versions does not match the checksum provided by the server! Something is wrong (local checksum is "\"d41d8cd98f00b204e9800998ecf8427e\"", was expecting "\"123\"").
WARN
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "falls back when the user's home directory does not exist or is not writable" do
@@ -163,7 +184,7 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle! :install, :artifice => "compact_index"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "handles host redirects" do
@@ -173,7 +194,7 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle! :install, :artifice => "compact_index_host_redirect"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "handles host redirects without Net::HTTP::Persistent" do
@@ -197,7 +218,7 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle! :install, :artifice => "compact_index_host_redirect", :requires => [lib_path("disable_net_http_persistent.rb")]
expect(out).to_not match(/Too many redirects/)
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "times out when Bundler::Fetcher redirects too much" do
@@ -219,7 +240,7 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle "install --full-index", :artifice => "compact_index"
expect(out).to include("Fetching source index from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "should use the modern index for update" do
@@ -230,7 +251,7 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle "update --full-index", :artifice => "compact_index"
expect(out).to include("Fetching source index from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -249,7 +270,7 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle! :install, :artifice => "compact_index_extra"
- should_be_installed "back_deps 1.0"
+ expect(the_bundle).to include_gems "back_deps 1.0"
end
it "fetches gem versions even when those gems are already installed" do
@@ -258,7 +279,7 @@ The checksum of /versions does not match the checksum provided by the server! So
gem "rack", "1.0.0"
G
bundle! :install, :artifice => "compact_index_extra_api"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
build_repo4 do
build_gem "rack", "1.2" do |s|
@@ -272,7 +293,7 @@ The checksum of /versions does not match the checksum provided by the server! So
gem "rack", "1.2"
G
bundle! :install, :artifice => "compact_index_extra_api"
- should_be_installed "rack 1.2"
+ expect(the_bundle).to include_gems "rack 1.2"
end
it "considers all possible versions of dependencies from all api gem sources" do
@@ -295,8 +316,8 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle! :install, :artifice => "compact_index_extra_api"
- should_be_installed "somegem 1.0.0"
- should_be_installed "activesupport 1.2.3"
+ expect(the_bundle).to include_gems "somegem 1.0.0"
+ expect(the_bundle).to include_gems "activesupport 1.2.3"
end
it "prints API output properly with back deps" do
@@ -340,7 +361,7 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle! :install, :artifice => "compact_index_extra_missing"
- should_be_installed "back_deps 1.0"
+ expect(the_bundle).to include_gems "back_deps 1.0"
end
it "uses the endpoint if all sources support it" do
@@ -351,7 +372,7 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle! :install, :artifice => "compact_index_api_missing"
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "fetches again when more dependencies are found in subsequent sources using --deployment" do
@@ -371,7 +392,7 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle! :install, :artifice => "compact_index_extra"
bundle "install --deployment", :artifice => "compact_index_extra"
- should_be_installed "back_deps 1.0"
+ expect(the_bundle).to include_gems "back_deps 1.0"
end
it "does not refetch if the only unmet dependency is bundler" do
@@ -394,7 +415,7 @@ The checksum of /versions does not match the checksum provided by the server! So
gem "rails"
G
bundle! :install, :artifice => "compact_index"
- should_be_installed "rails 2.3.2"
+ expect(the_bundle).to include_gems "rails 2.3.2"
end
it "installs the binstubs" do
@@ -471,7 +492,7 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle! :install, :artifice => "compact_index_basic_authentication"
expect(out).not_to include("#{user}:#{password}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "strips http basic authentication creds for modern index" do
@@ -482,7 +503,7 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle! :install, :artifice => "endopint_marshal_fail_basic_authentication"
expect(out).not_to include("#{user}:#{password}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "strips http basic auth creds when it can't reach the server" do
@@ -505,7 +526,7 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle! :install, :artifice => "compact_index_basic_authentication"
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).not_to include("#{user}:#{password}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "does not pass the user / password to different hosts on redirect" do
@@ -515,7 +536,7 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle! :install, :artifice => "compact_index_creds_diff_host"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
describe "with authentication details in bundle config" do
@@ -532,7 +553,7 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle! :install, :artifice => "compact_index_strict_basic_authentication"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "reads authentication details by full url from bundle config" do
@@ -542,14 +563,14 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle! :install, :artifice => "compact_index_strict_basic_authentication"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "should use the API" do
bundle "config #{source_hostname} #{user}:#{password}"
bundle! :install, :artifice => "compact_index_strict_basic_authentication"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "prefers auth supplied in the source uri" do
@@ -561,7 +582,7 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle "config #{source_hostname} otheruser:wrong"
bundle! :install, :artifice => "compact_index_strict_basic_authentication"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "shows instructions if auth is not provided for the source" do
@@ -587,7 +608,7 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle! :install, :artifice => "compact_index_basic_authentication"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
end
@@ -672,6 +693,6 @@ The checksum of /versions does not match the checksum provided by the server! So
bundle! :install, :artifice => "compact_index_concurrent_download"
expect(File.read(versions)).to start_with("created_at")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb
index 70190dd01b..a7c1aedea3 100644
--- a/spec/install/gems/dependency_api_spec.rb
+++ b/spec/install/gems/dependency_api_spec.rb
@@ -13,7 +13,7 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "should URI encode gem names" do
@@ -34,13 +34,14 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint"
expect(out).to include("Fetching gem metadata from #{source_uri}/...")
- should_be_installed(
+ expect(the_bundle).to include_gems(
"rails 2.3.2",
"actionpack 2.3.2",
"activerecord 2.3.2",
"actionmailer 2.3.2",
"activeresource 2.3.2",
- "activesupport 2.3.2")
+ "activesupport 2.3.2"
+ )
end
it "should handle multiple gem dependencies on the same gem" do
@@ -50,7 +51,7 @@ describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint"
- should_be_installed "net-sftp 1.1.1"
+ expect(the_bundle).to include_gems "net-sftp 1.1.1"
end
it "should use the endpoint when using --deployment" do
@@ -62,7 +63,7 @@ describe "gemcutter's dependency API" do
bundle "install --deployment", :artifice => "endpoint"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "handles git dependencies that are in rubygems" do
@@ -80,7 +81,7 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint"
- should_be_installed("rails 2.3.2")
+ expect(the_bundle).to include_gems("rails 2.3.2")
end
it "handles git dependencies that are in rubygems using --deployment" do
@@ -98,7 +99,7 @@ describe "gemcutter's dependency API" do
bundle "install --deployment", :artifice => "endpoint"
- should_be_installed("rails 2.3.2")
+ expect(the_bundle).to include_gems("rails 2.3.2")
end
it "doesn't fail if you only have a git gem with no deps when using --deployment" do
@@ -112,7 +113,7 @@ describe "gemcutter's dependency API" do
bundle "install --deployment", :artifice => "endpoint"
expect(exitstatus).to eq(0) if exitstatus
- should_be_installed("foo 1.0")
+ expect(the_bundle).to include_gems("foo 1.0")
end
it "falls back when the API errors out" do
@@ -125,7 +126,7 @@ describe "gemcutter's dependency API" do
bundle :install, :fakeweb => "windows"
expect(out).to include("Fetching source index from #{source_uri}")
- should_be_installed "rcov 1.0.0"
+ expect(the_bundle).to include_gems "rcov 1.0.0"
end
it "falls back when hitting the Gemcutter Dependency Limit" do
@@ -142,7 +143,7 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint_fallback"
expect(out).to include("Fetching source index from #{source_uri}")
- should_be_installed(
+ expect(the_bundle).to include_gems(
"activesupport 2.3.2",
"actionpack 2.3.2",
"actionmailer 2.3.2",
@@ -150,7 +151,8 @@ describe "gemcutter's dependency API" do
"activesupport 2.3.2",
"thin 1.0.0",
"rack 1.0.0",
- "rails 2.3.2")
+ "rails 2.3.2"
+ )
end
it "falls back when Gemcutter API doesn't return proper Marshal format" do
@@ -161,7 +163,7 @@ describe "gemcutter's dependency API" do
bundle :install, :verbose => true, :artifice => "endpoint_marshal_fail"
expect(out).to include("could not fetch from the dependency API, trying the full index")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "falls back when the API URL returns 403 Forbidden" do
@@ -172,7 +174,7 @@ describe "gemcutter's dependency API" do
bundle :install, :verbose => true, :artifice => "endpoint_api_forbidden"
expect(out).to include("Fetching source index from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "handles host redirects" do
@@ -182,7 +184,7 @@ describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint_host_redirect"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "handles host redirects without Net::HTTP::Persistent" do
@@ -206,7 +208,7 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint_host_redirect", :requires => [lib_path("disable_net_http_persistent.rb")]
expect(out).to_not match(/Too many redirects/)
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "timeouts when Bundler::Fetcher redirects too much" do
@@ -228,7 +230,7 @@ describe "gemcutter's dependency API" do
bundle "install --full-index", :artifice => "endpoint"
expect(out).to include("Fetching source index from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "should use the modern index for update" do
@@ -239,7 +241,7 @@ describe "gemcutter's dependency API" do
bundle "update --full-index", :artifice => "endpoint"
expect(out).to include("Fetching source index from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -258,7 +260,7 @@ describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint_extra"
- should_be_installed "back_deps 1.0"
+ expect(the_bundle).to include_gems "back_deps 1.0"
end
it "fetches gem versions even when those gems are already installed" do
@@ -280,7 +282,7 @@ describe "gemcutter's dependency API" do
gem "rack", "1.2"
G
bundle :install, :artifice => "endpoint_extra_api"
- should_be_installed "rack 1.2"
+ expect(the_bundle).to include_gems "rack 1.2"
end
it "considers all possible versions of dependencies from all api gem sources" do
@@ -303,8 +305,8 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint_extra_api"
- should_be_installed "somegem 1.0.0"
- should_be_installed "activesupport 1.2.3"
+ expect(the_bundle).to include_gems "somegem 1.0.0"
+ expect(the_bundle).to include_gems "activesupport 1.2.3"
end
it "prints API output properly with back deps" do
@@ -348,7 +350,7 @@ describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint_extra_missing"
- should_be_installed "back_deps 1.0"
+ expect(the_bundle).to include_gems "back_deps 1.0"
end
it "uses the endpoint if all sources support it" do
@@ -359,7 +361,7 @@ describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint_api_missing"
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "fetches again when more dependencies are found in subsequent sources using --deployment" do
@@ -379,7 +381,7 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint_extra"
bundle "install --deployment", :artifice => "endpoint_extra"
- should_be_installed "back_deps 1.0"
+ expect(the_bundle).to include_gems "back_deps 1.0"
end
it "does not refetch if the only unmet dependency is bundler" do
@@ -402,7 +404,7 @@ describe "gemcutter's dependency API" do
gem "rails"
G
bundle :install, :artifice => "endpoint"
- should_be_installed "rails 2.3.2"
+ expect(the_bundle).to include_gems "rails 2.3.2"
end
it "installs the binstubs" do
@@ -479,7 +481,7 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint_basic_authentication"
expect(out).not_to include("#{user}:#{password}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "strips http basic authentication creds for modern index" do
@@ -490,7 +492,7 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endopint_marshal_fail_basic_authentication"
expect(out).not_to include("#{user}:#{password}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "strips http basic auth creds when it can't reach the server" do
@@ -513,7 +515,7 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint_basic_authentication"
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).not_to include("#{user}:#{password}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "does not pass the user / password to different hosts on redirect" do
@@ -523,7 +525,7 @@ describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint_creds_diff_host"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
describe "with authentication details in bundle config" do
@@ -540,7 +542,7 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint_strict_basic_authentication"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "reads authentication details by full url from bundle config" do
@@ -550,14 +552,14 @@ describe "gemcutter's dependency API" do
bundle :install, :artifice => "endpoint_strict_basic_authentication"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "should use the API" do
bundle "config #{source_hostname} #{user}:#{password}"
bundle :install, :artifice => "endpoint_strict_basic_authentication"
expect(out).to include("Fetching gem metadata from #{source_uri}")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "prefers auth supplied in the source uri" do
@@ -569,7 +571,7 @@ describe "gemcutter's dependency API" do
bundle "config #{source_hostname} otheruser:wrong"
bundle :install, :artifice => "endpoint_strict_basic_authentication"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "shows instructions if auth is not provided for the source" do
@@ -595,7 +597,7 @@ describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint_basic_authentication"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
end
diff --git a/spec/install/gems/env_spec.rb b/spec/install/gems/env_spec.rb
index 072e698d8a..d7d3a3230e 100644
--- a/spec/install/gems/env_spec.rb
+++ b/spec/install/gems/env_spec.rb
@@ -15,13 +15,13 @@ describe "bundle install with ENV conditionals" do
it "excludes the gems when the ENV variable is not set" do
bundle :install
- should_not_be_installed "rack"
+ expect(the_bundle).not_to include_gems "rack"
end
it "includes the gems when the ENV variable is set" do
ENV["BUNDLER_TEST"] = "1"
bundle :install
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
@@ -38,13 +38,13 @@ describe "bundle install with ENV conditionals" do
it "excludes the gems when the ENV variable is not set" do
bundle :install
- should_not_be_installed "rack"
+ expect(the_bundle).not_to include_gems "rack"
end
it "includes the gems when the ENV variable is set" do
ENV["BUNDLER_TEST"] = "1"
bundle :install
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
@@ -61,19 +61,19 @@ describe "bundle install with ENV conditionals" do
it "excludes the gems when the ENV variable is not set" do
bundle :install
- should_not_be_installed "rack"
+ expect(the_bundle).not_to include_gems "rack"
end
it "excludes the gems when the ENV variable is set but does not match the condition" do
ENV["BUNDLER_TEST"] = "1"
bundle :install
- should_not_be_installed "rack"
+ expect(the_bundle).not_to include_gems "rack"
end
it "includes the gems when the ENV variable is set and matches the condition" do
ENV["BUNDLER_TEST"] = "foo"
bundle :install
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
@@ -90,19 +90,19 @@ describe "bundle install with ENV conditionals" do
it "excludes the gems when the ENV variable is not set" do
bundle :install
- should_not_be_installed "rack"
+ expect(the_bundle).not_to include_gems "rack"
end
it "excludes the gems when the ENV variable is set but does not match the condition" do
ENV["BUNDLER_TEST"] = "fo"
bundle :install
- should_not_be_installed "rack"
+ expect(the_bundle).not_to include_gems "rack"
end
it "includes the gems when the ENV variable is set and matches the condition" do
ENV["BUNDLER_TEST"] = "foobar"
bundle :install
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
end
diff --git a/spec/install/gems/flex_spec.rb b/spec/install/gems/flex_spec.rb
index 452cadf35e..2f900893cd 100644
--- a/spec/install/gems/flex_spec.rb
+++ b/spec/install/gems/flex_spec.rb
@@ -8,8 +8,8 @@ describe "bundle flex_install" do
gem 'rack'
G
- should_be_installed "rack 1.0.0"
- should_be_locked
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ expect(the_bundle).to be_locked
end
it "installs even when the lockfile is invalid" do
@@ -18,8 +18,8 @@ describe "bundle flex_install" do
gem 'rack'
G
- should_be_installed "rack 1.0.0"
- should_be_locked
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ expect(the_bundle).to be_locked
gemfile <<-G
source "file://#{gem_repo1}"
@@ -27,8 +27,8 @@ describe "bundle flex_install" do
G
bundle :install
- should_be_installed "rack 1.0.0"
- should_be_locked
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ expect(the_bundle).to be_locked
end
it "keeps child dependencies at the same version" do
@@ -39,7 +39,7 @@ describe "bundle flex_install" do
gem "rack-obama"
G
- should_be_installed "rack 1.0.0", "rack-obama 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0.0"
update_repo2
install_gemfile <<-G
@@ -47,7 +47,7 @@ describe "bundle flex_install" do
gem "rack-obama", "1.0"
G
- should_be_installed "rack 1.0.0", "rack-obama 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0.0"
end
describe "adding new gems" do
@@ -67,7 +67,7 @@ describe "bundle flex_install" do
gem 'activesupport', '2.3.5'
G
- should_be_installed "rack 1.0.0", "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.5"
end
it "keeps child dependencies pinned" do
@@ -86,7 +86,7 @@ describe "bundle flex_install" do
gem "thin"
G
- should_be_installed "rack 1.0.0", "rack-obama 1.0", "thin 1.0"
+ expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0", "thin 1.0"
end
end
@@ -106,8 +106,8 @@ describe "bundle flex_install" do
gem 'rack'
G
- should_be_installed "rack 1.0.0"
- should_not_be_installed "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5"
install_gemfile <<-G
source "file://#{gem_repo2}"
@@ -115,7 +115,7 @@ describe "bundle flex_install" do
gem 'activesupport', '2.3.2'
G
- should_be_installed "rack 1.0.0", "activesupport 2.3.2"
+ expect(the_bundle).to include_gems "rack 1.0.0", "activesupport 2.3.2"
end
it "removes top level dependencies when removed from the Gemfile while leaving other dependencies intact" do
@@ -133,7 +133,7 @@ describe "bundle flex_install" do
gem 'rack'
G
- should_not_be_installed "activesupport 2.3.5"
+ expect(the_bundle).not_to include_gems "activesupport 2.3.5"
end
it "removes child dependencies" do
@@ -144,7 +144,7 @@ describe "bundle flex_install" do
gem 'activesupport'
G
- should_be_installed "rack 1.0.0", "rack-obama 1.0.0", "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "rack 1.0.0", "rack-obama 1.0.0", "activesupport 2.3.5"
update_repo2
install_gemfile <<-G
@@ -152,8 +152,8 @@ describe "bundle flex_install" do
gem 'activesupport'
G
- should_be_installed "activesupport 2.3.5"
- should_not_be_installed "rack-obama", "rack"
+ expect(the_bundle).to include_gems "activesupport 2.3.5"
+ expect(the_bundle).not_to include_gems "rack-obama", "rack"
end
end
@@ -165,7 +165,7 @@ describe "bundle flex_install" do
gem "rack_middleware"
G
- should_be_installed "rack_middleware 1.0", "rack 0.9.1"
+ expect(the_bundle).to include_gems "rack_middleware 1.0", "rack 0.9.1"
build_repo2
update_repo2 do
@@ -186,7 +186,7 @@ describe "bundle flex_install" do
it "does not install gems whose dependencies are not met" do
bundle :install
- ruby <<-RUBY, :expect_err => true
+ ruby <<-RUBY
require 'bundler/setup'
RUBY
expect(err).to match(/could not find gem 'rack-obama/i)
diff --git a/spec/install/gems/mirror_spec.rb b/spec/install/gems/mirror_spec.rb
index 8540778d5c..e7b4317f05 100644
--- a/spec/install/gems/mirror_spec.rb
+++ b/spec/install/gems/mirror_spec.rb
@@ -15,7 +15,7 @@ describe "bundle install with a mirror configured" do
it "installs from the normal location" do
bundle :install
expect(out).to include("Fetching source index from file:#{gem_repo1}")
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
@@ -34,7 +34,7 @@ describe "bundle install with a mirror configured" do
bundle :install
expect(out).to include("Fetching source index from file:#{gem_repo1}")
expect(out).not_to include("Fetching source index from file:#{gem_repo2}")
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
end
diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb
index a3ff7394d5..816799c0f8 100644
--- a/spec/install/gems/resolving_spec.rb
+++ b/spec/install/gems/resolving_spec.rb
@@ -36,7 +36,7 @@ describe "bundle install with install-time dependencies" do
gem "actionpack", "2.3.2"
G
- should_be_installed "actionpack 2.3.2", "activesupport 2.3.2"
+ expect(the_bundle).to include_gems "actionpack 2.3.2", "activesupport 2.3.2"
end
describe "with crazy rubygem plugin stuff" do
@@ -46,7 +46,7 @@ describe "bundle install with install-time dependencies" do
gem "net_b"
G
- should_be_installed "net_b 1.0"
+ expect(the_bundle).to include_gems "net_b 1.0"
end
it "installs plugins depended on by other plugins" do
@@ -55,7 +55,7 @@ describe "bundle install with install-time dependencies" do
gem "net_a"
G
- should_be_installed "net_a 1.0", "net_b 1.0"
+ expect(the_bundle).to include_gems "net_a 1.0", "net_b 1.0"
end
it "installs multiple levels of dependencies" do
@@ -65,7 +65,7 @@ describe "bundle install with install-time dependencies" do
gem "net_e"
G
- should_be_installed "net_a 1.0", "net_b 1.0", "net_c 1.0", "net_d 1.0", "net_e 1.0"
+ 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['DEBUG_RESOLVER'] set" do
@@ -76,11 +76,9 @@ describe "bundle install with install-time dependencies" do
gem "net_e"
G
- resolve_output = capture(:stdout) do
- bundle :install, :env => { "DEBUG_RESOLVER" => "1" }
- end
+ bundle :install, :env => { "DEBUG_RESOLVER" => "1" }
- expect(resolve_output).to include("Creating possibility state for net_c")
+ expect(err).to include("Creating possibility state for net_c")
end
end
@@ -92,12 +90,10 @@ describe "bundle install with install-time dependencies" do
gem "net_e"
G
- resolve_output = capture(:stdout) do
- bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1" }
- end
+ bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1" }
- expect(resolve_output).to include(" net_b")
- expect(resolve_output).to include(" net_build_extensions (1.0)")
+ expect(err).to include(" net_b")
+ expect(err).to include(" net_build_extensions (1.0)")
end
end
end
@@ -118,7 +114,7 @@ describe "bundle install with install-time dependencies" do
G
expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
- should_be_installed("rack 1.2")
+ expect(the_bundle).to include_gems("rack 1.2")
end
end
diff --git a/spec/install/gems/standalone_spec.rb b/spec/install/gems/standalone_spec.rb
index 396edb50a7..64e01a7495 100644
--- a/spec/install/gems/standalone_spec.rb
+++ b/spec/install/gems/standalone_spec.rb
@@ -5,7 +5,7 @@ shared_examples "bundle install --standalone" do
shared_examples "common functionality" do
it "still makes the gems available to normal bundler" do
args = expected_gems.map {|k, v| "#{k} #{v}" }
- should_be_installed(*args)
+ expect(the_bundle).to include_gems(*args)
end
it "generates a bundle/bundler/setup.rb" do
@@ -198,7 +198,7 @@ shared_examples "bundle install --standalone" do
bundle "install --standalone --path path/to/bundle"
Dir.chdir(bundled_app) do
- ruby <<-RUBY, :no_lib => true, :expect_err => false
+ ruby <<-RUBY, :no_lib => true
$:.unshift File.expand_path("path/to/bundle")
require "bundler/setup"
diff --git a/spec/install/gems/sudo_spec.rb b/spec/install/gems/sudo_spec.rb
index e102d2da96..66b9901831 100644
--- a/spec/install/gems/sudo_spec.rb
+++ b/spec/install/gems/sudo_spec.rb
@@ -18,7 +18,7 @@ describe "when using sudo", :sudo => true do
expect(out).to_not match(/an error occurred/i)
expect(system_gem_path("cache/rack-1.0.0.gem")).to exist
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
end
@@ -37,7 +37,7 @@ describe "when using sudo", :sudo => true do
expect(system_gem_path("gems/rack-1.0.0")).to exist
expect(system_gem_path("gems/rack-1.0.0").stat.uid).to eq(0)
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "installs rake and a gem dependent on rake in the same session" do
@@ -63,7 +63,7 @@ describe "when using sudo", :sudo => true do
expect(bundle_path.join("gems/rack-1.0.0")).to exist
expect(bundle_path.join("gems/rack-1.0.0").stat.uid).to eq(0)
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "installs when BUNDLE_PATH does not exist" do
@@ -80,7 +80,7 @@ describe "when using sudo", :sudo => true do
expect(bundle_path.join("gems/rack-1.0.0")).to exist
expect(bundle_path.join("gems/rack-1.0.0").stat.uid).to eq(0)
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "installs extensions/ compiled by Rubygems 2.2", :rubygems => "2.2" do
@@ -107,7 +107,7 @@ describe "when using sudo", :sudo => true do
G
expect(default_bundle_path("gems/rack-1.0.0")).to exist
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
it "cleans up the tmpdirs generated" do
@@ -139,7 +139,7 @@ describe "when using sudo", :sudo => true do
bundle :install, :env => { "GEM_HOME" => gem_home.to_s, "GEM_PATH" => nil }
expect(gem_home.join("bin/rackup")).to exist
- should_be_installed "rack 1.0", :env => { "GEM_HOME" => gem_home.to_s, "GEM_PATH" => nil }
+ expect(the_bundle).to include_gems "rack 1.0", :env => { "GEM_HOME" => gem_home.to_s, "GEM_PATH" => nil }
end
end
diff --git a/spec/install/gemspecs_spec.rb b/spec/install/gemspecs_spec.rb
index 58e086b4b2..3e6021b7e2 100644
--- a/spec/install/gemspecs_spec.rb
+++ b/spec/install/gemspecs_spec.rb
@@ -44,7 +44,7 @@ describe "bundle install" do
f.write spec.to_ruby
end
bundle :install, :artifice => "endpoint_marshal_fail" # force gemspec load
- should_be_installed "activesupport 2.3.2"
+ expect(the_bundle).to include_gems "activesupport 2.3.2"
end
context "when ruby version is specified in gemspec and gemfile" do
@@ -57,7 +57,7 @@ describe "bundle install" do
ruby '#{RUBY_VERSION}', :engine_version => '#{RUBY_VERSION}', :engine => 'ruby'
gemspec
G
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "installs when patch level is specified and the version still matches the current version",
@@ -70,7 +70,7 @@ describe "bundle install" do
ruby '#{RUBY_VERSION}', :engine_version => '#{RUBY_VERSION}', :engine => 'ruby', :patchlevel => '#{RUBY_PATCHLEVEL}'
gemspec
G
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "fails and complains about patchlevel on patchlevel mismatch",
diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb
index 401da1b1d3..f35a543509 100644
--- a/spec/install/git_spec.rb
+++ b/spec/install/git_spec.rb
@@ -12,7 +12,7 @@ describe "bundle install" do
bundle :install
expect(out).to include("Using foo 1.0 from #{lib_path("foo")} (at master@#{revision_for(lib_path("foo"))[0..6]})")
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}"
end
it "should check out git repos that are missing but not being installed" do
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index 4076eec22a..3d84fffd58 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -16,7 +16,7 @@ describe "bundle install" do
it "does not use available system gems with bundle --path vendor/bundle" do
bundle "install --path vendor/bundle"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "handles paths with regex characters in them" do
@@ -48,7 +48,7 @@ describe "bundle install" do
bundle "install"
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -79,7 +79,7 @@ describe "bundle install" do
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
expect(bundled_app("vendor2")).not_to be_directory
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "installs gems to BUNDLE_PATH with #{type}" do
@@ -88,7 +88,7 @@ describe "bundle install" do
bundle :install
expect(bundled_app("vendor/gems/rack-1.0.0")).to be_directory
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "installs gems to BUNDLE_PATH relative to root when relative" do
@@ -100,7 +100,7 @@ describe "bundle install" do
end
expect(bundled_app("vendor/gems/rack-1.0.0")).to be_directory
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -110,14 +110,14 @@ describe "bundle install" do
bundle :install
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "sets BUNDLE_PATH as the first argument to bundle install" do
bundle "install --path ./vendor/bundle"
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "disables system gems when passing a path to install" do
@@ -126,7 +126,7 @@ describe "bundle install" do
bundle "install --path ./vendor/bundle"
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
diff --git a/spec/install/prereleases_spec.rb b/spec/install/prereleases_spec.rb
index 61676f5dfa..cbf99ca96f 100644
--- a/spec/install/prereleases_spec.rb
+++ b/spec/install/prereleases_spec.rb
@@ -8,7 +8,7 @@ describe "bundle install" do
source "file://#{gem_repo1}"
gem "not_released"
G
- should_be_installed "not_released 1.0.pre"
+ expect(the_bundle).to include_gems "not_released 1.0.pre"
end
it "uses regular releases if available" do
@@ -16,7 +16,7 @@ describe "bundle install" do
source "file://#{gem_repo1}"
gem "has_prerelease"
G
- should_be_installed "has_prerelease 1.0"
+ expect(the_bundle).to include_gems "has_prerelease 1.0"
end
it "uses prereleases if requested" do
@@ -24,7 +24,7 @@ describe "bundle install" do
source "file://#{gem_repo1}"
gem "has_prerelease", "1.1.pre"
G
- should_be_installed "has_prerelease 1.1.pre"
+ expect(the_bundle).to include_gems "has_prerelease 1.1.pre"
end
end
@@ -36,7 +36,7 @@ describe "bundle install" do
gem "rack"
G
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end
end
diff --git a/spec/install/security_policy_spec.rb b/spec/install/security_policy_spec.rb
index 08a9213e00..7e2c320b80 100644
--- a/spec/install/security_policy_spec.rb
+++ b/spec/install/security_policy_spec.rb
@@ -19,7 +19,7 @@ describe "policies with unsigned gems" do
bundle "install --deployment"
bundle :install
expect(exitstatus).to eq(0) if exitstatus
- should_be_installed "rack 1.0", "signed_gem 1.0"
+ expect(the_bundle).to include_gems "rack 1.0", "signed_gem 1.0"
end
it "will fail when given invalid security policy" do
@@ -66,12 +66,12 @@ describe "policies with signed gems and no CA" do
it "will succeed with Low Security setting, low security accepts self signed gem" do
bundle "install --trust-policy=LowSecurity"
expect(exitstatus).to eq(0) if exitstatus
- should_be_installed "signed_gem 1.0"
+ expect(the_bundle).to include_gems "signed_gem 1.0"
end
it "will succeed with no policy" do
bundle "install"
expect(exitstatus).to eq(0) if exitstatus
- should_be_installed "signed_gem 1.0"
+ expect(the_bundle).to include_gems "signed_gem 1.0"
end
end
diff --git a/spec/install/upgrade_spec.rb b/spec/install/upgrade_spec.rb
deleted file mode 100644
index 852a746322..0000000000
--- a/spec/install/upgrade_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: true
-require "spec_helper"
-
-describe "bundle install for the first time with v1.0" do
- before :each do
- in_app_root
-
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
- end
-
- it "removes lockfiles in 0.9 YAML format" do
- File.open("Gemfile.lock", "w") {|f| YAML.dump({}, f) }
- bundle :install
- expect(File.read("Gemfile.lock")).not_to match(/^---/)
- end
-
- it "removes env.rb if it exists" do
- bundled_app.join(".bundle").mkdir
- bundled_app.join(".bundle/environment.rb").open("w") {|f| f.write("raise 'nooo'") }
- bundle :install
- expect(bundled_app.join(".bundle/environment.rb")).not_to exist
- end
-end
diff --git a/spec/lock/git_spec.rb b/spec/lock/git_spec.rb
index 69937aaba5..93473db052 100644
--- a/spec/lock/git_spec.rb
+++ b/spec/lock/git_spec.rb
@@ -11,7 +11,7 @@ describe "bundle lock with git gems" do
end
it "doesn't break right after running lock" do
- should_be_installed "foo 1.0.0"
+ expect(the_bundle).to include_gems "foo 1.0.0"
end
it "locks a git source to the current ref" do
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb
index 6e0713102a..09a7411e3b 100644
--- a/spec/lock/lockfile_spec.rb
+++ b/spec/lock/lockfile_spec.rb
@@ -413,7 +413,7 @@ describe "the lockfile format" do
#{Bundler::VERSION}
G
- should_be_installed "net-sftp 1.1.1", "net-ssh 1.0.0"
+ expect(the_bundle).to include_gems "net-sftp 1.1.1", "net-ssh 1.0.0"
end
it "generates a simple lockfile for a single pinned source, gem with a version requirement" do
@@ -480,7 +480,7 @@ describe "the lockfile format" do
L
bundle "install"
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "serializes global git sources" do
@@ -1125,7 +1125,7 @@ describe "the lockfile format" do
G
end
- it "captures the Ruby version in the lockfile", :focus do
+ it "captures the Ruby version in the lockfile" do
install_gemfile <<-G
source "file://#{gem_repo1}"
ruby '#{RUBY_VERSION}'
@@ -1168,7 +1168,7 @@ describe "the lockfile format" do
G
bundle "install --path vendor"
- should_be_installed "omg 1.0"
+ expect(the_bundle).to include_gems "omg 1.0"
# Create a Gemfile.lock that has duplicate GIT sections
lockfile <<-L
@@ -1202,7 +1202,7 @@ describe "the lockfile format" do
FileUtils.rm_rf(bundled_app("vendor"))
bundle "install"
- should_be_installed "omg 1.0"
+ expect(the_bundle).to include_gems "omg 1.0"
# Confirm that duplicate specs do not appear
expect(File.read(bundled_app("Gemfile.lock"))).to eq(strip_whitespace(<<-L))
@@ -1245,7 +1245,7 @@ describe "the lockfile format" do
it "generates Gemfile.lock with \\n line endings" do
expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n")
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
context "during updates" do
@@ -1254,7 +1254,7 @@ describe "the lockfile format" do
expect { bundle "update" }.to change { File.mtime(bundled_app("Gemfile.lock")) }
expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n")
- should_be_installed "rack 1.2"
+ expect(the_bundle).to include_gems "rack 1.2"
end
it "preserves Gemfile.lock \\n\\r line endings" do
@@ -1265,7 +1265,7 @@ describe "the lockfile format" do
expect { bundle "update" }.to change { File.mtime(bundled_app("Gemfile.lock")) }
expect(File.read(bundled_app("Gemfile.lock"))).to match("\r\n")
- should_be_installed "rack 1.2"
+ expect(the_bundle).to include_gems "rack 1.2"
end
end
@@ -1317,7 +1317,7 @@ describe "the lockfile format" do
#{Bundler::VERSION}
L
- error = install_gemfile(<<-G, :expect_err => true)
+ error = install_gemfile(<<-G)
source "file://#{gem_repo1}"
gem "rack"
G
diff --git a/spec/other/bundle_ruby_spec.rb b/spec/other/bundle_ruby_spec.rb
index 9847aded62..4b2ebf4cfd 100644
--- a/spec/other/bundle_ruby_spec.rb
+++ b/spec/other/bundle_ruby_spec.rb
@@ -11,7 +11,7 @@ describe "bundle_ruby" do
gem "foo"
G
- bundle_ruby :expect_err => true
+ bundle_ruby
expect(out).to include("ruby 1.9.3")
end
@@ -24,7 +24,7 @@ describe "bundle_ruby" do
gem "foo"
G
- bundle_ruby :expect_err => true
+ bundle_ruby
expect(out).to include("ruby 1.9.3")
end
@@ -37,7 +37,7 @@ describe "bundle_ruby" do
gem "foo"
G
- bundle_ruby :expect_err => true
+ bundle_ruby
expect(out).to include("ruby 1.8.7 (jruby 1.6.5)")
end
@@ -50,7 +50,7 @@ describe "bundle_ruby" do
gem "foo"
G
- bundle_ruby :expect_err => true
+ bundle_ruby
expect(out).to include("ruby 1.8.7 (rbx 1.2.4)")
end
@@ -63,10 +63,10 @@ describe "bundle_ruby" do
gem "foo"
G
- bundle_ruby :expect_err => true, :exitstatus => true
+ bundle_ruby
expect(exitstatus).not_to eq(0) if exitstatus
- bundle_ruby :expect_err => true
+ bundle_ruby
expect(out).to include("Please define :engine_version")
end
@@ -78,10 +78,10 @@ describe "bundle_ruby" do
gem "foo"
G
- bundle_ruby :expect_err => true, :exitstatus => true
+ bundle_ruby
expect(exitstatus).not_to eq(0) if exitstatus
- bundle_ruby :expect_err => true
+ bundle_ruby
expect(out).to include("Please define :engine")
end
@@ -93,10 +93,10 @@ describe "bundle_ruby" do
gem "foo"
G
- bundle_ruby :expect_err => true, :exitstatus => true
+ bundle_ruby
expect(exitstatus).not_to eq(0) if exitstatus
- bundle_ruby :expect_err => true
+ bundle_ruby
expect(out).to include("ruby_version must match the :engine_version for MRI")
end
@@ -107,7 +107,7 @@ describe "bundle_ruby" do
gem "foo"
G
- bundle_ruby :expect_err => true
+ bundle_ruby
expect(out).to include("No ruby version specified")
end
@@ -122,7 +122,7 @@ describe "bundle_ruby" do
gem "foo"
G
- bundle_ruby :expect_err => true
+ bundle_ruby
expect(out).to include("ruby 1.9.3p429")
end
@@ -135,7 +135,7 @@ describe "bundle_ruby" do
gem "foo"
G
- bundle_ruby :expect_err => true
+ bundle_ruby
expect(out).to include("ruby 1.9.3p392 (jruby 1.7.4)")
end
diff --git a/spec/other/ext_spec.rb b/spec/other/ext_spec.rb
index 5508ef8b74..7e2e712827 100644
--- a/spec/other/ext_spec.rb
+++ b/spec/other/ext_spec.rb
@@ -58,12 +58,12 @@ describe "Gem::SourceIndex#refresh!" do
end
it "does not explode when called", :if => rubygems_1_7 do
- run "Gem.source_index.refresh!", :expect_err => true
- run "Gem::SourceIndex.new([]).refresh!", :expect_err => true
+ run "Gem.source_index.refresh!"
+ run "Gem::SourceIndex.new([]).refresh!"
end
it "does not explode when called", :unless => rubygems_1_7 do
- run "Gem.source_index.refresh!", :expect_err => true
- run "Gem::SourceIndex.from_gems_in([]).refresh!", :expect_err => true
+ run "Gem.source_index.refresh!"
+ run "Gem::SourceIndex.from_gems_in([]).refresh!"
end
end
diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb
index c2d1cdbeb5..c8a2633279 100644
--- a/spec/other/major_deprecation_spec.rb
+++ b/spec/other/major_deprecation_spec.rb
@@ -16,7 +16,7 @@ describe "major deprecations" do
describe "bundle_ruby" do
it "prints a deprecation" do
- bundle_ruby :expect_err => true
+ bundle_ruby
out.gsub! "\nruby #{RUBY_VERSION}", ""
expect(warnings).to have_major_deprecation "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`"
end
@@ -31,6 +31,14 @@ describe "major deprecations" do
end
end
+ describe ".environment" do
+ it "is deprecated in favor of .load" do
+ source = "Bundler.environment"
+ bundle "exec ruby -e #{source.dump}"
+ expect(warnings).to have_major_deprecation "Bundler.environment has been removed in favor of Bundler.load"
+ end
+ end
+
shared_examples_for "environmental deprecations" do |trigger|
describe "ruby version", :ruby => "< 2.0" do
it "requires a newer ruby version" do
@@ -107,7 +115,8 @@ describe "major deprecations" do
G
expect(warnings).to have_major_deprecation a_string_including(
- "flags passed to commands will no longer be automatically remembered.")
+ "flags passed to commands will no longer be automatically remembered."
+ )
end
end
end
@@ -135,7 +144,7 @@ describe "major deprecations" do
context "when `bundler/deployment` is required in a ruby script" do
it "should print a capistrano deprecation warning" do
- ruby(<<-RUBY, :expect_err => true)
+ ruby(<<-RUBY)
require 'bundler/deployment'
RUBY
diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb
index c0d121c7b1..7aa0d0f8ea 100644
--- a/spec/other/platform_spec.rb
+++ b/spec/other/platform_spec.rb
@@ -494,7 +494,7 @@ G
end
bundle "update"
- should_be_installed "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
+ expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
it "updates fine with any engine" do
@@ -511,7 +511,7 @@ G
end
bundle "update"
- should_be_installed "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
+ expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
end
diff --git a/spec/other/trampoline_spec.rb b/spec/other/trampoline_spec.rb
index 2be0c9c3e9..2aac0a2c1d 100644
--- a/spec/other/trampoline_spec.rb
+++ b/spec/other/trampoline_spec.rb
@@ -4,6 +4,7 @@ require "spec_helper"
describe "bundler version trampolining" do
before do
ENV["BUNDLE_DISABLE_POSTIT"] = nil
+ ENV["BUNDLE_ENABLE_TRAMPOLINE"] = "true"
FileUtils.rm_rf(system_gem_path)
FileUtils.cp_r(base_system_gems, system_gem_path)
end
@@ -81,13 +82,28 @@ describe "bundler version trampolining" do
it "fails gracefully when installing the bundler fails" do
ENV["BUNDLER_VERSION"] = "9999"
- bundle "--version", :expect_err => true
+ bundle "--version"
expect(err).to start_with(<<-E.strip)
+Installing locked Bundler version 9999...
Installing the inferred bundler version (= 9999) failed.
If you'd like to update to the current bundler version (#{Bundler::VERSION}) in this project, run `bundle update --bundler`.
The error was:
E
end
+
+ it "displays installing message before install is started" do
+ expect(system_gem_path.join("gems", "bundler-1.12.3")).not_to exist
+ bundle! "--version"
+ expect(err).to include("Installing locked Bundler version #{ENV["BUNDLER_VERSION"]}...")
+ end
+
+ it "doesn't display installing message if locked version is installed" do
+ expect(system_gem_path.join("gems", "bundler-1.12.3")).not_to exist
+ bundle! "--version"
+ expect(system_gem_path.join("gems", "bundler-1.12.3")).to exist
+ bundle! "--version"
+ expect(err).not_to include("Installing locked Bundler version = #{ENV["BUNDLER_VERSION"]}...")
+ end
end
context "bundle update --bundler" do
@@ -99,7 +115,7 @@ The error was:
it "updates to the specified version" do
# HACK: since no released bundler version actually supports this feature!
- bundle "update --bundler=1.12.0", :expect_err => true
+ bundle "update --bundler=1.12.0"
expect(out).to include("Unknown switches '--bundler=1.12.0'")
end
@@ -150,4 +166,11 @@ You're running Bundler #{Bundler::VERSION} but this project uses #{ENV["BUNDLER_
WARN
end
end
+
+ context "with --verbose" do
+ it "prints the running command" do
+ bundle! "config", :verbose => true, :env => { "BUNDLE_POSTIT_TRAMPOLINING_VERSION" => Bundler::VERSION }
+ expect(out).to start_with("Running `bundle config --verbose` with bundler #{Bundler::VERSION}")
+ end
+ end
end
diff --git a/spec/plugins/install_spec.rb b/spec/plugins/install_spec.rb
index eaf6427577..c667ed0a68 100644
--- a/spec/plugins/install_spec.rb
+++ b/spec/plugins/install_spec.rb
@@ -127,7 +127,7 @@ describe "bundler plugin install" do
expect(out).to include("Bundle complete!")
- should_be_installed("rack 1.0.0")
+ expect(the_bundle).to include_gems("rack 1.0.0")
plugin_should_be_installed("foo")
end
diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb
index ead24e0d37..520e1b9db4 100644
--- a/spec/plugins/source/example_spec.rb
+++ b/spec/plugins/source/example_spec.rb
@@ -61,7 +61,7 @@ describe "real source plugins" do
expect(out).to include("Bundle complete!")
- should_be_installed("a-path-gem 1.0")
+ expect(the_bundle).to include_gems("a-path-gem 1.0")
end
it "writes to lock file" do
@@ -124,7 +124,7 @@ describe "real source plugins" do
expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}/.bundlecache")).to be_file
FileUtils.rm_rf lib_path("a-path-gem-1.0")
- should_be_installed("a-path-gem 1.0")
+ expect(the_bundle).to include_gems("a-path-gem 1.0")
end
it "copies repository to vendor cache and uses it even when installed with bundle --path" do
@@ -134,7 +134,7 @@ describe "real source plugins" do
expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
FileUtils.rm_rf lib_path("a-path-gem-1.0")
- should_be_installed("a-path-gem 1.0")
+ expect(the_bundle).to include_gems("a-path-gem 1.0")
end
it "bundler package copies repository to vendor cache" do
@@ -144,7 +144,7 @@ describe "real source plugins" do
expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
FileUtils.rm_rf lib_path("a-path-gem-1.0")
- should_be_installed("a-path-gem 1.0")
+ expect(the_bundle).to include_gems("a-path-gem 1.0")
end
end
@@ -175,7 +175,7 @@ describe "real source plugins" do
it "installs" do
bundle "install"
- should_be_installed("a-path-gem 1.0")
+ expect(the_bundle).to include_gems("a-path-gem 1.0")
end
end
end
@@ -324,7 +324,7 @@ describe "real source plugins" do
it "handles the source option" do
bundle "install"
expect(out).to include("Bundle complete!")
- should_be_installed("ma-gitp-gem 1.0")
+ expect(the_bundle).to include_gems("ma-gitp-gem 1.0")
end
it "writes to lock file" do
@@ -382,7 +382,7 @@ describe "real source plugins" do
it "installs" do
bundle "install"
- should_be_installed("ma-gitp-gem 1.0")
+ expect(the_bundle).to include_gems("ma-gitp-gem 1.0")
end
it "uses the locked ref" do
@@ -417,7 +417,7 @@ describe "real source plugins" do
G
bundle "install"
- should_be_installed("ma-gitp-gem 1.1")
+ expect(the_bundle).to include_gems("ma-gitp-gem 1.1")
end
end
@@ -439,7 +439,7 @@ describe "real source plugins" do
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file
FileUtils.rm_rf lib_path("foo-1.0")
- should_be_installed "foo 1.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
end
end
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index 41f7d58425..5f73228b4a 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -77,10 +77,19 @@ describe "The library itself" do
def check_for_expendable_words(filename)
failing_line_message = []
- useless_words = /\b(actually|obviously|just|clearly|basically|really)\b/i
+ useless_words = %w(
+ actually
+ basically
+ clearly
+ just
+ obviously
+ really
+ simply
+ )
+ pattern = /\b#{Regexp.union(useless_words)}\b/i
File.readlines(filename).each_with_index do |line, number|
- next unless word_found = useless_words.match(line)
+ next unless word_found = pattern.match(line)
failing_line_message << "#{filename} has '#{word_found}' on line #{number + 1}. Avoid using these kinds of weak modifiers."
end
@@ -184,11 +193,17 @@ describe "The library itself" do
it "can still be built" do
Dir.chdir(root) do
- `gem build bundler.gemspec`
- expect($?).to eq(0)
-
- # clean up the .gem generated
- system("rm bundler-#{Bundler::VERSION}.gem")
+ begin
+ gem_command! :build, "bundler.gemspec"
+ if Bundler.rubygems.provides?(">= 2.4")
+ # older rubygems have weird warnings, and we won't actually be using them
+ # to build the gem for releases anyways
+ expect(err).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
+ end
+ ensure
+ # clean up the .gem generated
+ FileUtils.rm("bundler-#{Bundler::VERSION}.gem")
+ end
end
end
@@ -202,7 +217,7 @@ describe "The library itself" do
lib_files = `git ls-files -z`.split("\x0").grep(/\.rb$/) - exclusions
lib_files.reject! {|f| f.start_with?("bundler/vendor") }
lib_files.map! {|f| f.chomp(".rb") }
- sys_exec("ruby -w -I. ", :expect_err) do |input, _, _|
+ sys_exec!("ruby -w -I.") do |input, _, _|
lib_files.each do |f|
input.puts "require '#{f}'"
end
diff --git a/spec/realworld/dependency_api_spec.rb b/spec/realworld/dependency_api_spec.rb
index c77036fc5f..9823cf8c76 100644
--- a/spec/realworld/dependency_api_spec.rb
+++ b/spec/realworld/dependency_api_spec.rb
@@ -16,7 +16,8 @@ describe "gemcutter's dependency API", :realworld => true do
:Host => "0.0.0.0",
:Port => port,
:server => "webrick",
- :AccessLog => [])
+ :AccessLog => [],
+ :Logger => Spec::SilentLogger.new)
server.start
end
@t.run
@@ -41,7 +42,7 @@ describe "gemcutter's dependency API", :realworld => true do
bundle :install
expect(out).to include("Fetching source index from #{@server_uri}/")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
end
diff --git a/spec/realworld/edgecases_spec.rb b/spec/realworld/edgecases_spec.rb
index 5c6835ed39..7a78a114b4 100644
--- a/spec/realworld/edgecases_spec.rb
+++ b/spec/realworld/edgecases_spec.rb
@@ -49,7 +49,7 @@ describe "real world edgecases", :realworld => true, :sometimes => true do
gem 'rack-cache', '1.2.0' # last version that works on Ruby 1.9
G
bundle :lock
- expect(lockfile).to include("rails (3.2.22.2)")
+ expect(lockfile).to include("rails (3.2.22.4)")
expect(lockfile).to include("capybara (2.2.1)")
end
@@ -89,7 +89,7 @@ describe "real world edgecases", :realworld => true, :sometimes => true do
gem 'rack', '1.0.1'
G
- bundle "install --path vendor/bundle", :expect_err => true
+ bundle "install --path vendor/bundle"
expect(err).not_to include("Could not find rake")
expect(err).to lack_errors
end
diff --git a/spec/realworld/gemfile_source_header_spec.rb b/spec/realworld/gemfile_source_header_spec.rb
index be8f45c81b..1c39fe97bb 100644
--- a/spec/realworld/gemfile_source_header_spec.rb
+++ b/spec/realworld/gemfile_source_header_spec.rb
@@ -26,7 +26,7 @@ describe "fetching dependencies with a mirrored source", :realworld => true, :ru
expect(out).to include("Installing weakling")
expect(out).to include("Bundle complete")
- should_be_installed "weakling 0.0.3"
+ expect(the_bundle).to include_gems "weakling 0.0.3"
end
private
@@ -43,7 +43,8 @@ describe "fetching dependencies with a mirrored source", :realworld => true, :ru
:Host => "0.0.0.0",
:Port => @port,
:server => "webrick",
- :AccessLog => [])
+ :AccessLog => [],
+ :Logger => Spec::SilentLogger.new)
end.run
wait_for_server("127.0.0.1", @port)
diff --git a/spec/realworld/mirror_probe_spec.rb b/spec/realworld/mirror_probe_spec.rb
index 981c4b8442..bb2be7f232 100644
--- a/spec/realworld/mirror_probe_spec.rb
+++ b/spec/realworld/mirror_probe_spec.rb
@@ -35,7 +35,7 @@ describe "fetching dependencies with a not available mirror", :realworld => true
expect(out).to include("Installing weakling")
expect(out).to include("Bundle complete")
- should_be_installed "weakling 0.0.3"
+ expect(the_bundle).to include_gems "weakling 0.0.3"
end
end
@@ -55,7 +55,7 @@ describe "fetching dependencies with a not available mirror", :realworld => true
expect(out).to include("Installing weakling")
expect(out).to include("Bundle complete")
- should_be_installed "weakling 0.0.3"
+ expect(the_bundle).to include_gems "weakling 0.0.3"
end
end
@@ -112,7 +112,8 @@ describe "fetching dependencies with a not available mirror", :realworld => true
:Host => host,
:Port => @server_port,
:server => "webrick",
- :AccessLog => [])
+ :AccessLog => [],
+ :Logger => Spec::SilentLogger.new)
end.run
wait_for_server(host, @server_port)
diff --git a/spec/resolver/basic_spec.rb b/spec/resolver/basic_spec.rb
index 48224ae7af..b7b8b4c3b8 100644
--- a/spec/resolver/basic_spec.rb
+++ b/spec/resolver/basic_spec.rb
@@ -213,7 +213,6 @@ describe "Resolving" do
it "will not revert to a previous version in strict mode level patch" do
pending "possible issue with molinillo - needs further research"
- ENV["DEBUG_RESOLVER"] = "true"
should_conservative_resolve_and_include [:patch, :strict], [], %w(foo-1.4.3 bar-2.1.1)
end
diff --git a/spec/runtime/inline_spec.rb b/spec/runtime/inline_spec.rb
index ccc2aed8be..3119045be4 100644
--- a/spec/runtime/inline_spec.rb
+++ b/spec/runtime/inline_spec.rb
@@ -61,7 +61,7 @@ describe "bundler/inline#gemfile" do
expect(out).to eq("two")
expect(exitstatus).to be_zero if exitstatus
- script <<-RUBY, :expect_err => true
+ script <<-RUBY
gemfile do
path "#{lib_path}"
gem "eleven"
@@ -114,7 +114,7 @@ describe "bundler/inline#gemfile" do
end
it "raises an exception if passed unknown arguments" do
- script <<-RUBY, :expect_err => true
+ script <<-RUBY
gemfile(true, :arglebargle => true) do
path "#{lib_path}"
gem "two"
diff --git a/spec/runtime/platform_spec.rb b/spec/runtime/platform_spec.rb
index db99f3556b..666864a88c 100644
--- a/spec/runtime/platform_spec.rb
+++ b/spec/runtime/platform_spec.rb
@@ -57,7 +57,7 @@ describe "Bundler.setup with multi platform stuff" do
gem "nokogiri"
G
- should_be_installed "nokogiri 1.4.2"
+ expect(the_bundle).to include_gems "nokogiri 1.4.2"
end
it "will add the resolve for the current platform" do
@@ -86,6 +86,6 @@ describe "Bundler.setup with multi platform stuff" do
gem "platform_specific"
G
- should_be_installed "nokogiri 1.4.2", "platform_specific 1.0 x86-darwin-100"
+ expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 x86-darwin-100"
end
end
diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb
index d565be7194..ef88f91282 100644
--- a/spec/runtime/require_spec.rb
+++ b/spec/runtime/require_spec.rb
@@ -133,7 +133,7 @@ describe "Bundler.require" do
gem "faulty"
G
- run "Bundler.require", :expect_err => true
+ run "Bundler.require"
expect(err).to match("error while trying to load the gem 'faulty'")
expect(err).to match("Gem Internal Error Message")
end
@@ -155,7 +155,7 @@ describe "Bundler.require" do
$stderr.puts "ZOMG LOAD ERROR: \#{e.message}"
end
RUBY
- run(cmd, :expect_err => true)
+ run(cmd)
expect(err).to eq_err("ZOMG LOAD ERROR: cannot load such file -- load-bar")
end
@@ -191,7 +191,7 @@ describe "Bundler.require" do
require 'bundler'
Bundler.require
RUBY
- ruby(cmd, :expect_err => true)
+ ruby(cmd)
expect(err).to lack_errors
end
@@ -225,7 +225,7 @@ describe "Bundler.require" do
$stderr.puts "ZOMG LOAD ERROR" if e.message.include?("Could not open library 'libfuuu-1.0'")
end
RUBY
- run(cmd, :expect_err => true)
+ run(cmd)
expect(err).to eq_err("ZOMG LOAD ERROR")
end
@@ -248,7 +248,7 @@ describe "Bundler.require" do
$stderr.puts "ZOMG LOAD ERROR: \#{e.message}"
end
RUBY
- run(cmd, :expect_err => true)
+ run(cmd)
expect(err).to eq_err("ZOMG LOAD ERROR: cannot load such file -- load-bar")
end
@@ -374,7 +374,7 @@ describe "Bundler.require with platform specific dependencies" do
gem "rack", "1.0.0"
G
- run "Bundler.require", :expect_err => true
+ run "Bundler.require"
expect(err).to lack_errors
end
@@ -387,7 +387,7 @@ describe "Bundler.require with platform specific dependencies" do
end
G
- run "Bundler.require; puts RACK", :expect_err => true
+ run "Bundler.require; puts RACK"
expect(out).to eq("1.0.0")
expect(err).to lack_errors
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 18abf0549e..eab66e2ee2 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -93,7 +93,7 @@ describe "Bundler.setup" do
end
it "handles multiple non-additive invocations" do
- ruby <<-RUBY, :expect_err => true
+ ruby <<-RUBY
require 'bundler'
Bundler.setup(:default, :test)
Bundler.setup(:default)
@@ -194,7 +194,7 @@ describe "Bundler.setup" do
gem "rack"
G
- ruby <<-R, :expect_err => true
+ ruby <<-R
require 'rubygems'
require 'bundler'
@@ -218,7 +218,7 @@ describe "Bundler.setup" do
gem "nosuchgem", "10.0"
G
- ruby <<-R, :expect_err => true
+ ruby <<-R
require 'rubygems'
require 'bundler'
@@ -256,7 +256,7 @@ describe "Bundler.setup" do
ENV["BUNDLE_GEMFILE"] = bundled_app("4realz").to_s
bundle :install
- should_be_installed "activesupport 2.3.5"
+ expect(the_bundle).to include_gems "activesupport 2.3.5"
end
it "prioritizes gems in BUNDLE_PATH over gems in GEM_HOME" do
@@ -270,7 +270,7 @@ describe "Bundler.setup" do
s.write "lib/rack.rb", "RACK = 'FAIL'"
end
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
describe "integrate with rubygems" do
@@ -296,7 +296,7 @@ describe "Bundler.setup" do
end
it "version_requirement is now deprecated in rubygems 1.4.0+ when gem is missing" do
- run <<-R, :expect_err => true
+ run <<-R
begin
gem "activesupport"
puts "FAIL"
@@ -322,7 +322,7 @@ describe "Bundler.setup" do
end
it "version_requirement is now deprecated in rubygems 1.4.0+ when the version is wrong" do
- run <<-R, :expect_err => true
+ run <<-R
begin
gem "rack", "1.0.0"
puts "FAIL"
@@ -388,7 +388,7 @@ describe "Bundler.setup" do
end
it "provides a useful exception when the git repo is not checked out yet" do
- run "1", :expect_err => true
+ run "1"
expect(err).to match(/the git source #{lib_path('rack-1.0.0')} is not yet checked out. Please run `bundle install`/i)
end
@@ -431,7 +431,7 @@ describe "Bundler.setup" do
end
R
- run "puts 'FAIL'", :expect_err => true
+ run "puts 'FAIL'"
expect(err).not_to include "This is not the git you are looking for"
end
@@ -439,14 +439,14 @@ describe "Bundler.setup" do
it "works even when the cache directory has been deleted" do
bundle "install --path vendor/bundle"
FileUtils.rm_rf vendored_gems("cache")
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do
bundle "install --path vendor/bundle"
with_read_only("**/*") do
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
@@ -454,7 +454,7 @@ describe "Bundler.setup" do
bundle "install"
with_read_only("#{Bundler.bundle_path}/**/*") do
- should_be_installed "rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
end
end
end
@@ -475,7 +475,7 @@ describe "Bundler.setup" do
expect(out).to match(/at #{lib_path('local-rack')}/)
FileUtils.rm_rf(lib_path("local-rack"))
- run "require 'rack'", :expect_err => true
+ run "require 'rack'"
expect(err).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
end
@@ -498,7 +498,7 @@ describe "Bundler.setup" do
gem "rack", :git => "#{lib_path("rack-0.8")}"
G
- run "require 'rack'", :expect_err => true
+ run "require 'rack'"
expect(err).to match(/because :branch is not specified in Gemfile/)
end
@@ -521,7 +521,7 @@ describe "Bundler.setup" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "changed"
G
- run "require 'rack'", :expect_err => true
+ run "require 'rack'"
expect(err).to match(/is using branch master but Gemfile specifies changed/)
end
@@ -541,7 +541,7 @@ describe "Bundler.setup" do
G
bundle %(config local.rack #{lib_path("local-rack")})
- run "require 'rack'", :expect_err => true
+ run "require 'rack'"
expect(err).to match(/is using branch master but Gemfile specifies nonexistant/)
end
end
@@ -559,7 +559,7 @@ describe "Bundler.setup" do
install_gems "activesupport-2.3.5"
- should_be_installed "activesupport 2.3.2", :groups => :default
+ expect(the_bundle).to include_gems "activesupport 2.3.2", :groups => :default
end
it "remembers --without and does not bail on bare Bundler.setup" do
@@ -574,7 +574,7 @@ describe "Bundler.setup" do
install_gems "activesupport-2.3.5"
- should_be_installed "activesupport 2.3.2"
+ expect(the_bundle).to include_gems "activesupport 2.3.2"
end
it "remembers --without and does not include groups passed to Bundler.setup" do
@@ -591,8 +591,8 @@ describe "Bundler.setup" do
end
G
- should_not_be_installed "activesupport 2.3.2", :groups => :rack
- should_be_installed "rack 1.0.0", :groups => :rack
+ expect(the_bundle).not_to include_gems "activesupport 2.3.2", :groups => :rack
+ expect(the_bundle).to include_gems "rack 1.0.0", :groups => :rack
end
end
@@ -635,7 +635,7 @@ describe "Bundler.setup" do
gem "thin", "1.0"
G
- ruby <<-R, :expect_err => true
+ ruby <<-R
require 'rubygems'
gem "thin"
require 'bundler'
@@ -922,14 +922,17 @@ describe "Bundler.setup" do
end
it "error intelligently if the gemspec has a LoadError" do
- update_git "bar", :gemspec => false do |s|
+ ref = update_git "bar", :gemspec => false do |s|
s.write "bar.gemspec", "require 'foobarbaz'"
- end
+ end.ref_for("HEAD")
bundle :install
- expect(out).to include("was a LoadError while loading bar.gemspec")
- expect(out).to include("foobarbaz")
- expect(out).to include("bar.gemspec:1")
- expect(out).to include("try to require a relative path") if RUBY_VERSION >= "1.9"
+
+ expect(out.lines.map(&:chomp)).to include(
+ a_string_starting_with("[!] There was an error while loading `bar.gemspec`:"),
+ RUBY_VERSION >= "1.9" ? a_string_starting_with("Does it try to require a relative path? That's been removed in Ruby 1.9.") : "",
+ " # from #{default_bundle_path "bundler", "gems", "bar-1.0-#{ref[0, 12]}", "bar.gemspec"}:1",
+ " > require 'foobarbaz'"
+ )
end
it "evals each gemspec with a binding from the top level" do
diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb
index 5ab72ed1ce..752754be39 100644
--- a/spec/runtime/with_clean_env_spec.rb
+++ b/spec/runtime/with_clean_env_spec.rb
@@ -38,7 +38,7 @@ describe "Bundler.with_env helpers" do
RB
path = `getconf PATH`.strip + File::PATH_SEPARATOR + File.dirname(Gem.ruby)
with_path_as(path) do
- bundle!("exec ruby #{bundled_app("exe.rb")} 2", :expect_err => true)
+ bundle!("exec ruby #{bundled_app("exe.rb")} 2")
end
expect(err).to eq <<-EOS.strip
2 false
@@ -78,7 +78,7 @@ describe "Bundler.with_env helpers" do
it "should restore the original MANPATH" do
code = "print Bundler.clean_env['MANPATH']"
ENV["MANPATH"] = "/foo"
- ENV["BUNDLE_ORIG_MANPATH"] = "/foo-original"
+ ENV["BUNDLER_ORIG_MANPATH"] = "/foo-original"
result = bundle("exec ruby -e #{code.inspect}")
expect(result).to eq("/foo-original")
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index d780a3f27b..a3251ea640 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -34,8 +34,7 @@ Dir["#{File.expand_path("../support", __FILE__)}/*.rb"].each do |file|
require file unless file =~ %r{fakeweb/.*\.rb}
end
-$debug = false
-$show_err = true
+$debug = false
Spec::Rubygems.setup
FileUtils.rm_rf(Spec::Path.gem_repo1)
@@ -74,21 +73,18 @@ RSpec.configure do |config|
config.filter_run_excluding :realworld => true
end
+ git_version = Bundler::Source::Git::GitProxy.new(nil, nil, nil).version
+
config.filter_run_excluding :ruby => LessThanProc.with(RUBY_VERSION)
config.filter_run_excluding :rubygems => LessThanProc.with(Gem::VERSION)
- config.filter_run_excluding :git => LessThanProc.with(`git --version`.gsub("git version", "").strip)
+ config.filter_run_excluding :git => LessThanProc.with(git_version)
config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master")
- config.filter_run :focused => true unless ENV["CI"]
- config.run_all_when_everything_filtered = true
+ config.filter_run_when_matching :focus unless ENV["CI"]
original_wd = Dir.pwd
original_env = ENV.to_hash
- def pending_jruby_shebang_fix
- pending "JRuby executables do not have a proper shebang" if RUBY_PLATFORM == "java"
- end
-
config.expect_with :rspec do |c|
c.syntax = :expect
end
@@ -101,10 +97,18 @@ RSpec.configure do |config|
reset!
system_gems []
in_app_root
+ @all_output = String.new
end
config.after :each do |example|
- puts @out if defined?(@out) && example.exception
+ @all_output.strip!
+ if example.exception && !@all_output.empty?
+ warn @all_output unless config.formatters.grep(RSpec::Core::Formatters::DocumentationFormatter).empty?
+ message = example.exception.message + "\n\nCommands:\n#{@all_output}"
+ (class << example.exception; self; end).send(:define_method, :message) do
+ message
+ end
+ end
Dir.chdir(original_wd)
ENV.replace(original_env)
diff --git a/spec/support/artifice/fail.rb b/spec/support/artifice/fail.rb
new file mode 100644
index 0000000000..e15768a328
--- /dev/null
+++ b/spec/support/artifice/fail.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require File.expand_path("../../path.rb", __FILE__)
+
+# Set up pretend http gem server with FakeWeb
+$LOAD_PATH.unshift Dir[Spec::Path.base_system_gems.join("gems/artifice*/lib")].first.to_s
+$LOAD_PATH.unshift Dir[Spec::Path.base_system_gems.join("gems/rack-*/lib")].first.to_s
+$LOAD_PATH.unshift Dir[Spec::Path.base_system_gems.join("gems/rack-*/lib")].last.to_s
+$LOAD_PATH.unshift Dir[Spec::Path.base_system_gems.join("gems/tilt*/lib")].first.to_s
+require "artifice"
+
+class Fail
+ def call(env)
+ raise(exception(env))
+ end
+
+ def exception(env)
+ name = ENV.fetch("BUNDLER_SPEC_EXCEPTION") { "Errno::ENETUNREACH" }
+ const = name.split("::").reduce(Object) {|mod, sym| mod.const_get(sym) }
+ const.new("host down: Bundler spec artifice fail! #{env["PATH_INFO"]}")
+ end
+end
+Artifice.activate_with(Fail.new)
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 00024db7cf..337234f14a 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -373,12 +373,14 @@ module Spec
end
return unless block_given?
@_build_path = "#{path}/gems"
+ @_build_repo = File.basename(path)
yield
with_gem_path_as Path.base_system_gems do
- Dir.chdir(path) { gem_command :generate_index }
+ Dir.chdir(path) { gem_command! :generate_index }
end
ensure
@_build_path = nil
+ @_build_repo = nil
end
def build_index(&block)
@@ -393,6 +395,8 @@ module Spec
s.name = name
s.version = Gem::Version.new(v)
s.platform = platform
+ s.authors = ["no one in particular"]
+ s.summary = "a gemspec used only for testing"
DepBuilder.run(s, &block) if block_given?
end
end
@@ -418,8 +422,9 @@ module Spec
end
def update_git(name, *args, &block)
+ opts = args.last.is_a?(Hash) ? args.last : {}
spec = build_with(GitUpdater, name, args, &block)
- GitReader.new lib_path(spec.full_name)
+ GitReader.new(opts[:path] || lib_path(spec.full_name))
end
def build_plugin(name, *args, &blk)
@@ -430,11 +435,13 @@ module Spec
def build_with(builder, name, args, &blk)
@_build_path ||= nil
+ @_build_repo ||= nil
options = args.last.is_a?(Hash) ? args.pop : {}
versions = args.last || "1.0"
spec = nil
options[:path] ||= @_build_path
+ options[:source] ||= @_build_repo
Array(versions).each do |version|
spec = builder.new(self, name, version)
@@ -534,8 +541,13 @@ module Spec
@spec.executables = Array(val)
@spec.executables.each do |file|
executable = "#{@spec.bindir}/#{file}"
+ shebang = if Bundler.current_ruby.jruby?
+ "#!/usr/bin/env jruby\n"
+ else
+ "#!/usr/bin/env ruby\n"
+ end
@spec.files << executable
- write executable, "#!/usr/bin/env ruby\nrequire '#{@name}' ; puts #{Builders.constantize(@name)}"
+ write executable, "#{shebang}require '#{@name}' ; puts #{Builders.constantize(@name)}"
end
end
@@ -579,7 +591,12 @@ module Spec
@files["#{name}.gemspec"] = @spec.to_ruby
end
- @files = _default_files.merge(@files) unless options[:no_default]
+ 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(@files)
+ end
@spec.authors = ["no one"]
@@ -604,7 +621,8 @@ module Spec
class GitBuilder < LibBuilder
def _build(options)
path = options[:path] || _default_path
- super(options.merge(:path => path))
+ source = options[:source] || "git@#{path}"
+ super(options.merge(:path => path, :source => source))
Dir.chdir(path) do
`git init`
`git add *`
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 34335ee1a3..fe79604f30 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -13,7 +13,7 @@ module Spec
FileUtils.mkdir_p(tmp)
FileUtils.mkdir_p(home)
ENV["BUNDLE_DISABLE_POSTIT"] = "1"
- Bundler.send(:remove_instance_variable, :@settings) if Bundler.send(:instance_variable_defined?, :@settings)
+ Bundler.reset!
Bundler.ui = nil
Bundler.ui # force it to initialize
end
@@ -34,6 +34,10 @@ module Spec
attr_reader :out, :err, :exitstatus
+ def the_bundle(*args)
+ TheBundle.new(*args)
+ end
+
def in_app_root(&blk)
Dir.chdir(bundled_app, &blk)
end
@@ -48,11 +52,10 @@ module Spec
def run(cmd, *args)
opts = args.last.is_a?(Hash) ? args.pop : {}
- expect_err = opts.delete(:expect_err)
env = opts.delete(:env)
groups = args.map(&:inspect).join(", ")
setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
- @out = ruby(setup + cmd, :expect_err => expect_err, :env => env)
+ @out = ruby(setup + cmd, :env => env)
end
bang :run
@@ -65,7 +68,6 @@ module Spec
end
RUBY
opts = args.last.is_a?(Hash) ? args.pop : {}
- opts.merge!(:expect_err => true)
args += [opts]
run(cmd, *args)
end
@@ -79,7 +81,6 @@ module Spec
end
def bundle(cmd, options = {})
- expect_err = options.delete(:expect_err)
with_sudo = options.delete(:sudo)
sudo = with_sudo == :preserve_env ? "sudo -E" : "sudo" if with_sudo
@@ -99,7 +100,7 @@ module Spec
end.join
cmd = "#{env} #{sudo} #{Gem.ruby} -I#{lib}:#{spec} #{requires_str} #{bundle_bin} #{cmd}#{args}"
- sys_exec(cmd, expect_err) {|i, o, thr| yield i, o, thr if block_given? }
+ sys_exec(cmd) {|i, o, thr| yield i, o, thr if block_given? }
end
bang :bundle
@@ -109,7 +110,6 @@ module Spec
end
def bundle_ruby(options = {})
- expect_err = options.delete(:expect_err)
options["no-color"] = true unless options.key?("no-color")
bundle_bin = File.expand_path("../../../exe/bundle_ruby", __FILE__)
@@ -122,27 +122,25 @@ module Spec
env = (options.delete(:env) || {}).map {|k, v| "#{k}='#{v}' " }.join
cmd = "#{env}#{Gem.ruby} -I#{lib} #{requires_str} #{bundle_bin}"
- sys_exec(cmd, expect_err) {|i, o, thr| yield i, o, thr if block_given? }
+ sys_exec(cmd) {|i, o, thr| yield i, o, thr if block_given? }
end
def ruby(ruby, options = {})
- expect_err = options.delete(:expect_err)
env = (options.delete(:env) || {}).map {|k, v| "#{k}='#{v}' " }.join
ruby = ruby.gsub(/["`\$]/) {|m| "\\#{m}" }
lib_option = options[:no_lib] ? "" : " -I#{lib}"
- sys_exec(%(#{env}#{Gem.ruby}#{lib_option} -e "#{ruby}"), expect_err)
+ sys_exec(%(#{env}#{Gem.ruby}#{lib_option} -e "#{ruby}"))
end
bang :ruby
def load_error_ruby(ruby, name, opts = {})
- cmd = <<-R
+ ruby(<<-R)
begin
#{ruby}
rescue LoadError => e
$stderr.puts "ZOMG LOAD ERROR"# if e.message.include?("-- #{name}")
end
R
- ruby(cmd, opts.merge(:expect_err => true))
end
def gembin(cmd)
@@ -155,17 +153,33 @@ module Spec
ENV["RUBYOPT"] = old
end
- def sys_exec(cmd, expect_err = false)
+ def gem_command(command, args = "", options = {})
+ if command == :exec && !options[:no_quote]
+ args = args.gsub(/(?=")/, "\\")
+ args = %("#{args}")
+ end
+ sys_exec("#{Gem.ruby} -rubygems -S gem --backtrace #{command} #{args}")
+ end
+ bang :gem_command
+
+ def sys_exec(cmd)
Open3.popen3(cmd.to_s) do |stdin, stdout, stderr, wait_thr|
yield stdin, stdout, wait_thr if block_given?
stdin.close
+ @exitstatus = wait_thr && wait_thr.value.exitstatus
@out = Thread.new { stdout.read }.value.strip
@err = Thread.new { stderr.read }.value.strip
- @exitstatus = wait_thr && wait_thr.value.exitstatus
end
- puts @err unless expect_err || @err.empty? || !$show_err
+ (@all_output ||= String.new) << [
+ "$ #{cmd.to_s.strip}",
+ out,
+ err,
+ @exitstatus ? "# $? => #{@exitstatus}" : "",
+ "\n",
+ ].reject(&:empty?).join("\n")
+
@out
end
bang :sys_exec
@@ -217,6 +231,7 @@ module Spec
opts[:retry] ||= 0
bundle :install, opts
end
+ bang :install_gemfile
def lock_gemfile(*args)
gemfile(*args)
@@ -231,7 +246,7 @@ module Spec
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
- gem_command :install, "--no-rdoc --no-ri --ignore-dependencies #{path}"
+ gem_command! :install, "--no-rdoc --no-ri --ignore-dependencies #{path}"
end
end
@@ -241,7 +256,7 @@ module Spec
backup = ENV.to_hash
ENV["GEM_HOME"] = path.to_s
ENV["GEM_PATH"] = path.to_s
- ENV["BUNDLE_ORIG_GEM_PATH"] = nil
+ ENV["BUNDLER_ORIG_GEM_PATH"] = nil
yield
ensure
ENV.replace(backup)
@@ -250,7 +265,7 @@ module Spec
def with_path_as(path)
backup = ENV.to_hash
ENV["PATH"] = path.to_s
- ENV["BUNDLE_ORIG_PATH"] = nil
+ ENV["BUNDLER_ORIG_PATH"] = nil
yield
ensure
ENV.replace(backup)
@@ -264,7 +279,7 @@ module Spec
def break_git!
FileUtils.mkdir_p(tmp("broken_path"))
- File.open(tmp("broken_path/git"), "w", 0755) do |f|
+ File.open(tmp("broken_path/git"), "w", 0o755) do |f|
f.puts "#!/usr/bin/env ruby\nSTDERR.puts 'This is not the git you are looking for'\nexit 1"
end
@@ -273,7 +288,7 @@ module Spec
def with_fake_man
FileUtils.mkdir_p(tmp("fake_man"))
- File.open(tmp("fake_man/man"), "w", 0755) do |f|
+ File.open(tmp("fake_man/man"), "w", 0o755) do |f|
f.puts "#!/usr/bin/env ruby\nputs ARGV.inspect\n"
end
with_path_added(tmp("fake_man")) { yield }
@@ -290,7 +305,7 @@ module Spec
env_backup = ENV.to_hash
ENV["GEM_HOME"] = system_gem_path.to_s
ENV["GEM_PATH"] = system_gem_path.to_s
- ENV["BUNDLE_ORIG_GEM_PATH"] = nil
+ ENV["BUNDLER_ORIG_GEM_PATH"] = nil
install_gems(*gems)
return unless block_given?
@@ -400,14 +415,7 @@ module Spec
end
def capture_output
- fake_stdout = StringIO.new
- actual_stdout = $stdout
- $stdout = fake_stdout
- yield
- fake_stdout.rewind
- fake_stdout.read
- ensure
- $stdout = actual_stdout
+ capture(:stdout)
end
def with_read_only(pattern)
@@ -418,10 +426,10 @@ module Spec
end
end
- Dir[pattern].each(&chmod[0555, 0444])
+ Dir[pattern].each(&chmod[0o555, 0o444])
yield
ensure
- Dir[pattern].each(&chmod[0755, 0644])
+ Dir[pattern].each(&chmod[0o755, 0o644])
end
def process_file(pathname)
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index 10e47691ab..9476f18984 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -1,6 +1,64 @@
# frozen_string_literal: true
+require "forwardable"
+require "support/the_bundle"
module Spec
module Matchers
+ extend RSpec::Matchers
+
+ class Precondition
+ include RSpec::Matchers::Composable
+ extend Forwardable
+ def_delegators :failing_matcher,
+ :failure_message,
+ :actual,
+ :description,
+ :diffable?,
+ :expected,
+ :failure_message_when_negated
+
+ def initialize(matcher, preconditions)
+ @matcher = with_matchers_cloned(matcher)
+ @preconditions = with_matchers_cloned(preconditions)
+ @failure_index = nil
+ end
+
+ def matches?(target, &blk)
+ return false if @failure_index = @preconditions.index {|pc| !pc.matches?(target, &blk) }
+ @matcher.matches?(target, &blk)
+ end
+
+ def does_not_match?(target, &blk)
+ return false if @failure_index = @preconditions.index {|pc| !pc.matches?(target, &blk) }
+ if @matcher.respond_to?(:does_not_match?)
+ @matcher.does_not_match?(target, &blk)
+ else
+ !@matcher.matches?(target, &blk)
+ end
+ end
+
+ def expects_call_stack_jump?
+ @matcher.expects_call_stack_jump? || @preconditions.any?(&:expects_call_stack_jump)
+ end
+
+ def supports_block_expectations?
+ @matcher.supports_block_expectations? || @preconditions.any?(&:supports_block_expectations)
+ end
+
+ def failing_matcher
+ @failure_index ? @preconditions[@failure_index] : @matcher
+ end
+ end
+
+ def self.define_compound_matcher(matcher, preconditions, &declarations)
+ raise "Must have preconditions to define a compound matcher" if preconditions.empty?
+ define_method(matcher) do |*expected, &block_arg|
+ Precondition.new(
+ RSpec::Matchers::DSL::Matcher.new(matcher, declarations, self, *expected, &block_arg),
+ preconditions
+ )
+ end
+ end
+
MAJOR_DEPRECATION = /^\[DEPRECATED FOR 2\.0\]\s*/
RSpec::Matchers.define :lack_errors do
@@ -50,69 +108,121 @@ module Spec
end
end
- def should_be_installed(*names)
- opts = names.last.is_a?(Hash) ? names.pop : {}
- groups = Array(opts[:groups])
- groups << opts
- names.each do |name|
- name, version, platform = name.split(/\s+/)
- version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name)
- run! "require '#{name}.rb'; puts #{version_const}", *groups
- expect(out).not_to be_empty, "#{name} is not installed"
- out.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
- actual_version, actual_platform = out.strip.split(/\s+/, 2)
- expect(Gem::Version.new(actual_version)).to eq(Gem::Version.new(version))
- expect(actual_platform).to eq(platform)
+ define_compound_matcher :read_as, [exist] do |file_contents|
+ diffable
+ attr_reader :strip_whitespace
+
+ chain :stripping_whitespace do
+ @strip_whitespace = true
+ end
+
+ match do |actual|
+ @actual = Bundler.read_file(actual)
+ file_contents = strip_whitespace(file_contents) if strip_whitespace
+ values_match?(file_contents, @actual)
end
end
- alias_method :should_be_available, :should_be_installed
+ def indent(string, padding = 4, indent_character = " ")
+ string.to_s.gsub(/^/, indent_character * padding).gsub("\t", " ")
+ end
- def should_not_be_installed(*names)
- opts = names.last.is_a?(Hash) ? names.pop : {}
- groups = Array(opts[:groups]) || []
- names.each do |name|
- name, version = name.split(/\s+/, 2)
- run <<-R, *(groups + [opts])
+ define_compound_matcher :include_gems, [be_an_instance_of(Spec::TheBundle)] do |*names|
+ match do
+ opts = names.last.is_a?(Hash) ? names.pop : {}
+ source = opts.delete(:source)
+ groups = Array(opts[:groups])
+ groups << opts
+ @errors = names.map do |name|
+ name, version, platform = name.split(/\s+/)
+ version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name)
begin
- require '#{name}'
- puts #{Spec::Builders.constantize(name)}
- rescue LoadError, NameError
- puts "WIN"
+ run! "require '#{name}.rb'; puts #{version_const}", *groups
+ rescue => e
+ next "#{name} is not installed:\n#{indent(e)}"
end
- R
- if version.nil? || out == "WIN"
- expect(out).to eq("WIN")
- else
- expect(Gem::Version.new(out)).not_to eq(Gem::Version.new(version))
- end
+ out.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
+ actual_version, actual_platform = out.strip.split(/\s+/, 2)
+ unless Gem::Version.new(actual_version) == Gem::Version.new(version)
+ next "#{name} was expected to be at version #{version} but was #{actual_version}"
+ end
+ unless actual_platform == platform
+ next "#{name} was expected to be of platform #{platform} but was #{actual_platform}"
+ end
+ next unless source
+ begin
+ source_const = "#{Spec::Builders.constantize(name)}_SOURCE"
+ run! "require '#{name}/source'; puts #{source_const}", *groups
+ rescue
+ next "#{name} does not have a source defined:\n#{indent(e)}"
+ end
+ out.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
+ unless out.strip == source
+ next "Expected #{name} (#{version}) to be installed from `#{source}`, was actually from `#{out}`"
+ end
+ end.compact
+
+ @errors.empty?
end
+
+ match_when_negated do
+ opts = names.last.is_a?(Hash) ? names.pop : {}
+ groups = Array(opts[:groups]) || []
+ @errors = names.map do |name|
+ name, version = name.split(/\s+/, 2)
+ begin
+ run <<-R, *(groups + [opts])
+ begin
+ require '#{name}'
+ puts #{Spec::Builders.constantize(name)}
+ rescue LoadError, NameError
+ puts "WIN"
+ end
+ R
+ rescue => e
+ next "checking for #{name} failed:\n#{e}"
+ end
+ next if out == "WIN"
+ next "expected #{name} to not be installed, but it was" if version.nil?
+ if Gem::Version.new(out) == Gem::Version.new(version)
+ next "expected #{name} (#{version}) not to be installed, but it was"
+ end
+ end.compact
+
+ @errors.empty?
+ end
+
+ failure_message do
+ super() + " but:\n" + @errors.map {|e| indent(e) }.join("\n")
+ end
+
+ failure_message_when_negated do
+ super() + " but:\n" + @errors.map {|e| indent(e) }.join("\n")
+ end
+ end
+ RSpec::Matchers.define_negated_matcher :not_include_gems, :include_gems
+ RSpec::Matchers.alias_matcher :include_gem, :include_gems
+
+ def have_lockfile(expected)
+ read_as(strip_whitespace(expected))
end
def plugin_should_be_installed(*names)
names.each do |name|
- path = Bundler::Plugin.installed?(name)
- expect(path).to be_truthy
- expect(Pathname.new(path).join("plugins.rb")).to exist
+ expect(Bundler::Plugin).to be_installed(name)
+ path = Pathname.new(Bundler::Plugin.installed?(name))
+ expect(path + "plugins.rb").to exist
end
end
def plugin_should_not_be_installed(*names)
names.each do |name|
- path = Bundler::Plugin.installed?(name)
- expect(path).to be_falsey
+ expect(Bundler::Plugin).not_to be_installed(name)
end
end
- def should_be_locked
- expect(bundled_app("Gemfile.lock")).to exist
- end
-
def lockfile_should_be(expected)
- should_be_locked
- spaces = expected[/\A\s+/, 0] || ""
- expected = expected.gsub(/^#{spaces}/, "")
- expect(bundled_app("Gemfile.lock").read).to eq(expected)
+ expect(bundled_app("Gemfile.lock")).to read_as(strip_whitespace(expected))
end
end
end
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index e436503157..4ddbc3312a 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -50,14 +50,5 @@ module Spec
cmd += " --version '#{version}'" if version
system(cmd) || raise("Installing gem #{name} for the tests to use failed!")
end
-
- def gem_command(command, args = "", options = {})
- if command == :exec && !options[:no_quote]
- args = args.gsub(/(?=")/, "\\")
- args = %("#{args}")
- end
- lib = File.join(File.dirname(__FILE__), "..", "..", "lib")
- `#{Gem.ruby} -I#{lib} -rubygems -S gem --backtrace #{command} #{args}`.strip
- end
end
end
diff --git a/spec/support/silent_logger.rb b/spec/support/silent_logger.rb
new file mode 100644
index 0000000000..1a8f91b3ba
--- /dev/null
+++ b/spec/support/silent_logger.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+require "logger"
+module Spec
+ class SilentLogger
+ (::Logger.instance_methods - Object.instance_methods).each do |logger_instance_method|
+ define_method(logger_instance_method) {|*args, &blk| }
+ end
+ end
+end
diff --git a/spec/support/sometimes.rb b/spec/support/sometimes.rb
index 1ecbd36e2d..6a50f5ff4c 100644
--- a/spec/support/sometimes.rb
+++ b/spec/support/sometimes.rb
@@ -33,7 +33,8 @@ RSpec.configure do |config|
message = proc do |color, text|
colored = RSpec::Core::Formatters::ConsoleCodes.wrap(text, color)
notification = RSpec::Core::Notifications::MessageNotification.new(colored)
- RSpec.configuration.formatters.first.message(notification)
+ formatter = RSpec.configuration.formatters.first
+ formatter.message(notification) if formatter.respond_to?(:message)
end
retried_examples = RSpec.world.example_groups.map do |g|
diff --git a/spec/support/the_bundle.rb b/spec/support/the_bundle.rb
new file mode 100644
index 0000000000..86df9cd9c7
--- /dev/null
+++ b/spec/support/the_bundle.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+require "support/helpers"
+require "support/path"
+
+module Spec
+ class TheBundle
+ include Spec::Helpers
+ include Spec::Path
+
+ attr_accessor :bundle_dir
+
+ def initialize(opts = {})
+ opts = opts.dup
+ @bundle_dir = Pathname.new(opts.delete(:bundle_dir) { bundled_app })
+ raise "Too many options! #{opts}" unless opts.empty?
+ end
+
+ def to_s
+ "the bundle"
+ end
+ alias_method :inspect, :to_s
+
+ def locked?
+ lockfile.file?
+ end
+
+ def lockfile
+ bundle_dir.join("Gemfile.lock")
+ end
+ end
+end
diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb
index 25dff6818e..b67ddda202 100644
--- a/spec/update/git_spec.rb
+++ b/spec/update/git_spec.rb
@@ -19,7 +19,7 @@ describe "bundle update" do
bundle "update"
- should_be_installed "foo 1.1"
+ expect(the_bundle).to include_gems "foo 1.1"
end
it "updates correctly when you have like craziness" do
@@ -34,7 +34,7 @@ describe "bundle update" do
bundle "update rails"
expect(out).to include("Using activesupport 3.0 from #{lib_path("rails")} (at master@#{revision_for(lib_path("rails"))[0..6]})")
- should_be_installed "rails 3.0", "activesupport 3.0"
+ expect(the_bundle).to include_gems "rails 3.0", "activesupport 3.0"
end
it "floats on a branch when :branch is used and the source is specified in the update" do
@@ -53,7 +53,7 @@ describe "bundle update" do
bundle "update --source foo"
- should_be_installed "foo 1.1"
+ expect(the_bundle).to include_gems "foo 1.1"
end
it "floats on master when updating all gems that are pinned to the source even if you have child dependencies" do
@@ -73,7 +73,7 @@ describe "bundle update" do
bundle "update foo"
- should_be_installed "foo 1.1"
+ expect(the_bundle).to include_gems "foo 1.1"
end
it "notices when you change the repo url in the Gemfile" do
@@ -132,7 +132,7 @@ describe "bundle update" do
end
Dir.chdir(lib_path("has_submodule-1.0")) do
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", :expect_err => true
+ sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0"
`git commit -m "submodulator"`
end
end
@@ -147,7 +147,7 @@ describe "bundle update" do
run "require 'submodule'"
expect(out).to eq("GEM")
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
git "#{lib_path("has_submodule-1.0")}", :submodules => true do
gem "has_submodule"
end
@@ -158,7 +158,7 @@ describe "bundle update" do
end
it "unlocks the source when submodules are removed from git source", :git => ">= 2.9.0" do
- install_gemfile <<-G, :expect_err => true
+ install_gemfile <<-G
git "#{lib_path("has_submodule-1.0")}", :submodules => true do
gem "has_submodule"
end
@@ -187,7 +187,7 @@ describe "bundle update" do
lib_path("foo-1.0").join(".git").rmtree
- bundle :update, :expect_err => true
+ bundle :update
expect(out).to include(lib_path("foo-1.0").to_s)
end
@@ -268,7 +268,7 @@ describe "bundle update" do
update_git "foo", "2.0", :path => @git.path
bundle "update --source foo"
- should_be_installed "foo 2.0"
+ expect(the_bundle).to include_gems "foo 2.0"
end
it "leaves all other gems frozen" do
@@ -276,7 +276,7 @@ describe "bundle update" do
update_git "foo", :path => @git.path
bundle "update --source foo"
- should_be_installed "rack 1.0"
+ expect(the_bundle).to include_gems "rack 1.0"
end
end