summaryrefslogtreecommitdiff
path: root/spec/bundler/support/matchers.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-01 23:29:38 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-01 23:29:38 +0000
commitbe7b5929126cb3e696ef222339237faba9b8fe5a (patch)
tree51eae376f93c09bc82dde5a657a91df2c89062e4 /spec/bundler/support/matchers.rb
parentae49dbd392083f69026f2a0fff4a1d5f42d172a7 (diff)
Update bundled bundler to 1.16.0.
* lib/bundler, spec/bundler: Merge bundler-1.16.0. * common.mk: rspec examples of bundler-1.16.0 needs require option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/bundler/support/matchers.rb')
-rw-r--r--spec/bundler/support/matchers.rb34
1 files changed, 27 insertions, 7 deletions
diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb
index 9248360639..782257a222 100644
--- a/spec/bundler/support/matchers.rb
+++ b/spec/bundler/support/matchers.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require "forwardable"
require "support/the_bundle"
module Spec
@@ -78,7 +79,12 @@ module Spec
RSpec::Matchers.define :have_major_deprecation do |expected|
diffable
match do |actual|
- actual.split(MAJOR_DEPRECATION).any? do |d|
+ deprecations = actual.split(MAJOR_DEPRECATION)
+
+ return !expected.nil? if deprecations.size <= 1
+ return true if expected.nil?
+
+ deprecations.any? do |d|
!d.empty? && values_match?(expected, d.strip)
end
end
@@ -108,6 +114,20 @@ module Spec
end
end
+ RSpec::Matchers.define :be_sorted do
+ diffable
+ attr_reader :expected
+ match do |actual|
+ expected = block_arg ? actual.sort_by(&block_arg) : actual.sort
+ actual.==(expected).tap do
+ # HACK: since rspec won't show a diff when everything is a string
+ differ = RSpec::Support::Differ.new
+ @actual = differ.send(:object_to_string, actual)
+ @expected = differ.send(:object_to_string, expected)
+ end
+ end
+ end
+
define_compound_matcher :read_as, [exist] do |file_contents|
diffable
@@ -135,8 +155,8 @@ module Spec
rescue => e
next "#{name} is not installed:\n#{indent(e)}"
end
- out.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
- actual_version, actual_platform = out.strip.split(/\s+/, 2)
+ last_command.stdout.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
+ actual_version, actual_platform = last_command.stdout.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
@@ -150,8 +170,8 @@ module Spec
rescue
next "#{name} does not have a source defined:\n#{indent(e)}"
end
- out.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
- unless out.strip == source
+ last_command.stdout.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
+ unless last_command.stdout.strip == source
next "Expected #{name} (#{version}) to be installed from `#{source}`, was actually from `#{out}`"
end
end.compact
@@ -176,9 +196,9 @@ module Spec
rescue => e
next "checking for #{name} failed:\n#{e}"
end
- next if out == "WIN"
+ next if last_command.stdout == "WIN"
next "expected #{name} to not be installed, but it was" if version.nil?
- if Gem::Version.new(out) == Gem::Version.new(version)
+ if Gem::Version.new(last_command.stdout) == Gem::Version.new(version)
next "expected #{name} (#{version}) not to be installed, but it was"
end
end.compact