2012-05-04 17:46:01 -04:00
|
|
|
# encoding: utf-8
|
2011-02-19 15:44:08 -05:00
|
|
|
######################################################################
|
|
|
|
# This file is imported from the minitest project.
|
|
|
|
# DO NOT make modifications in this repo. They _will_ be reverted!
|
|
|
|
# File a patch instead and assign it to Ryan Davis.
|
|
|
|
######################################################################
|
2008-10-09 21:18:03 -04:00
|
|
|
|
|
|
|
#!/usr/bin/ruby -w
|
|
|
|
|
|
|
|
require 'minitest/unit'
|
|
|
|
|
2011-08-23 17:47:25 -04:00
|
|
|
class Module # :nodoc:
|
2010-09-23 17:27:19 -04:00
|
|
|
def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
|
2010-01-06 17:58:07 -05:00
|
|
|
# warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
|
|
|
|
self.class_eval <<-EOM
|
2011-11-17 18:02:16 -05:00
|
|
|
def #{new_name} *args
|
2012-05-04 17:46:01 -04:00
|
|
|
case
|
|
|
|
when Proc === self then
|
|
|
|
MiniTest::Spec.current.#{meth}(*args, &self)
|
|
|
|
when #{!!dont_flip} then
|
|
|
|
MiniTest::Spec.current.#{meth}(self, *args)
|
|
|
|
else
|
|
|
|
MiniTest::Spec.current.#{meth}(args.first, self, *args[1..-1])
|
|
|
|
end
|
2010-01-06 17:58:07 -05:00
|
|
|
end
|
|
|
|
EOM
|
|
|
|
end
|
|
|
|
|
2010-09-23 17:27:19 -04:00
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# infect_with_assertions has been removed due to excessive clever.
|
|
|
|
# Use infect_an_assertion directly instead.
|
2010-09-23 17:27:19 -04:00
|
|
|
|
2010-01-06 17:58:07 -05:00
|
|
|
def infect_with_assertions(pos_prefix, neg_prefix,
|
|
|
|
skip_re,
|
|
|
|
dont_flip_re = /\c0/,
|
|
|
|
map = {})
|
2011-08-23 17:47:25 -04:00
|
|
|
abort "infect_with_assertions is dead. Use infect_an_assertion directly"
|
2008-10-09 21:18:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-08-23 17:47:25 -04:00
|
|
|
module Kernel # :nodoc:
|
2010-03-27 21:37:07 -04:00
|
|
|
##
|
|
|
|
# Describe a series of expectations for a given target +desc+.
|
|
|
|
#
|
|
|
|
# TODO: find good tutorial url.
|
|
|
|
#
|
2011-06-01 01:12:55 -04:00
|
|
|
# Defines a test class subclassing from either MiniTest::Spec or
|
|
|
|
# from the surrounding describe's class. The surrounding class may
|
|
|
|
# subclass MiniTest::Spec manually in order to easily share code:
|
|
|
|
#
|
|
|
|
# class MySpec < MiniTest::Spec
|
|
|
|
# # ... shared code ...
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# class TestStuff < MySpec
|
|
|
|
# it "does stuff" do
|
|
|
|
# # shared code available here
|
|
|
|
# end
|
|
|
|
# describe "inner stuff" do
|
|
|
|
# it "still does stuff" do
|
|
|
|
# # ...and here
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
2011-08-23 17:47:25 -04:00
|
|
|
def describe desc, additional_desc = nil, &block # :doc:
|
2009-06-18 03:31:39 -04:00
|
|
|
stack = MiniTest::Spec.describe_stack
|
2011-08-23 17:47:25 -04:00
|
|
|
name = [stack.last, desc, additional_desc].compact.join("::")
|
2013-05-02 00:48:43 -04:00
|
|
|
sclas = stack.last || if Class === self && is_a?(MiniTest::Spec::DSL) then
|
2011-06-01 01:12:55 -04:00
|
|
|
self
|
|
|
|
else
|
|
|
|
MiniTest::Spec.spec_type desc
|
|
|
|
end
|
2010-12-01 00:33:32 -05:00
|
|
|
|
2011-08-23 17:47:25 -04:00
|
|
|
cls = sclas.create name, desc
|
2009-06-18 03:31:39 -04:00
|
|
|
|
|
|
|
stack.push cls
|
2008-10-09 21:18:03 -04:00
|
|
|
cls.class_eval(&block)
|
2009-06-18 03:31:39 -04:00
|
|
|
stack.pop
|
2010-09-01 04:40:53 -04:00
|
|
|
cls
|
2008-10-09 21:18:03 -04:00
|
|
|
end
|
2008-12-27 15:51:23 -05:00
|
|
|
private :describe
|
2008-10-09 21:18:03 -04:00
|
|
|
end
|
|
|
|
|
2010-09-23 17:27:19 -04:00
|
|
|
##
|
|
|
|
# MiniTest::Spec -- The faster, better, less-magical spec framework!
|
|
|
|
#
|
2011-08-23 17:47:25 -04:00
|
|
|
# For a list of expectations, see MiniTest::Expectations.
|
2010-09-23 17:27:19 -04:00
|
|
|
|
2008-10-09 21:18:03 -04:00
|
|
|
class MiniTest::Spec < MiniTest::Unit::TestCase
|
2011-06-01 01:12:55 -04:00
|
|
|
|
|
|
|
##
|
2013-05-02 00:48:43 -04:00
|
|
|
# Oh look! A MiniTest::Spec::DSL module! Eat your heart out DHH.
|
|
|
|
|
|
|
|
module DSL
|
|
|
|
##
|
|
|
|
# Contains pairs of matchers and Spec classes to be used to
|
|
|
|
# calculate the superclass of a top-level describe. This allows for
|
|
|
|
# automatically customizable spec types.
|
|
|
|
#
|
|
|
|
# See: register_spec_type and spec_type
|
|
|
|
|
|
|
|
TYPES = [[//, MiniTest::Spec]]
|
|
|
|
|
|
|
|
##
|
|
|
|
# Register a new type of spec that matches the spec's description.
|
|
|
|
# This method can take either a Regexp and a spec class or a spec
|
|
|
|
# class and a block that takes the description and returns true if
|
|
|
|
# it matches.
|
|
|
|
#
|
|
|
|
# Eg:
|
|
|
|
#
|
|
|
|
# register_spec_type(/Controller$/, MiniTest::Spec::Rails)
|
|
|
|
#
|
|
|
|
# or:
|
|
|
|
#
|
|
|
|
# register_spec_type(MiniTest::Spec::RailsModel) do |desc|
|
|
|
|
# desc.superclass == ActiveRecord::Base
|
|
|
|
# end
|
|
|
|
|
|
|
|
def register_spec_type(*args, &block)
|
|
|
|
if block then
|
|
|
|
matcher, klass = block, args.first
|
2011-08-27 16:30:57 -04:00
|
|
|
else
|
2013-05-02 00:48:43 -04:00
|
|
|
matcher, klass = *args
|
2011-08-27 16:30:57 -04:00
|
|
|
end
|
2013-05-02 00:48:43 -04:00
|
|
|
TYPES.unshift [matcher, klass]
|
|
|
|
end
|
2009-06-18 03:31:39 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
##
|
|
|
|
# Figure out the spec class to use based on a spec's description. Eg:
|
|
|
|
#
|
|
|
|
# spec_type("BlahController") # => MiniTest::Spec::Rails
|
2011-08-23 17:47:25 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
def spec_type desc
|
|
|
|
TYPES.find { |matcher, klass|
|
|
|
|
if matcher.respond_to? :call then
|
|
|
|
matcher.call desc
|
|
|
|
else
|
|
|
|
matcher === desc.to_s
|
|
|
|
end
|
|
|
|
}.last
|
|
|
|
end
|
2011-06-01 01:12:55 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
def describe_stack # :nodoc:
|
2013-06-21 20:20:05 -04:00
|
|
|
Thread.current[:describe_stack] ||= []
|
2009-06-18 03:31:39 -04:00
|
|
|
end
|
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
##
|
|
|
|
# Returns the children of this spec.
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
def children
|
|
|
|
@children ||= []
|
2012-08-20 20:39:57 -04:00
|
|
|
end
|
2008-10-09 21:18:03 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
def nuke_test_methods! # :nodoc:
|
|
|
|
self.public_instance_methods.grep(/^test_/).each do |name|
|
|
|
|
self.send :undef_method, name
|
|
|
|
end
|
|
|
|
end
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
##
|
|
|
|
# Define a 'before' action. Inherits the way normal methods should.
|
|
|
|
#
|
|
|
|
# NOTE: +type+ is ignored and is only there to make porting easier.
|
|
|
|
#
|
|
|
|
# Equivalent to MiniTest::Unit::TestCase#setup.
|
|
|
|
|
|
|
|
def before type = nil, &block
|
|
|
|
define_method :setup do
|
|
|
|
super()
|
|
|
|
self.instance_eval(&block)
|
|
|
|
end
|
2012-08-20 20:39:57 -04:00
|
|
|
end
|
2008-10-09 21:18:03 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
##
|
|
|
|
# Define an 'after' action. Inherits the way normal methods should.
|
|
|
|
#
|
|
|
|
# NOTE: +type+ is ignored and is only there to make porting easier.
|
|
|
|
#
|
|
|
|
# Equivalent to MiniTest::Unit::TestCase#teardown.
|
|
|
|
|
|
|
|
def after type = nil, &block
|
|
|
|
define_method :teardown do
|
|
|
|
self.instance_eval(&block)
|
|
|
|
super()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Define an expectation with name +desc+. Name gets morphed to a
|
|
|
|
# proper test method name. For some freakish reason, people who
|
|
|
|
# write specs don't like class inheritance, so this goes way out of
|
|
|
|
# its way to make sure that expectations aren't inherited.
|
|
|
|
#
|
|
|
|
# This is also aliased to #specify and doesn't require a +desc+ arg.
|
|
|
|
#
|
|
|
|
# Hint: If you _do_ want inheritence, use minitest/unit. You can mix
|
|
|
|
# and match between assertions and expectations as much as you want.
|
|
|
|
|
|
|
|
def it desc = "anonymous", &block
|
|
|
|
block ||= proc { skip "(no tests defined)" }
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
@specs ||= 0
|
|
|
|
@specs += 1
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
name = "test_%04d_%s" % [ @specs, desc ]
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
define_method name, &block
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
self.children.each do |mod|
|
|
|
|
mod.send :undef_method, name if mod.public_method_defined? name
|
|
|
|
end
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
name
|
2010-03-27 21:37:07 -04:00
|
|
|
end
|
2012-05-04 17:46:01 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
##
|
|
|
|
# Essentially, define an accessor for +name+ with +block+.
|
|
|
|
#
|
|
|
|
# Why use let instead of def? I honestly don't know.
|
2010-09-23 17:27:19 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
def let name, &block
|
|
|
|
define_method name do
|
|
|
|
@_memoized ||= {}
|
|
|
|
@_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
|
|
|
|
end
|
|
|
|
end
|
2012-05-04 17:46:01 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
##
|
|
|
|
# Another lazy man's accessor generator. Made even more lazy by
|
|
|
|
# setting the name for you to +subject+.
|
|
|
|
|
|
|
|
def subject &block
|
|
|
|
let :subject, &block
|
2011-08-23 17:47:25 -04:00
|
|
|
end
|
2010-09-23 17:27:19 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
def create name, desc # :nodoc:
|
|
|
|
cls = Class.new(self) do
|
|
|
|
@name = name
|
|
|
|
@desc = desc
|
2012-05-04 17:46:01 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
nuke_test_methods!
|
|
|
|
end
|
2011-08-23 17:47:25 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
children << cls
|
2010-09-23 17:27:19 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
cls
|
2010-09-23 17:27:19 -04:00
|
|
|
end
|
2011-08-23 17:47:25 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
def name # :nodoc:
|
|
|
|
defined?(@name) ? @name : super
|
|
|
|
end
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
def to_s # :nodoc:
|
|
|
|
name # Can't alias due to 1.8.7, not sure why
|
|
|
|
end
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2013-05-02 00:48:43 -04:00
|
|
|
# :stopdoc:
|
2011-10-19 16:34:21 -04:00
|
|
|
attr_reader :desc
|
|
|
|
alias :specify :it
|
2013-05-02 00:48:43 -04:00
|
|
|
# :startdoc:
|
2011-08-23 17:47:25 -04:00
|
|
|
end
|
2013-05-02 00:48:43 -04:00
|
|
|
|
|
|
|
extend DSL
|
|
|
|
|
|
|
|
TYPES = DSL::TYPES # :nodoc:
|
2011-08-23 17:47:25 -04:00
|
|
|
end
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2012-05-04 17:46:01 -04:00
|
|
|
##
|
|
|
|
# It's where you hide your "assertions".
|
|
|
|
|
2011-08-23 17:47:25 -04:00
|
|
|
module MiniTest::Expectations
|
2010-03-27 21:37:07 -04:00
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_empty.
|
|
|
|
#
|
|
|
|
# collection.must_be_empty
|
|
|
|
#
|
2010-03-27 21:37:07 -04:00
|
|
|
# :method: must_be_empty
|
|
|
|
|
2012-05-04 17:46:01 -04:00
|
|
|
infect_an_assertion :assert_empty, :must_be_empty, :unary
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_equal
|
|
|
|
#
|
|
|
|
# a.must_equal b
|
|
|
|
#
|
|
|
|
# :method: must_equal
|
|
|
|
|
|
|
|
infect_an_assertion :assert_equal, :must_equal
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_in_delta
|
|
|
|
#
|
|
|
|
# n.must_be_close_to m [, delta]
|
|
|
|
#
|
2012-08-20 20:39:57 -04:00
|
|
|
# :method: must_be_close_to
|
2011-08-23 17:47:25 -04:00
|
|
|
|
|
|
|
infect_an_assertion :assert_in_delta, :must_be_close_to
|
|
|
|
|
2012-08-20 20:39:57 -04:00
|
|
|
alias :must_be_within_delta :must_be_close_to # :nodoc:
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_in_epsilon
|
|
|
|
#
|
|
|
|
# n.must_be_within_epsilon m [, epsilon]
|
|
|
|
#
|
|
|
|
# :method: must_be_within_epsilon
|
|
|
|
|
|
|
|
infect_an_assertion :assert_in_epsilon, :must_be_within_epsilon
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2010-09-01 04:40:53 -04:00
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_includes
|
|
|
|
#
|
|
|
|
# collection.must_include obj
|
|
|
|
#
|
|
|
|
# :method: must_include
|
|
|
|
|
|
|
|
infect_an_assertion :assert_includes, :must_include, :reverse
|
2010-09-01 04:40:53 -04:00
|
|
|
|
2010-03-27 21:37:07 -04:00
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_instance_of
|
|
|
|
#
|
|
|
|
# obj.must_be_instance_of klass
|
|
|
|
#
|
|
|
|
# :method: must_be_instance_of
|
|
|
|
|
|
|
|
infect_an_assertion :assert_instance_of, :must_be_instance_of
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_kind_of
|
|
|
|
#
|
|
|
|
# obj.must_be_kind_of mod
|
|
|
|
#
|
|
|
|
# :method: must_be_kind_of
|
|
|
|
|
|
|
|
infect_an_assertion :assert_kind_of, :must_be_kind_of
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_match
|
|
|
|
#
|
|
|
|
# a.must_match b
|
|
|
|
#
|
|
|
|
# :method: must_match
|
|
|
|
|
|
|
|
infect_an_assertion :assert_match, :must_match
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_nil
|
|
|
|
#
|
|
|
|
# obj.must_be_nil
|
|
|
|
#
|
|
|
|
# :method: must_be_nil
|
|
|
|
|
2012-05-04 17:46:01 -04:00
|
|
|
infect_an_assertion :assert_nil, :must_be_nil, :unary
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_operator
|
|
|
|
#
|
|
|
|
# n.must_be :<=, 42
|
|
|
|
#
|
2011-10-19 16:34:21 -04:00
|
|
|
# This can also do predicates:
|
|
|
|
#
|
|
|
|
# str.must_be :empty?
|
|
|
|
#
|
2011-08-23 17:47:25 -04:00
|
|
|
# :method: must_be
|
|
|
|
|
2011-10-19 16:34:21 -04:00
|
|
|
infect_an_assertion :assert_operator, :must_be, :reverse
|
2010-03-27 21:37:07 -04:00
|
|
|
|
2010-09-01 04:40:53 -04:00
|
|
|
##
|
|
|
|
# See MiniTest::Assertions#assert_output
|
2011-08-23 17:47:25 -04:00
|
|
|
#
|
|
|
|
# proc { ... }.must_output out_or_nil [, err]
|
|
|
|
#
|
|
|
|
# :method: must_output
|
|
|
|
|
|
|
|
infect_an_assertion :assert_output, :must_output
|
2010-09-01 04:40:53 -04:00
|
|
|
|
2010-03-27 21:37:07 -04:00
|
|
|
##
|
|
|
|
# See MiniTest::Assertions#assert_raises
|
2011-08-23 17:47:25 -04:00
|
|
|
#
|
|
|
|
# proc { ... }.must_raise exception
|
|
|
|
#
|
|
|
|
# :method: must_raise
|
|
|
|
|
|
|
|
infect_an_assertion :assert_raises, :must_raise
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
# See MiniTest::Assertions#assert_respond_to
|
2011-08-23 17:47:25 -04:00
|
|
|
#
|
|
|
|
# obj.must_respond_to msg
|
|
|
|
#
|
|
|
|
# :method: must_respond_to
|
|
|
|
|
|
|
|
infect_an_assertion :assert_respond_to, :must_respond_to, :reverse
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_same
|
|
|
|
#
|
|
|
|
# a.must_be_same_as b
|
|
|
|
#
|
|
|
|
# :method: must_be_same_as
|
|
|
|
|
|
|
|
infect_an_assertion :assert_same, :must_be_same_as
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_send
|
|
|
|
# TODO: remove me
|
|
|
|
#
|
|
|
|
# a.must_send
|
|
|
|
#
|
|
|
|
# :method: must_send
|
|
|
|
|
|
|
|
infect_an_assertion :assert_send, :must_send
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_silent
|
|
|
|
#
|
|
|
|
# proc { ... }.must_be_silent
|
|
|
|
#
|
|
|
|
# :method: must_be_silent
|
|
|
|
|
|
|
|
infect_an_assertion :assert_silent, :must_be_silent
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#assert_throws
|
|
|
|
#
|
|
|
|
# proc { ... }.must_throw sym
|
|
|
|
#
|
|
|
|
# :method: must_throw
|
|
|
|
|
|
|
|
infect_an_assertion :assert_throws, :must_throw
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
# See MiniTest::Assertions#refute_empty
|
2011-08-23 17:47:25 -04:00
|
|
|
#
|
|
|
|
# collection.wont_be_empty
|
|
|
|
#
|
|
|
|
# :method: wont_be_empty
|
|
|
|
|
2012-05-04 17:46:01 -04:00
|
|
|
infect_an_assertion :refute_empty, :wont_be_empty, :unary
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#refute_equal
|
|
|
|
#
|
|
|
|
# a.wont_equal b
|
|
|
|
#
|
|
|
|
# :method: wont_equal
|
|
|
|
|
|
|
|
infect_an_assertion :refute_equal, :wont_equal
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#refute_in_delta
|
|
|
|
#
|
|
|
|
# n.wont_be_close_to m [, delta]
|
|
|
|
#
|
2012-08-20 20:39:57 -04:00
|
|
|
# :method: wont_be_close_to
|
2011-08-23 17:47:25 -04:00
|
|
|
|
2012-08-20 20:39:57 -04:00
|
|
|
infect_an_assertion :refute_in_delta, :wont_be_close_to
|
2011-08-23 17:47:25 -04:00
|
|
|
|
2012-08-20 20:39:57 -04:00
|
|
|
alias :wont_be_within_delta :wont_be_close_to # :nodoc:
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#refute_in_epsilon
|
|
|
|
#
|
|
|
|
# n.wont_be_within_epsilon m [, epsilon]
|
|
|
|
#
|
|
|
|
# :method: wont_be_within_epsilon
|
|
|
|
|
|
|
|
infect_an_assertion :refute_in_epsilon, :wont_be_within_epsilon
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#refute_includes
|
|
|
|
#
|
|
|
|
# collection.wont_include obj
|
|
|
|
#
|
|
|
|
# :method: wont_include
|
|
|
|
|
|
|
|
infect_an_assertion :refute_includes, :wont_include, :reverse
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#refute_instance_of
|
|
|
|
#
|
|
|
|
# obj.wont_be_instance_of klass
|
|
|
|
#
|
|
|
|
# :method: wont_be_instance_of
|
|
|
|
|
|
|
|
infect_an_assertion :refute_instance_of, :wont_be_instance_of
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#refute_kind_of
|
|
|
|
#
|
|
|
|
# obj.wont_be_kind_of mod
|
|
|
|
#
|
|
|
|
# :method: wont_be_kind_of
|
|
|
|
|
|
|
|
infect_an_assertion :refute_kind_of, :wont_be_kind_of
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#refute_match
|
|
|
|
#
|
|
|
|
# a.wont_match b
|
|
|
|
#
|
|
|
|
# :method: wont_match
|
|
|
|
|
|
|
|
infect_an_assertion :refute_match, :wont_match
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#refute_nil
|
|
|
|
#
|
|
|
|
# obj.wont_be_nil
|
|
|
|
#
|
|
|
|
# :method: wont_be_nil
|
|
|
|
|
2012-05-04 17:46:01 -04:00
|
|
|
infect_an_assertion :refute_nil, :wont_be_nil, :unary
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
2011-08-23 17:47:25 -04:00
|
|
|
# See MiniTest::Assertions#refute_operator
|
|
|
|
#
|
|
|
|
# n.wont_be :<=, 42
|
|
|
|
#
|
2011-10-19 16:34:21 -04:00
|
|
|
# This can also do predicates:
|
|
|
|
#
|
|
|
|
# str.wont_be :empty?
|
|
|
|
#
|
2011-08-23 17:47:25 -04:00
|
|
|
# :method: wont_be
|
|
|
|
|
2011-10-19 16:34:21 -04:00
|
|
|
infect_an_assertion :refute_operator, :wont_be, :reverse
|
2010-03-27 21:37:07 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
# See MiniTest::Assertions#refute_respond_to
|
2011-08-23 17:47:25 -04:00
|
|
|
#
|
|
|
|
# obj.wont_respond_to msg
|
|
|
|
#
|
|
|
|
# :method: wont_respond_to
|
|
|
|
|
|
|
|
infect_an_assertion :refute_respond_to, :wont_respond_to, :reverse
|
|
|
|
|
|
|
|
##
|
|
|
|
# See MiniTest::Assertions#refute_same
|
|
|
|
#
|
|
|
|
# a.wont_be_same_as b
|
|
|
|
#
|
|
|
|
# :method: wont_be_same_as
|
|
|
|
|
|
|
|
infect_an_assertion :refute_same, :wont_be_same_as
|
|
|
|
end
|
|
|
|
|
2012-05-04 17:46:01 -04:00
|
|
|
class Object # :nodoc:
|
2012-11-28 22:23:11 -05:00
|
|
|
include MiniTest::Expectations unless ENV["MT_NO_EXPECTATIONS"]
|
2008-10-09 21:18:03 -04:00
|
|
|
end
|