[前][次][番号順一覧][スレッド一覧]

ruby-changes:33997

From: akr <ko1@a...>
Date: Sat, 24 May 2014 19:20:46 +0900 (JST)
Subject: [ruby-changes:33997] akr:r46078 (trunk): * test/lib/minitest/spec.rb: Unused file removed.

akr	2014-05-24 19:20:41 +0900 (Sat, 24 May 2014)

  New Revision: 46078

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=46078

  Log:
    * test/lib/minitest/spec.rb: Unused file removed.
    
    * test/lib/minitest/autorun.rb: Don't require minitest/spec.
    
    * test/lib/minitest/benchmark.rb: Ditto.

  Removed files:
    trunk/test/lib/minitest/spec.rb
    trunk/test/minitest/test_minitest_spec.rb
  Modified files:
    trunk/ChangeLog
    trunk/test/lib/minitest/autorun.rb
    trunk/test/lib/minitest/benchmark.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46077)
+++ ChangeLog	(revision 46078)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat May 24 19:08:47 2014  Tanaka Akira  <akr@f...>
+
+	* test/lib/minitest/spec.rb: Unused file removed.
+
+	* test/lib/minitest/autorun.rb: Don't require minitest/spec.
+
+	* test/lib/minitest/benchmark.rb: Ditto.
+
 Sat May 24 18:45:30 2014  Tanaka Akira  <akr@f...>
 
 	* test/benchmark/test_benchmark.rb: Use test/unit.
