diff --git a/ChangeLog b/ChangeLog index cfd442f753..406db7522f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jul 12 08:48:33 2012 Ryan Davis + + * lib/minitest/*: Imported minitest 3.2.0 (r7598) + * test/minitest/*: ditto + Thu Jul 12 05:11:41 2012 Nobuyoshi Nakada * insns.def (defined): use method entry and id in cfp for proper diff --git a/lib/minitest/mock.rb b/lib/minitest/mock.rb index ec36d775cc..38f15757eb 100644 --- a/lib/minitest/mock.rb +++ b/lib/minitest/mock.rb @@ -57,12 +57,12 @@ module MiniTest self end - def call name, data + def __call name, data case data when Hash then "#{name}(#{data[:args].inspect[1..-2]}) => #{data[:retval].inspect}" else - data.map { |d| call name, d }.join ", " + data.map { |d| __call name, d }.join ", " end end @@ -74,15 +74,16 @@ module MiniTest def verify @expected_calls.each do |name, calls| calls.each do |expected| - msg1 = "expected #{call name, expected}" - msg2 = "#{msg1}, got [#{call name, @actual_calls[name]}]" + msg1 = "expected #{__call name, expected}" + msg2 = "#{msg1}, got [#{__call name, @actual_calls[name]}]" raise MockExpectationError, msg2 if - @actual_calls.has_key? name and + @actual_calls.has_key?(name) and not @actual_calls[name].include?(expected) raise MockExpectationError, msg1 unless - @actual_calls.has_key? name and @actual_calls[name].include?(expected) + @actual_calls.has_key?(name) and + @actual_calls[name].include?(expected) end end true @@ -163,7 +164,7 @@ class Object # :nodoc: end end - yield + yield self ensure metaclass.send :undef_method, name metaclass.send :alias_method, name, new_name diff --git a/lib/minitest/spec.rb b/lib/minitest/spec.rb index c0c0ae2f02..02c57ec7ef 100644 --- a/lib/minitest/spec.rb +++ b/lib/minitest/spec.rb @@ -181,12 +181,6 @@ class MiniTest::Spec < MiniTest::Unit::TestCase add_teardown_hook {|tc| tc.instance_eval(&block) } end - NAME_RE = if RUBY_VERSION >= "1.9" - Regexp.new("[^[[:word:]]]+") - else - /\W+/u - end - ## # Define an expectation with name +desc+. Name gets morphed to a # proper test method name. For some freakish reason, people who @@ -204,7 +198,7 @@ class MiniTest::Spec < MiniTest::Unit::TestCase @specs ||= 0 @specs += 1 - name = "test_%04d_%s" % [ @specs, desc.gsub(NAME_RE, '_').downcase ] + name = "test_%04d_%s" % [ @specs, desc ] define_method name, &block diff --git a/lib/minitest/unit.rb b/lib/minitest/unit.rb index 50c1fac94b..1b95742af3 100644 --- a/lib/minitest/unit.rb +++ b/lib/minitest/unit.rb @@ -652,7 +652,7 @@ module MiniTest end class Unit # :nodoc: - VERSION = "3.0.0" # :nodoc: + VERSION = "3.2.0" # :nodoc: attr_accessor :report, :failures, :errors, :skips # :nodoc: attr_accessor :test_count, :assertion_count # :nodoc: @@ -713,16 +713,6 @@ module MiniTest @@out end - ## - # Returns the stream to use for output. - # - # DEPRECATED: use ::output instead. - - def self.out - warn "::out deprecated, use ::output instead." if $VERBOSE - output - end - ## # Sets MiniTest::Unit to write output to +stream+. $stdout is the default # output diff --git a/test/minitest/metametameta.rb b/test/minitest/metametameta.rb index 609e551ff5..35a27d51b6 100644 --- a/test/minitest/metametameta.rb +++ b/test/minitest/metametameta.rb @@ -27,6 +27,8 @@ class MetaMetaMetaTestCase < MiniTest::Unit::TestCase output.sub!(/Finished tests in .*/, "Finished tests in 0.00") output.sub!(/Loaded suite .*/, 'Loaded suite blah') + output.gsub!(/ = \d+.\d\d s = /, ' = 0.00 s = ') + if windows? then output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, '[FILE:LINE]') output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in') diff --git a/test/minitest/test_minitest_mock.rb b/test/minitest/test_minitest_mock.rb index 87774c9ebb..cd235d60da 100644 --- a/test/minitest/test_minitest_mock.rb +++ b/test/minitest/test_minitest_mock.rb @@ -211,7 +211,7 @@ class TestMiniTestMock < MiniTest::Unit::TestCase end end -require "metametameta" +require "minitest/metametameta" class TestMiniTestStub < MiniTest::Unit::TestCase def setup @@ -268,4 +268,14 @@ class TestMiniTestStub < MiniTest::Unit::TestCase assert_stub obj end + + def test_stub_yield_self + obj = "foo" + + val = obj.stub :to_s, "bar" do |s| + s.to_s + end + + @tc.assert_equal "bar", val + end end diff --git a/test/minitest/test_minitest_spec.rb b/test/minitest/test_minitest_spec.rb index 68c4dec003..d267e8d7d0 100644 --- a/test/minitest/test_minitest_spec.rb +++ b/test/minitest/test_minitest_spec.rb @@ -645,8 +645,8 @@ class TestMeta < MiniTest::Unit::TestCase assert_equal "inner thingy", y.desc assert_equal "very inner thingy", z.desc - top_methods = %w(test_0001_top_level_it) - inner_methods1 = %w(test_0001_inner_it) + top_methods = %w(test_0001_top-level-it) + inner_methods1 = %w(test_0001_inner-it) inner_methods2 = inner_methods1 + %w(test_0002_anonymous test_0003_anonymous) @@ -690,13 +690,13 @@ class TestMeta < MiniTest::Unit::TestCase x = describe "top-level thingy" do y = describe "first thingy" do end - x1 = it "top-level-it" do end + x1 = it "top level it" do end x2 = it "не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world" do end z = describe "second thingy" do end end - test_methods = ['test_0001_top_level_it', 'test_0002_не_латинские_буквы_и_спецсимволы_いった_α_β_γ_δ_ε_hello_world'].sort + test_methods = ['test_0001_top level it', 'test_0002_не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world'].sort assert_equal test_methods, [x1, x2] assert_equal test_methods, diff --git a/test/minitest/test_minitest_unit.rb b/test/minitest/test_minitest_unit.rb index 27132515ef..b27f3fde33 100644 --- a/test/minitest/test_minitest_unit.rb +++ b/test/minitest/test_minitest_unit.rb @@ -6,7 +6,7 @@ ###################################################################### require 'pathname' -require 'metametameta' +require 'minitest/metametameta' module MyModule; end class AnError < StandardError; include MyModule; end