Update to ruby/mspec@3fb5112
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f00bf24272
commit
e59bf54b3a
@ -75,7 +75,7 @@ class MkSpec
|
|||||||
parents = '../' * (sub.split('/').length + 1)
|
parents = '../' * (sub.split('/').length + 1)
|
||||||
|
|
||||||
File.open(file, 'w') do |f|
|
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|
|
config[:requires].each do |lib|
|
||||||
f.puts "require '#{lib}'"
|
f.puts "require '#{lib}'"
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
require 'mspec/guards/guard'
|
require 'mspec/guards/guard'
|
||||||
|
require 'mspec/utils/deprecate'
|
||||||
|
|
||||||
class ConflictsGuard < SpecGuard
|
class ConflictsGuard < SpecGuard
|
||||||
|
def initialize(*args)
|
||||||
|
MSpec.deprecate 'conflicts_with', 'guard -> { condition } do'
|
||||||
|
super(*args)
|
||||||
|
end
|
||||||
|
|
||||||
def match?
|
def match?
|
||||||
# Always convert constants to symbols regardless of version.
|
# Always convert constants to symbols regardless of version.
|
||||||
constants = Object.constants.map { |x| x.to_sym }
|
constants = Object.constants.map { |x| x.to_sym }
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
require 'mspec/utils/deprecate'
|
|
||||||
|
|
||||||
class RaiseErrorMatcher
|
class RaiseErrorMatcher
|
||||||
def initialize(exception, message, &block)
|
def initialize(exception, message, &block)
|
||||||
@exception = exception
|
@exception = exception
|
||||||
|
@ -8,10 +8,9 @@ class NameMap
|
|||||||
'*' => 'multiply',
|
'*' => 'multiply',
|
||||||
'/' => 'divide',
|
'/' => 'divide',
|
||||||
'%' => 'modulo',
|
'%' => 'modulo',
|
||||||
'<<' => {'Bignum' => 'left_shift',
|
'<<' => {'Integer' => 'left_shift',
|
||||||
'Fixnum' => 'left_shift',
|
'IO' => 'output',
|
||||||
'IO' => 'output',
|
:default => 'append' },
|
||||||
:default => 'append' },
|
|
||||||
'>>' => 'right_shift',
|
'>>' => 'right_shift',
|
||||||
'<' => 'lt',
|
'<' => 'lt',
|
||||||
'<=' => 'lte',
|
'<=' => 'lte',
|
||||||
@ -25,33 +24,22 @@ class NameMap
|
|||||||
'[]=' => 'element_set',
|
'[]=' => 'element_set',
|
||||||
'**' => 'exponent',
|
'**' => 'exponent',
|
||||||
'!' => 'not',
|
'!' => 'not',
|
||||||
'~' => {'Bignum' => 'complement',
|
'~' => {'Integer' => 'complement',
|
||||||
'Fixnum' => 'complement',
|
:default => 'match' },
|
||||||
'Regexp' => 'match',
|
|
||||||
'String' => 'match' },
|
|
||||||
'!=' => 'not_equal',
|
'!=' => 'not_equal',
|
||||||
'!~' => 'not_match',
|
'!~' => 'not_match',
|
||||||
'=~' => 'match',
|
'=~' => 'match',
|
||||||
'&' => {'Bignum' => 'bit_and',
|
'&' => {'Integer' => 'bit_and',
|
||||||
'Fixnum' => 'bit_and',
|
|
||||||
'Array' => 'intersection',
|
'Array' => 'intersection',
|
||||||
'TrueClass' => 'and',
|
'Set' => 'intersection',
|
||||||
'FalseClass' => 'and',
|
:default => 'and' },
|
||||||
'NilClass' => 'and',
|
'|' => {'Integer' => 'bit_or',
|
||||||
'Set' => 'intersection' },
|
|
||||||
'|' => {'Bignum' => 'bit_or',
|
|
||||||
'Fixnum' => 'bit_or',
|
|
||||||
'Array' => 'union',
|
'Array' => 'union',
|
||||||
'TrueClass' => 'or',
|
'Set' => 'union',
|
||||||
'FalseClass' => 'or',
|
:default => 'or' },
|
||||||
'NilClass' => 'or',
|
'^' => {'Integer' => 'bit_xor',
|
||||||
'Set' => 'union' },
|
'Set' => 'exclusion',
|
||||||
'^' => {'Bignum' => 'bit_xor',
|
:default => 'xor' },
|
||||||
'Fixnum' => 'bit_xor',
|
|
||||||
'TrueClass' => 'xor',
|
|
||||||
'FalseClass' => 'xor',
|
|
||||||
'NilClass' => 'xor',
|
|
||||||
'Set' => 'exclusion'},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EXCLUDED = %w[
|
EXCLUDED = %w[
|
||||||
@ -119,7 +107,12 @@ class NameMap
|
|||||||
|
|
||||||
def file_name(m, c)
|
def file_name(m, c)
|
||||||
if MAP.key?(m)
|
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
|
else
|
||||||
name = m.gsub(/[?!=]/, '')
|
name = m.gsub(/[?!=]/, '')
|
||||||
end
|
end
|
||||||
|
@ -189,11 +189,7 @@ class MSpecScript
|
|||||||
end
|
end
|
||||||
|
|
||||||
patterns.each do |pattern|
|
patterns.each do |pattern|
|
||||||
begin
|
expanded = File.expand_path(pattern)
|
||||||
expanded = File.realpath(pattern)
|
|
||||||
rescue Errno::ENOENT
|
|
||||||
next
|
|
||||||
end
|
|
||||||
if File.file?(expanded) && expanded.end_with?('.rb')
|
if File.file?(expanded) && expanded.end_with?('.rb')
|
||||||
return [expanded]
|
return [expanded]
|
||||||
elsif File.directory?(expanded)
|
elsif File.directory?(expanded)
|
||||||
|
@ -167,13 +167,13 @@ describe MkSpec, "#write_requires" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "writes the spec_helper require line" do
|
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")
|
@script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "writes require lines for each library specified on the command line" do
|
it "writes require lines for each library specified on the command line" do
|
||||||
@file.stub(:puts)
|
@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'")
|
@file.should_receive(:puts).with("require 'complex'")
|
||||||
@script.config[:requires] << 'complex'
|
@script.config[:requires] << 'complex'
|
||||||
@script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb")
|
@script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb")
|
||||||
|
@ -3,6 +3,7 @@ require 'mspec/guards'
|
|||||||
|
|
||||||
describe Object, "#conflicts_with" do
|
describe Object, "#conflicts_with" do
|
||||||
before :each do
|
before :each do
|
||||||
|
hide_deprecation_warnings
|
||||||
ScratchPad.clear
|
ScratchPad.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ end
|
|||||||
|
|
||||||
describe Object, "#conflicts_with" do
|
describe Object, "#conflicts_with" do
|
||||||
before :each do
|
before :each do
|
||||||
|
hide_deprecation_warnings
|
||||||
@guard = ConflictsGuard.new
|
@guard = ConflictsGuard.new
|
||||||
ConflictsGuard.stub(:new).and_return(@guard)
|
ConflictsGuard.stub(:new).and_return(@guard)
|
||||||
end
|
end
|
||||||
|
@ -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
|
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("~", "Regexp").should == "match_spec.rb"
|
||||||
@map.file_name("~", "Fixnum").should == "complement_spec.rb"
|
@map.file_name("~", "Integer").should == "complement_spec.rb"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the name of the spec file based on the default entry for the method" do
|
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
|
end
|
||||||
|
|
||||||
it "uses the last component of the constant to look up the method name" do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user