Index: test/lib/minitest/spec.rb
===================================================================
--- test/lib/minitest/spec.rb	(revision 46077)
+++ test/lib/minitest/spec.rb	(revision 46078)
@@ -1,546 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/test/lib/minitest/spec.rb#L0
-# encoding: utf-8
-
-#!/usr/bin/ruby -w
-
-require 'minitest/unit'
-
-class Module # :nodoc:
-  def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
-    # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
-    self.class_eval <<-EOM
-      def #{new_name} *args
-        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
-      end
-    EOM
-  end
-
-  ##
-  # infect_with_assertions has been removed due to excessive clever.
-  # Use infect_an_assertion directly instead.
-
-  def infect_with_assertions(pos_prefix, neg_prefix,
-                             skip_re,
-                             dont_flip_re = /\c0/,
-                             map = {})
-    abort "infect_with_assertions is dead. Use infect_an_assertion directly"
-  end
-end
-
-module Kernel # :nodoc:
-  ##
-  # Describe a series of expectations for a given target +desc+.
-  #
-  # TODO: find good tutorial url.
-  #
-  # 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
-
-  def describe desc, additional_desc = nil, &block # :doc:
-    stack = MiniTest::Spec.describe_stack
-    name  = [stack.last, desc, additional_desc].compact.join("::")
-    sclas = stack.last || if Class === self && is_a?(MiniTest::Spec::DSL) then
-                            self
-                          else
-                            MiniTest::Spec.spec_type desc
-                          end
-
-    cls = sclas.create name, desc
-
-    stack.push cls
-    cls.class_eval(&block)
-    stack.pop
-    cls
-  end
-  private :describe
-end
-
-##
-# MiniTest::Spec -- The faster, better, less-magical spec framework!
-#
-# For a list of expectations, see MiniTest::Expectations.
-
-class MiniTest::Spec < MiniTest::Unit::TestCase
-
-  ##
-  # 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
-      else
-        matcher, klass = *args
-      end
-      TYPES.unshift [matcher, klass]
-    end
-
-    ##
-    # Figure out the spec class to use based on a spec's description. Eg:
-    #
-    #     spec_type("BlahController") # => MiniTest::Spec::Rails
-
-    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
-
-    def describe_stack # :nodoc:
-      Thread.current[:describe_stack] ||= []
-    end
-
-    ##
-    # Returns the children of this spec.
-
-    def children
-      @children ||= []
-    end
-
-    def nuke_test_methods! # :nodoc:
-      self.public_instance_methods.grep(/^test_/).each do |name|
-        self.send :undef_method, name
-      end
-    end
-
-    ##
-    # 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
-    end
-
-    ##
-    # 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)" }
-
-      @specs ||= 0
-      @specs += 1
-
-      name = "test_%04d_%s" % [ @specs, desc ]
-
-      define_method name, &block
-
-      self.children.each do |mod|
-        mod.send :undef_method, name if mod.public_method_defined? name
-      end
-
-      name
-    end
-
-    ##
-    # Essentially, define an accessor for +name+ with +block+.
-    #
-    # Why use let instead of def? I honestly don't know.
-
-    def let name, &block
-      define_method name do
-        @_memoized ||= {}
-        @_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
-      end
-    end
-
-    ##
-    # Another lazy man's accessor generator. Made even more lazy by
-    # setting the name for you to +subject+.
-
-    def subject &block
-      let :subject, &block
-    end
-
-    def create name, desc # :nodoc:
-      cls = Class.new(self) do
-        @name = name
-        @desc = desc
-
-        nuke_test_methods!
-      end
-
-      children << cls
-
-      cls
-    end
-
-    def name # :nodoc:
-      defined?(@name) ? @name : super
-    end
-
-    def to_s # :nodoc:
-      name # Can't alias due to 1.8.7, not sure why
-    end
-
-    # :stopdoc:
-    attr_reader :desc
-    alias :specify :it
-    # :startdoc:
-  end
-
-  extend DSL
-
-  TYPES = DSL::TYPES # :nodoc:
-end
-
-##
-# It's where you hide your "assertions".
-
-module MiniTest::Expectations
-  ##
-  # See MiniTest::Assertions#assert_empty.
-  #
-  #    collection.must_be_empty
-  #
-  # :method: must_be_empty
-
-  infect_an_assertion :assert_empty, :must_be_empty, :unary
-
-  ##
-  # See MiniTest::Assertions#assert_equal
-  #
-  #    a.must_equal b
-  #
-  # :method: must_equal
-
-  infect_an_assertion :assert_equal, :must_equal
-
-  ##
-  # See MiniTest::Assertions#assert_in_delta
-  #
-  #    n.must_be_close_to m [, delta]
-  #
-  # :method: must_be_close_to
-
-  infect_an_assertion :assert_in_delta, :must_be_close_to
-
-  alias :must_be_within_delta :must_be_close_to # :nodoc:
-
-  ##
-  # 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
-
-  ##
-  # See MiniTest::Assertions#assert_includes
-  #
-  #    collection.must_include obj
-  #
-  # :method: must_include
-
-  infect_an_assertion :assert_includes, :must_include, :reverse
-
-  ##
-  # 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
-
-  ##
-  # 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
-
-  ##
-  # See MiniTest::Assertions#assert_match
-  #
-  #    a.must_match b
-  #
-  # :method: must_match
-
-  infect_an_assertion :assert_match, :must_match
-
-  ##
-  # See MiniTest::Assertions#assert_nil
-  #
-  #    obj.must_be_nil
-  #
-  # :method: must_be_nil
-
-  infect_an_assertion :assert_nil, :must_be_nil, :unary
-
-  ##
-  # See MiniTest::Assertions#assert_operator
-  #
-  #    n.must_be :<=, 42
-  #
-  # This can also do predicates:
-  #
-  #    str.must_be :empty?
-  #
-  # :method: must_be
-
-  infect_an_assertion :assert_operator, :must_be, :reverse
-
-  ##
-  # See MiniTest::Assertions#assert_output
-  #
-  #    proc { ... }.must_output out_or_nil [, err]
-  #
-  # :method: must_output
-
-  infect_an_assertion :assert_output, :must_output
-
-  ##
-  # See MiniTest::Assertions#assert_raises
-  #
-  #    proc { ... }.must_raise exception
-  #
-  # :method: must_raise
-
-  infect_an_assertion :assert_raises, :must_raise
-
-  ##
-  # See MiniTest::Assertions#assert_respond_to
-  #
-  #    obj.must_respond_to msg
-  #
-  # :method: must_respond_to
-
-  infect_an_assertion :assert_respond_to, :must_respond_to, :reverse
-
-  ##
-  # 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
-
-  ##
-  # See MiniTest::Assertions#assert_send
-  # TODO: remove me
-  #
-  #    a.must_send
-  #
-  # :method: must_send
-
-  infect_an_assertion :assert_send, :must_send
-
-  ##
-  # See MiniTest::Assertions#assert_silent
-  #
-  #    proc { ... }.must_be_silent
-  #
-  # :method: must_be_silent
-
-  infect_an_assertion :assert_silent, :must_be_silent
-
-  ##
-  # See MiniTest::Assertions#assert_throws
-  #
-  #    proc { ... }.must_throw sym
-  #
-  # :method: must_throw
-
-  infect_an_assertion :assert_throws, :must_throw
-
-  ##
-  # See MiniTest::Assertions#refute_empty
-  #
-  #    collection.wont_be_empty
-  #
-  # :method: wont_be_empty
-
-  infect_an_assertion :refute_empty, :wont_be_empty, :unary
-
-  ##
-  # See MiniTest::Assertions#refute_equal
-  #
-  #    a.wont_equal b
-  #
-  # :method: wont_equal
-
-  infect_an_assertion :refute_equal, :wont_equal
-
-  ##
-  # See MiniTest::Assertions#refute_in_delta
-  #
-  #    n.wont_be_close_to m [, delta]
-  #
-  # :method: wont_be_close_to
-
-  infect_an_assertion :refute_in_delta, :wont_be_close_to
-
-  alias :wont_be_within_delta :wont_be_close_to # :nodoc:
-
-  ##
-  # 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
-
-  ##
-  # See MiniTest::Assertions#refute_includes
-  #
-  #    collection.wont_include obj
-  #
-  # :method: wont_include
-
-  infect_an_assertion :refute_includes, :wont_include, :reverse
-
-  ##
-  # 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
-
-  ##
-  # 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
-
-  ##
-  # See MiniTest::Assertions#refute_match
-  #
-  #    a.wont_match b
-  #
-  # :method: wont_match
-
-  infect_an_assertion :refute_match, :wont_match
-
-  ##
-  # See MiniTest::Assertions#refute_nil
-  #
-  #    obj.wont_be_nil
-  #
-  # :method: wont_be_nil
-
-  infect_an_assertion :refute_nil, :wont_be_nil, :unary
-
-  ##
-  # See MiniTest::Assertions#refute_operator
-  #
-  #    n.wont_be :<=, 42
-  #
-  # This can also do predicates:
-  #
-  #    str.wont_be :empty?
-  #
-  # :method: wont_be
-
-  infect_an_assertion :refute_operator, :wont_be, :reverse
-
-  ##
-  # See MiniTest::Assertions#refute_respond_to
-  #
-  #    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
-
-class Object # :nodoc:
-  include MiniTest::Expectations unless ENV["MT_NO_EXPECTATIONS"]
-end
Index: test/lib/minitest/autorun.rb
===================================================================
--- test/lib/minitest/autorun.rb	(revision 46077)
+++ test/lib/minitest/autorun.rb	(revision 46078)
@@ -8,7 +8,6 @@ rescue Gem::LoadError https://github.com/ruby/ruby/blob/trunk/test/lib/minitest/autorun.rb#L8
 end
 
 require 'minitest/unit'
