mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/mspec@5bd9409
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3efe410dd0
commit
49a864ad90
23 changed files with 122 additions and 159 deletions
|
|
@ -5,16 +5,18 @@ class RaiseErrorMatcher
|
|||
@exception = exception
|
||||
@message = message
|
||||
@block = block
|
||||
@actual = nil
|
||||
end
|
||||
|
||||
def matches?(proc)
|
||||
@result = proc.call
|
||||
return false
|
||||
rescue Exception => @actual
|
||||
if matching_exception?(@actual)
|
||||
rescue Exception => actual
|
||||
@actual = actual
|
||||
if matching_exception?(actual)
|
||||
return true
|
||||
else
|
||||
raise @actual
|
||||
raise actual
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -54,7 +56,7 @@ class RaiseErrorMatcher
|
|||
def failure_message
|
||||
message = ["Expected #{format_expected_exception}"]
|
||||
|
||||
if @actual then
|
||||
if @actual
|
||||
message << "but got #{format_exception(@actual)}"
|
||||
else
|
||||
message << "but no exception was raised (#{@result.pretty_inspect.chomp} was returned)"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
require 'mspec/expectations/expectations'
|
||||
require 'mspec/helpers/warning'
|
||||
|
||||
module Mock
|
||||
def self.reset
|
||||
|
|
@ -57,10 +58,12 @@ module Mock
|
|||
meta.__send__ :alias_method, key.first, sym
|
||||
end
|
||||
|
||||
meta.class_eval {
|
||||
define_method(sym) do |*args, &block|
|
||||
Mock.verify_call self, sym, *args, &block
|
||||
end
|
||||
suppress_warning {
|
||||
meta.class_eval {
|
||||
define_method(sym) do |*args, &block|
|
||||
Mock.verify_call self, sym, *args, &block
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
proxy = MockProxy.new type
|
||||
|
|
@ -179,7 +182,9 @@ module Mock
|
|||
meta = obj.singleton_class
|
||||
|
||||
if mock_respond_to? obj, replaced, true
|
||||
meta.__send__ :alias_method, sym, replaced
|
||||
suppress_warning do
|
||||
meta.__send__ :alias_method, sym, replaced
|
||||
end
|
||||
meta.__send__ :remove_method, replaced
|
||||
else
|
||||
meta.__send__ :remove_method, sym
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
require 'mspec/runner/formatters/spinner'
|
||||
require 'yaml'
|
||||
|
||||
class MultiFormatter < SpinnerFormatter
|
||||
def initialize(out=nil)
|
||||
|
|
@ -10,6 +9,8 @@ class MultiFormatter < SpinnerFormatter
|
|||
end
|
||||
|
||||
def aggregate_results(files)
|
||||
require 'yaml'
|
||||
|
||||
@timer.finish
|
||||
@exceptions = []
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ require 'mspec/runner/context'
|
|||
require 'mspec/runner/exception'
|
||||
require 'mspec/runner/tag'
|
||||
|
||||
module MSpec
|
||||
end
|
||||
|
||||
class MSpecEnv
|
||||
include MSpec
|
||||
end
|
||||
|
|
@ -399,4 +402,7 @@ module MSpec
|
|||
file = tags_file
|
||||
File.delete file if File.exist? file
|
||||
end
|
||||
|
||||
# Initialize @env
|
||||
setup_env
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ class MSpecScript
|
|||
end
|
||||
|
||||
def initialize
|
||||
if RUBY_VERSION < '2.2'
|
||||
abort "MSpec needs Ruby 2.2 or more recent"
|
||||
end
|
||||
|
||||
config[:formatter] = nil
|
||||
config[:includes] = []
|
||||
config[:excludes] = []
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ if RUBY_ENGINE == "ruby" and RUBY_VERSION >= "2.4.0"
|
|||
ruby_version_is "2.4"..."2.5" do
|
||||
# Kernel#warn does not delegate to Warning.warn in 2.4
|
||||
module Kernel
|
||||
remove_method :warn
|
||||
def warn(*messages)
|
||||
return if $VERBOSE == nil or messages.empty?
|
||||
msg = messages.join("\n")
|
||||
|
|
@ -16,6 +17,24 @@ if RUBY_ENGINE == "ruby" and RUBY_VERSION >= "2.4.0"
|
|||
|
||||
def Warning.warn(message)
|
||||
case message
|
||||
# $VERBOSE = true warnings
|
||||
when /possibly useless use of (<|<=|==|>=|>|\+|-) in void context/
|
||||
when /assigned but unused variable/
|
||||
when /method redefined/
|
||||
when /previous definition of/
|
||||
when /instance variable @.+ not initialized/
|
||||
when /statement not reached/
|
||||
when /shadowing outer local variable/
|
||||
when /setting Encoding.default_(in|ex)ternal/
|
||||
when /unknown (un)?pack directive/
|
||||
when /(un)?trust(ed\?)? is deprecated/
|
||||
when /\.exists\? is a deprecated name/
|
||||
when /Float .+ out of range/
|
||||
when /passing a block to String#(bytes|chars|codepoints|lines) is deprecated/
|
||||
when /core\/string\/modulo_spec\.rb:\d+: warning: too many arguments for format string/
|
||||
when /regexp\/shared\/new_ascii(_8bit)?\.rb:\d+: warning: Unknown escape .+ is ignored/
|
||||
|
||||
# $VERBOSE = false warnings
|
||||
when /constant ::(Fixnum|Bignum) is deprecated/
|
||||
when /\/(argf|io|stringio)\/.+(ARGF|IO)#(lines|chars|bytes|codepoints) is deprecated/
|
||||
when /Thread\.exclusive is deprecated.+\n.+thread\/exclusive_spec\.rb/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue