git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2018-09-25 10:40:39 +00:00
parent f00bf24272
commit e59bf54b3a
8 changed files with 34 additions and 39 deletions

View File

@ -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

View File

@ -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 }

View File

@ -1,5 +1,3 @@
require 'mspec/utils/deprecate'
class RaiseErrorMatcher
def initialize(exception, message, &block)
@exception = exception

View File

@ -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

View File

@ -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)

View File

@ -167,13 +167,13 @@ describe MkSpec, "#write_requires" do
end
it "writes the spec_helper require line" do
@file.should_receive(:puts).with("require File.expand_path('../../../../spec_helper', __FILE__)")
@file.should_receive(:puts).with("require_relative '../../../spec_helper'")
@script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb")
end
it "writes require lines for each library specified on the command line" do
@file.stub(:puts)
@file.should_receive(:puts).with("require File.expand_path('../../../../spec_helper', __FILE__)")
@file.should_receive(:puts).with("require_relative '../../../spec_helper'")
@file.should_receive(:puts).with("require 'complex'")
@script.config[:requires] << 'complex'
@script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb")

View File

@ -3,6 +3,7 @@ require 'mspec/guards'
describe Object, "#conflicts_with" do
before :each do
hide_deprecation_warnings
ScratchPad.clear
end
@ -33,6 +34,7 @@ end
describe Object, "#conflicts_with" do
before :each do
hide_deprecation_warnings
@guard = ConflictsGuard.new
ConflictsGuard.stub(:new).and_return(@guard)
end

View File

@ -129,7 +129,7 @@ describe NameMap, "#file_name" do
it "returns the name of the spec file based on the special entry for the method" do
@map.file_name("~", "Regexp").should == "match_spec.rb"
@map.file_name("~", "Fixnum").should == "complement_spec.rb"
@map.file_name("~", "Integer").should == "complement_spec.rb"
end
it "returns the name of the spec file based on the default entry for the method" do
@ -137,7 +137,7 @@ describe NameMap, "#file_name" do
end
it "uses the last component of the constant to look up the method name" do
@map.file_name("^", "NameMapSpecs::Fixnum").should == "bit_xor_spec.rb"
@map.file_name("^", "NameMapSpecs::Integer").should == "bit_xor_spec.rb"
end
end