-require 'minitest/spec'
 require 'minitest/mock'
 
 MiniTest::Unit.autorun
Index: test/lib/minitest/benchmark.rb
===================================================================
--- test/lib/minitest/benchmark.rb	(revision 46077)
+++ test/lib/minitest/benchmark.rb	(revision 46078)
@@ -1,7 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/test/lib/minitest/benchmark.rb#L1
 # encoding: utf-8
 
 require 'minitest/unit'
-require 'minitest/spec'
 
 class MiniTest::Unit # :nodoc:
   def run_benchmarks # :nodoc:
Index: test/minitest/test_minitest_spec.rb
===================================================================
--- test/minitest/test_minitest_spec.rb	(revision 46077)
+++ test/minitest/test_minitest_spec.rb	(revision 46078)
@@ -1,804 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/test/minitest/test_minitest_spec.rb#L0
-# encoding: utf-8
-
-# encoding: utf-8
-require "minitest/autorun"
-require "stringio"
-
-class MiniSpecA < MiniTest::Spec; end
-class MiniSpecB < MiniTest::Unit::TestCase; extend MiniTest::Spec::DSL; end
-class MiniSpecC < MiniSpecB; end
-class NamedExampleA < MiniSpecA; end
-class NamedExampleB < MiniSpecB; end
-class NamedExampleC < MiniSpecC; end
-class ExampleA; end
-class ExampleB < ExampleA; end
-
-describe MiniTest::Spec do
-  # do not parallelize this suite... it just can"t handle it.
-
-  def assert_triggered expected = "blah", klass = MiniTest::Assertion
-    @assertion_count += 2
-
-    e = assert_raises(klass) do
-      yield
-    end
-
-    msg = e.message.sub(/(---Backtrace---).*/m, '\1')
-    msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
-
-    assert_equal expected, msg
-  end
-
-  before do
-    @assertion_count = 4
-  end
-
-  after do
-    self._assertions.must_equal @assertion_count if passed? and not skipped?
-  end
-
-  it "needs to be able to catch a MiniTest::Assertion exception" do
-    @assertion_count = 1
-
-    assert_triggered "Expected 1 to not be equal to 1." do
-      1.wont_equal 1
-    end
-  end
-
-  it "needs to be sensible about must_include order" do
-    @assertion_count += 3 # must_include is 2 assertions
-
-    [1, 2, 3].must_include(2).must_equal true
-
-    assert_triggered "Expected [1, 2, 3] to include 5." do
-      [1, 2, 3].must_include 5
-    end
-
-    assert_triggered "msg.\nExpected [1, 2, 3] to include 5." do
-      [1, 2, 3].must_include 5, "msg"
-    end
-  end
-
-  it "needs to be sensible about wont_include order" do
-    @assertion_count += 3 # wont_include is 2 assertions
-
-    [1, 2, 3].wont_include(5).must_equal false
-
-    assert_triggered "Expected [1, 2, 3] to not include 2." do
-      [1, 2, 3].wont_include 2
-    end
-
-    assert_triggered "msg.\nExpected [1, 2, 3] to not include 2." do
-      [1, 2, 3].wont_include 2, "msg"
-    end
-  end
-
-  it "needs to catch an expected exception" do
-    @assertion_count = 2
-
-    proc { raise "blah" }.must_raise RuntimeError
-    proc { raise MiniTest::Assertion }.must_raise MiniTest::Assertion
-  end
-
-  it "needs to catch an unexpected exception" do
-    @assertion_count -= 2 # no positive
-
-    msg = <<-EOM.gsub(/^ {6}/, "").chomp
-      [RuntimeError] exception expected, not
-      Class: <MiniTest::Assertion>
-      Message: <"MiniTest::Assertion">
-      ---Backtrace---
-    EOM
-
-    assert_triggered msg do
-      proc { raise MiniTest::Assertion }.must_raise RuntimeError
-    end
-
-    assert_triggered "msg.\n#{msg}" do
-      proc { raise MiniTest::Assertion }.must_raise RuntimeError, "msg"
-    end
-  end
-
-  it "needs to ensure silence" do
-    @assertion_count -= 1 # no msg
-    @assertion_count += 2 # assert_output is 2 assertions
-
-    proc {  }.must_be_silent.must_equal true
-
-    assert_triggered "In stdout.\nExpected: \"\"\n  Actual: \"xxx\"" do
-      proc { print "xxx" }.must_be_silent
-    end
-  end
-
-  it "needs to have all methods named well" do
-    @assertion_count = 2
-
-    methods = Object.public_instance_methods.find_all { |n| n =~ /^must|^wont/ }
-    methods.map! { |m| m.to_s } if Symbol === methods.first
-
-    musts, wonts = methods.sort.partition { |m| m =~ /^must/ }
-
-    expected_musts = %w(must_be
-                        must_be_close_to
-                        must_be_empty
-                        must_be_instance_of
-                        must_be_kind_of
-                        must_be_nil
-                        must_be_same_as
-                        must_be_silent
-                        must_be_within_delta
-                        must_be_within_epsilon
-                        must_equal
-                        must_include
-                        must_match
-                        must_output
-                        must_raise
-                        must_respond_to
-                        must_send
-                        must_throw)
-
-    bad = %w[not raise throw send output be_silent]
-
-    expected_wonts = expected_musts.map { |m| m.sub(/^must/, "wont") }
-    expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
-
-    musts.must_equal expected_musts
-    wonts.must_equal expected_wonts
-  end
-
-  it "needs to raise if an expected exception is not raised" do
-    @assertion_count -= 2 # no positive test
-
-    assert_triggered "RuntimeError expected but nothing was raised." do
-      proc { 42 }.must_raise RuntimeError
-    end
-
-    assert_triggered "msg.\nRuntimeError expected but nothing was raised." do
-      proc { 42 }.must_raise RuntimeError, "msg"
-    end
-  end
-
-  it "needs to verify binary messages" do
-    42.wont_be(:<, 24).must_equal false
-
-    assert_triggered "Expected 24 to not be < 42." do
-      24.wont_be :<, 42
-    end
-
-    assert_triggered "msg.\nExpected 24 to not be < 42." do
-      24.wont_be :<, 42, "msg"
-    end
-  end
-
-  it "needs to verify emptyness" do
-    @assertion_count += 3 # empty is 2 assertions
-
-    [].must_be_empty.must_equal true
-
-    assert_triggered "Expected [42] to be empty." do
-      [42].must_be_empty
-    end
-
-    assert_triggered "msg.\nExpected [42] to be empty." do
-      [42].must_be_empty "msg"
-    end
-  (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]