summaryrefslogtreecommitdiff
path: root/spec/mspec/lib
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-25 10:40:39 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-25 10:40:39 +0000
commite59bf54b3a88d0465cca021afae7dc05b6db57a7 (patch)
tree9299f6a6e384ebe2bbc50c19dbd2049d6d0a2cba /spec/mspec/lib
parentf00bf242724d40d59a242c6bf9e567d18c9e1872 (diff)
Update to ruby/mspec@3fb5112
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/mspec/lib')
-rwxr-xr-xspec/mspec/lib/mspec/commands/mkspec.rb2
-rw-r--r--spec/mspec/lib/mspec/guards/conflict.rb6
-rw-r--r--spec/mspec/lib/mspec/matchers/raise_error.rb2
-rw-r--r--spec/mspec/lib/mspec/utils/name_map.rb47
-rw-r--r--spec/mspec/lib/mspec/utils/script.rb6
5 files changed, 28 insertions, 35 deletions
diff --git a/spec/mspec/lib/mspec/commands/mkspec.rb b/spec/mspec/lib/mspec/commands/mkspec.rb
index 7a943aa1fe..49a2e6b616 100755
--- a/spec/mspec/lib/mspec/commands/mkspec.rb
+++ b/spec/mspec/lib/mspec/commands/mkspec.rb
@@ -75,7 +75,7 @@ class MkSpec
parents = '../' * (sub.split('/').length + 1)
File.open(file, 'w') do |f|
- f.puts "require File.expand_path('../#{parents}spec_helper', __FILE__)"
+ f.puts "require_relative '#{parents}spec_helper'"
config[:requires].each do |lib|
f.puts "require '#{lib}'"
end
diff --git a/spec/mspec/lib/mspec/guards/conflict.rb b/spec/mspec/lib/mspec/guards/conflict.rb
index 7a27671c1e..4930e5734d 100644
--- a/spec/mspec/lib/mspec/guards/conflict.rb
+++ b/spec/mspec/lib/mspec/guards/conflict.rb
@@ -1,6 +1,12 @@
require 'mspec/guards/guard'
+require 'mspec/utils/deprecate'
class ConflictsGuard < SpecGuard
+ def initialize(*args)
+ MSpec.deprecate 'conflicts_with', 'guard -> { condition } do'
+ super(*args)
+ end
+
def match?
# Always convert constants to symbols regardless of version.
constants = Object.constants.map { |x| x.to_sym }
diff --git a/spec/mspec/lib/mspec/matchers/raise_error.rb b/spec/mspec/lib/mspec/matchers/raise_error.rb
index 2f9afdc687..a051ea12f7 100644
--- a/spec/mspec/lib/mspec/matchers/raise_error.rb
+++ b/spec/mspec/lib/mspec/matchers/raise_error.rb
@@ -1,5 +1,3 @@
-require 'mspec/utils/deprecate'
-
class RaiseErrorMatcher
def initialize(exception, message, &block)
@exception = exception
diff --git a/spec/mspec/lib/mspec/utils/name_map.rb b/spec/mspec/lib/mspec/utils/name_map.rb
index c1de081af0..a93b0d001e 100644
--- a/spec/mspec/lib/mspec/utils/name_map.rb
+++ b/spec/mspec/lib/mspec/utils/name_map.rb
@@ -8,10 +8,9 @@ class NameMap
'*' => 'multiply',
'/' => 'divide',
'%' => 'modulo',
- '<<' => {'Bignum' => 'left_shift',
- 'Fixnum' => 'left_shift',
- 'IO' => 'output',
- :default => 'append' },
+ '<<' => {'Integer' => 'left_shift',
+ 'IO' => 'output',
+ :default => 'append' },
'>>' => 'right_shift',
'<' => 'lt',
'<=' => 'lte',
@@ -25,33 +24,22 @@ class NameMap
'[]=' => 'element_set',
'**' => 'exponent',
'!' => 'not',
- '~' => {'Bignum' => 'complement',
- 'Fixnum' => 'complement',
- 'Regexp' => 'match',
- 'String' => 'match' },
+ '~' => {'Integer' => 'complement',
+ :default => 'match' },
'!=' => 'not_equal',
'!~' => 'not_match',
'=~' => 'match',
- '&' => {'Bignum' => 'bit_and',
- 'Fixnum' => 'bit_and',
+ '&' => {'Integer' => 'bit_and',
'Array' => 'intersection',
- 'TrueClass' => 'and',
- 'FalseClass' => 'and',
- 'NilClass' => 'and',
- 'Set' => 'intersection' },
- '|' => {'Bignum' => 'bit_or',
- 'Fixnum' => 'bit_or',
+ 'Set' => 'intersection',
+ :default => 'and' },
+ '|' => {'Integer' => 'bit_or',
'Array' => 'union',
- 'TrueClass' => 'or',
- 'FalseClass' => 'or',
- 'NilClass' => 'or',
- 'Set' => 'union' },
- '^' => {'Bignum' => 'bit_xor',
- 'Fixnum' => 'bit_xor',
- 'TrueClass' => 'xor',
- 'FalseClass' => 'xor',
- 'NilClass' => 'xor',
- 'Set' => 'exclusion'},
+ 'Set' => 'union',
+ :default => 'or' },
+ '^' => {'Integer' => 'bit_xor',
+ 'Set' => 'exclusion',
+ :default => 'xor' },
}
EXCLUDED = %w[
@@ -119,7 +107,12 @@ class NameMap
def file_name(m, c)
if MAP.key?(m)
- name = MAP[m].is_a?(Hash) ? MAP[m][c.split('::').last] || MAP[m][:default] : MAP[m]
+ mapping = MAP[m]
+ if mapping.is_a?(Hash)
+ name = mapping[c.split('::').last] || mapping.fetch(:default)
+ else
+ name = mapping
+ end
else
name = m.gsub(/[?!=]/, '')
end
diff --git a/spec/mspec/lib/mspec/utils/script.rb b/spec/mspec/lib/mspec/utils/script.rb
index 2816618b0f..db5a33a91a 100644
--- a/spec/mspec/lib/mspec/utils/script.rb
+++ b/spec/mspec/lib/mspec/utils/script.rb
@@ -189,11 +189,7 @@ class MSpecScript
end
patterns.each do |pattern|
- begin
- expanded = File.realpath(pattern)
- rescue Errno::ENOENT
- next
- end
+ expanded = File.expand_path(pattern)
if File.file?(expanded) && expanded.end_with?('.rb')
return [expanded]
elsif File.directory?(expanded)